hollance / YOLO-CoreML-MPSNNGraph

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

Adding your own model #18

Closed vvkv closed 6 years ago

vvkv commented 6 years ago

Thank you for this! How can we take this a step further and add our own model (still YOLO but trained with custom classes - https://github.com/AlexeyAB/darknet)

I have managed to convert the trained model to the .mlmodel format.

Thanks

hollance commented 6 years ago

You should be able to just drop your own mlmodel file into Xcode. Is that not working for you?

vvkv commented 6 years ago

Thank you for the quick turnaround. I did try dropping my own model file into xcode, but that gave an error that said "Argument labels '(image:)' do not match any available overloads". I have attached a screenshot to the error in the YOLO.swift file below for further reference. From a little bit of research it seems like it has more to do with the API than the mlmodel, but I'm still unsure as to how to go about resolving it. screen shot 2018-01-18 at 9 04 11 am

hollance commented 6 years ago

Xcode automatically creates this class for you. The label image: was used because that's what the input in my model is called. If your model has an input with a different name, Xcode will use that instead.

vvkv commented 6 years ago

Awesome! Thank you so much. This helped me figure it out

jenniferjiangkells commented 5 years ago

I'm also trying to add my own model (trained to recognise only one class) - does xcode somehow change this automatically or am I supposed to manually change the names?

hollance commented 5 years ago

The names of the classes are part of the model and should automatically work. But the name of the input (and perhaps output) can vary between models and you may have to change this yourself in the code.

jenniferjiangkells commented 5 years ago

Thanks! For the for the coreml converter step - it says that the dimensions 125x13x13 are hard-coded, however the model I'm using only has 1 class and would need to be 30x13x13 - where should I look to change this?

hollance commented 5 years ago

Search the code for the number 125. ;-) There is probably also a numClasses variable that you need to change from 20 to 1.