-
Notifications
You must be signed in to change notification settings - Fork 209
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
Export Detic to ONNX with custom vocabulary #113
Comments
And to infer from the ONNX model, I am using @HtwoOtwo's script The slightly modified inference script looks like this ->
|
Hello @gigasurgeon, thanks for the tutorial. |
Here's the ONNX file -> https://drive.google.com/file/d/1hYz19lZk4ugLrUGO0HIP9M2RbXs5A4O-/view?usp=sharing |
I wanted to share the method to export detic model to ONNX format with custom vocabulary.
Step 1) First of all, comment out this line
box_features = _ScaleGradient.apply(box_features, 1.0 / self.num_cascade_stages)
in custom_rcnn.pyStep 2) Also, according to this comment #107 (comment) , you have to comment the nms_and_topk line in centernet, while exporting the model
boxlists = self.nms_and_topK(boxlists, nms=not self.not_nms)
Step 3) Now on to the main part. You need to modify this file ->
Detic/detectron2/tools/deploy/export_model.py
This is the final script I had
At line 253
custom_classes = ['scoop', ....
is where I have added my custom labels.Step 4) Now you need to execute this script with the command
python3 detectron2/tools/deploy/export_model_lvis_vocabulary.py --config-file configs/Detic_LCOCOI21k_CLIP_SwinB_896b32_4x_ft4x_max-size.yaml --sample-image desk.jpg --output ./output --export-method tracing --format onnx MODEL.WEIGHTS models/Detic_LCOCOI21k_CLIP_SwinB_896b32_4x_ft4x_max-size.pth MODEL.DEVICE cuda
from detic's root folder. This will save the ONNX model at
output/model.onnx
.The text was updated successfully, but these errors were encountered: