-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How To Add NMS in pytorch model so that it gets converted into TFLITE #16
Comments
@gj-raza This is currently unsupported. We will take a look later. This shouldn't be too difficult I guess. |
@gj-raza Is |
JFYI, I've added the TFlite custom post processing OP in a keras object detection model following this method, but since pytorch has no NMS layer, so its getting tricky here. Also i've noticed, TFLite's NMS v4 and v5, exisits in your code here , can you please explain what is the overall flow of tinynn converter. so that i can contribute this feature myself |
i've tried this but it seems to not work. have a look at below code
it gives following error, TinyNeuralNetwork quick start for beginnerStart preparing the model for quantizationTraceback (most recent call last): |
Hi, The |
It is a long story. Currently, you have to make changes to multiple components to make it work. Let me list things to do here.
Yeah, you are right. However, according to this post, |
@gj-raza I've done the first two tasks. If you are interested, you may take a look at the latter two, which should be fairly easy. |
@peterjc123 Sure, but I have not previously worked with Pytorch/TFL internals or schemas so it might take me some time figuring it all out on my own, so if there is any documentation, links, tutorials etc that you think will be helpful please share, it'll get on it asap |
@gj-raza To implement NMS translation, you may have to do the following things:
class TorchVisionNmsOperator(TorchVisionNmsSchema):
def parse(self, node, attrs, args, graph_converter):
super().parse(node, attrs, args, graph_converter)
self.run(node)
graph_converter.add_operator(tfl.NonMaxSuppressionV4Operator(inputs, outputs))
The tricky parts include:
Plus: It also has the benefit of including the u8 implementation. But the problem is that it accepts different format of boxes |
@zhiqwang To my surprise, |
Yep @peterjc123 , and the name |
FYI @peterjc123 I guess the following figure can explain the secret here Copyright of this figure: ultralytics/yolov5#5825 (comment) . |
Thanks @peterjc123 . So now i'll have to map this operator to a new created pytorch operator in step 6 mentioned above? |
@gj-raza Yes, you'll need to do steps 1-6 as I described. |
Not going to implement it at our side because it is rarely used in our scenarios. However, if you have any questions implementing this feature, you are free to ask the questions. @gj-raza |
First off, thanks for this amazing repo. Im working on a ssd model in pytorch and i want to add post processing (NMS) into the tflite, how can i add it into my model so that it gets translated to tflite's NMS OP. thanks
The text was updated successfully, but these errors were encountered: