Skip to content

CoreML conversion/export and usage (non-max suppression) #5157

Description

@pytholic

Hi and thank you for the repository.

I trained my model on custom dataset and now trying to export it as coreml model to use in iOS. However I am facing some difficulties.

  1. When I convert my best.pt model using the provided script, I see a lot of "Adding op" like this:
scikit-learn version 0.20.0 is not supported. Minimum required version: 0.17. Maximum required version: 0.19.2. Disabling scikit-learn conversion API.
TensorFlow version 2.6.0 detected. Last version known to be fully compatible is 2.3.1 .
Keras version 2.6.0 detected. Last version known to be fully compatible of Keras is 2.2.4 .
Adding op 'pow' of type pow
Adding op 'pow_y_0' of type const
Adding op 'mul_1' of type mul
Adding op 'mul_1_x_0' of type const
Adding op 'add' of type add
Adding op 'mul_2' of type mul
Adding op 'mul_2_x_0' of type const
Adding op 'tanh' of type tanh
Adding op 'add_1' of type add
Adding op 'add_1_x_0' of type const
Adding op 'mul' of type mul
Adding op 'mul_x_0' of type const
Adding op 'mul_3' of type mul
Adding op 'pow' of type pow
Adding op 'pow_y_1' of type const
Adding op 'mul_1' of type mul
Adding op 'mul_1_x_1' of type const
.
.
.

Is it normal?

  1. In the converted model, I lose the concatenation part (combing output of three levels) and also NMS. Then I manually implement NMS in swift but I really want it to be integrated in the model itself. Can you help with this? I think I am missing something during conversion step maybe.

  2. When I test my code on iOS, in the end I have 10 boxes with highest scores. However, some of these boxes have exactly same score (even up to 7 decimal points) which I think should not be possible because boxes are different. So then when I apply NMS to keep only the best box, it doesn't really work because the some boxes have same score. Can you give some idea regarding this?

BoundingBox(classIndex: 0, score: 0.91258967, rect: (133.61363220214844, 171.43484497070312, 181.71127319335938, 233.848876953125))
BoundingBox(classIndex: 0, score: 0.91258967, rect: (218.47067260742188, 217.3438262939453, 75.99720764160156, 142.03091430664062))
BoundingBox(classIndex: 0, score: 0.91258967, rect: (260.2138977050781, 256.07952880859375, 56.5107421875, 64.55950164794922))
BoundingBox(classIndex: 0, score: 0.9090115, rect: (259.60150146484375, 224.28857421875, 57.72898483276367, 65.09613800048828))
BoundingBox(classIndex: 0, score: 0.8489735, rect: (188.3462371826172, 214.0371551513672, 73.1979751586914, 148.64938354492188))
BoundingBox(classIndex: 0, score: 0.8489735, rect: (229.7305908203125, 254.57789611816406, 54.429264068603516, 67.56790161132812))
BoundingBox(classIndex: 0, score: 0.81404513, rect: (218.50527954101562, 264.7089538574219, 107.66510009765625, 47.08483123779297))
BoundingBox(classIndex: 0, score: 0.7050861, rect: (290.6436462402344, 100.86282348632812, 106.90132141113281, 38.55246353149414))
BoundingBox(classIndex: 0, score: 0.7050861, rect: (326.1788330078125, 94.99613952636719, 51.8309440612793, 50.285823822021484))
BoundingBox(classIndex: 0, score: 0.7050861, rect: (343.8971252441406, 109.24378967285156, 32.39434051513672, 21.790523529052734))

I have also attached converted mlmodel image with properties. Thank you in advance!!

Screenshot from 2021-10-13 10-37-59

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    StaleStale and schedule for closing soonquestionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions