欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

第 24 期 - YOLOv3 模型转换和应用

最编程 2024-05-04 11:37:33
...

要解决“ YOLOv3体系结构概述”部分中说明的问题,请使用yolo_v3.json或yolo_v3_tiny.json(取决于模型)配置文件以及位于<OPENVINO_INSTALL_DIR>/deployment_tools/model_optimizer/extensions/front/tf存储库中的自定义操作。


以YOLOV3配置文件为例,它包含几个属性:

[

  {

    "id": "TFYOLOV3",

    "match_kind": "general",

    "custom_attributes": {

      "classes": 80,

      "anchors": [10, 13, 16, 30, 33, 23, 30, 61, 62, 45, 59, 119, 116, 90, 156, 198, 373, 326],

      "coords": 4,

      "num": 9,

      "masks":[[6, 7, 8], [3, 4, 5], [0, 1, 2]],

      "entry_points": ["detector/yolo-v3/Reshape", "detector/yolo-v3/Reshape_4", "detector/yolo-v3/Reshape_8"]

    }

  }

]


其中:

· id和match_kind是参数,你不能改变。

· custom_attributes 是存储所有YOLOv3特定属性的参数:

o classes,coords,num,和masks是属性,你应该从用于模型训练的配置文件复制文件。如果您使用的暗网正式共享权,您可以使用yolov3.cfg或yolov3-tiny.cfg从配置文件https://github.com/pjreddie/darknet/tree/master/cfg。将默认值替换为配置文件中标题后面custom_attributes的参数[yolo]。

o anchors是一个可选参数,在模型推断时不使用,但在演示中用于解析Region图层输出

o entry_points 是一个节点名称列表,用于切断模型并向Region区域添加上面指定的自定义属性。


要生成YOLOv3 TensorFlow模型的IR,请运行:

python3 mo_tf.py

--input_model /path/to/yolo_v3.pb

--tensorflow_use_custom_operations_config $ MO_ROOT / extensions / front / tf / yolo_v3.json


要生成YOLOv3-tiny TensorFlow模型的IR,请运行:

python3 mo_tf.py

--input_model /path/to/yolo_v3_tiny.pb

--tensorflow_use_custom_operations_config $ MO_ROOT / extensions / front / tf / yolo_v3_tiny.json


其中:

· --batch定义模型输入的形状。在示例中,--batch等于1,但是您还可以指定其他大于1的整数。

· --tensorflow_use_custom_operations_configRegion向模型添加缺少的图层。在IR中,Region图层的名称为RegionYolo。