Skip to content

Latest commit

 

History

History
76 lines (47 loc) · 2.38 KB

README.md

File metadata and controls

76 lines (47 loc) · 2.38 KB

YOLOv3 CoreML

Paper on YOLOv3

Darknet Github

Darknet Website

The converted CoreML model is included in this repository

YOLOv3 on Openimages dataset

Create keras model

  1. Download the openimages.cfg

  2. Download the openimages.weights

  3. Install keras-yolov3

  4. Run the following:

python3 convert.py yolov3-openimages.cfg yolov3-openimages.weights model_data/yolo-openimages.h5

Convert keras model to coreml

  1. Install coremltools:
pip install coremltools
  1. Create and run this file:
import coremltools

coreml_model = coremltools.converters.keras.convert(
    './model_data/yolo-openimages.h5',
    input_names='image',
    image_input_names='image',
    image_scale=1/255.,
    input_name_shape_dict = {'image': [None, 608, 608, 3]})

coreml_model.author = 'Original paper: Joseph Redmon, Ali Farhadi'
coreml_model.license = 'Public Domain'
coreml_model.short_description = "The YOLO network from the paper 'YOLOv3: An Incremental Improvement' (2018)"
coreml_model.input_description['image'] = 'Input image'

print(coreml_model)
coreml_model.save('yolo-openimages.mlmodel')

Now you have a CoreML model!

Implementation info

To implement something usefull with this you'll need the anchors, found in the yolov3 -openimages.cfg

[10.13, 16.30, 33.23, 30.61, 62.45, 59.119, 116.90, 156.198, 373.326]

And the labels for the openimages dataset categories

openimages.labels

TODO

Tasks for converting this code from YOLOv3 COCO dataset usage to OpenImages dataset use include:

  • Convert YOLO v3 OpenImages to CoreML ✅
  • Change anchors in code to reflect the OpenImages dataset anchors ✅
  • Update colors in code to not generate and create 80 for COCO but instead use 1 color instead of 601 colors for OpenImages ✅
  • fix crashes in computeBoundingBoxes 1 due to code not being compatible with the now smaller anchors array, another due to offset calculation