hollance / YOLO-CoreML-MPSNNGraph

Tiny YOLO for iOS implemented using CoreML but also using the new MPS graph API.
MIT License
929 stars 251 forks source link

Compatibility with YOLOV2 #28

Closed vvkv closed 5 years ago

vvkv commented 6 years ago

Hi there, Thank you very much for you work on this. I am attempting to use my YOLOv2 model on the app in pursuit of a higher accuracy. I am able to successfully convert the YOLO weights into a mlCore model, but when I add the model onto the xcode, there is no recognition happening. I know the model is loaded because the FPS dropped from ~19 while using tiny-yolo to ~3 on my iPhone 8. Is there any other change that needs to be made when working with a yolo model? The model size is about 280mb and I have already made changes to reflect in the number of classes and their labels. Thank you.

hollance commented 6 years ago

I haven't tried the full YOLOv2 so I'm not sure where the potential issues may be. Does it work when you make predictions with the mlmodel from Python?

vvkv commented 6 years ago

yes it does work when working through python

kinergy commented 6 years ago

any progress on testing YoloV2 on iOS?

oishi89 commented 6 years ago

@kinergy @vvkv with YOLOv2 you need to remove the reorg layer in .cfg file then retrain the model before conversion into coreML.

vvkv commented 6 years ago

@oishi89 I could make the conversion directly without having to make any changes in the cfg file. Will removing this layer before conversion have any impact on the FPS?

oishi89 commented 6 years ago

Sure you can convert directly but there will be no detections unless removing the layers. Not sure about the FPS but it might increase FPS because we reduced the layers. For perfomance improvements I prefer using mobilenet ssd with tf-coreml.

vvkv commented 6 years ago

@oishi89 I have been looking for a mobilenet ssd implementations in CoreML. Is there something I can work with? I have come across this before, but I am not able to convert my .pb graphs to the coreML models based on the conversion code at the bottom of the repo

oishi89 commented 6 years ago

For conversion you should follow this tutorial https://github.com/tf-coreml/tf-coreml/blob/master/examples/ssd_example.ipynb I have no chance to work with that right now so I don't know exactly whether it's working or not.

vvkv commented 6 years ago

@oishi89 Thank you for that reference. Also would you please be able to explain why we remove the reorg layer? I deployed my model as is and it worked with bounding boxes, although the accuracy did not seem quite right. I want to understand what removing the reorg layer does. Thanks

oishi89 commented 6 years ago

Honestly I don't have deep understanding about that. I was trying remove the unnecessary layers for a lightweight model and better performance. And I had a conversation with AlexeyAB who created the darknet yolo v2. He told me that layer is not required and removing that will not impact to the accuracy.

haemi commented 6 years ago

@vvkv did you manage to get yolo v2 running on iOS?

JGProg commented 6 years ago

here you can find an example with YOLO v2.0

https://github.com/hollance/Forge

I don't test yet.