ryouchinsa / Rectlabel-support

RectLabel is an offline image annotation tool for object detection and segmentation.
https://rectlabel.com
504 stars 73 forks source link

[CoreML] Custom Yolo v5 7.0 model returns error when trying to annotate #213

Closed Denizzje closed 1 year ago

Denizzje commented 1 year ago

Hi,

I have successfully used a standard pretrained yolov5 7.0 model directly from the authors themselves. Both with bounding boxes and instance segmentation. I took the yolov5s and yolov5s-seg from the repo, and converted it to CoreML via the Yolov5 provided export.py

Unfortunally, for now my custom models which I will need to use does not work. It can load, but when trying to auto annotate an image, I get the following error:

rectlabelcoremlerror

Here is the text: encountered an unexpected condition: *** -[__NSSingleObjectArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]

I cant make any sense of the error. For now I can just give the following details:

Bounding box model, 1 class. Exported with yolov5 export.py --include coreml Model trained and exported on the same yolov5 commit. Model exported on coremltools on Fedora 37 The laptop I use for RectLabel has MacOS 12. 2015 macbook pro core i5

Any pointers on how to solve this or provide more relevant information will be greatly appreciated.

ryouchinsa commented 1 year ago

Thanks for writing the issue. Please rename the Core ML model to yolov5.mlmodel.

RectLabel recognizes the model type through the file name and the short description. Such as YOLOv3, yolov5m, yolov5m-seg, yolov5m-cls, yolov8n, yolov8n-seg, yolov8n-cls, DeepLab, PoseNet, and FCRN-Depth. https://rectlabel.com/help#load_coreml

Denizzje commented 1 year ago

Thank you, that was not clear to me from the documentation. I will try out next week when I have access to the macbook again.

To be clear, I both have yolov5s and yolov5m "size" models. They are different kind of models with a different purpose. The "m" model is a 25 class model. If I want to use that model, I still have to name it yolov5.mlmodel ?

Good to see you support yolov8 already by the way!

ryouchinsa commented 1 year ago

Improved Core ML menus so that RectLabel can load and run YOLOv5/v8 models when their file names do not include yolov5/v8 keywords such as best.mlmodel and last.mlmodel.

The new update version 2023.02.12 was released. Please let us know your opinion.

In the previous version, the keyword "yolov5" was necessary in the file name to run the model as YOLOv5 model. The number of classes can be calculated based on the output layer shape. The number of classes = The output shape[2] - 5 Read this comment. https://github.com/ultralytics/yolov5/issues/9485#issuecomment-1250758705

Denizzje commented 1 year ago

Hi @ryouchinsa ,

Thank you for your quick work. I did not even try with renaming as you already put the update in when I got access to the Macbook again.

I could succesfully load in a custom YoloV5 bounding box model, and a YoloV8 segmentation model. Surprised how fast it worked on a 2015 i5 Macbook. You have done a true great work there. We will get a M2 Mac mini now for labeling work with Rectlabel.