Skip to content
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

Convert ONNX model to Other Formats #9

Open
sharoseali opened this issue Jul 28, 2022 · 2 comments
Open

Convert ONNX model to Other Formats #9

sharoseali opened this issue Jul 28, 2022 · 2 comments

Comments

@sharoseali
Copy link

HI, @dnth Thanks for the excellent work. Can I convert the ONNX or PyTorch model to tflite model? I roughly tried but I got the error.
After successful training and conversion, I got .pt and ONNX file. I convert the model using following command:
python3 yolov5-train/export.py --weights best.pt --include tflite --imgsz 320 --data my_data.yaml

Output:

export: data=my_data.yaml, weights=['best.pt'], imgsz=[320], batch_size=1, device=cpu, half=False, inplace=False, train=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=12, verbose=False, workspace=4, nms=False, agnostic_nms=False, topk_per_class=100, topk_all=100, iou_thres=0.45, conf_thres=0.25, remove_grid=False, include=['tflite']
YOLOv5 🚀 dbd4306 torch 1.9.0+cu111 CPU


                 from  n    params  module                                  arguments                     
  0                -1  1      1760  models.common.Conv                      [3, 16, 6, 2, 2]              
  1                -1  1      4672  models.common.Conv                      [16, 32, 3, 2]                
  2                -1  1      4800  models.common.C3                        [32, 32, 1]                   
  3                -1  1     18560  models.common.Conv                      [32, 64, 3, 2]                
  4                -1  2     29184  models.common.C3                        [64, 64, 2]                   
  5                -1  1     73984  models.common.Conv                      [64, 128, 3, 2]               
  6                -1  3    156928  models.common.C3                        [128, 128, 3]                 
  7                -1  1    295424  models.common.Conv                      [128, 256, 3, 2]              
  8                -1  1    296448  models.common.C3                        [256, 256, 1]                 
  9                -1  1    164608  models.common.SPPF                      [256, 256, 5]                 
 10                -1  1     33024  models.common.Conv                      [256, 128, 1, 1]              
 11                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          
 12           [-1, 6]  1         0  models.common.Concat                    [1]                           
 13                -1  1     90880  models.common.C3                        [256, 128, 1, False]          
 14                -1  1      8320  models.common.Conv                      [128, 64, 1, 1]               
 15                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          
 16           [-1, 4]  1         0  models.common.Concat                    [1]                           
 17                -1  1     22912  models.common.C3                        [128, 64, 1, False]           
 18                -1  1     36992  models.common.Conv                      [64, 64, 3, 2]                
 19          [-1, 14]  1         0  models.common.Concat                    [1]                           
 20                -1  1     74496  models.common.C3                        [128, 128, 1, False]          
 21                -1  1    147712  models.common.Conv                      [128, 128, 3, 2]              
 22          [-1, 10]  1         0  models.common.Concat                    [1]                           
 23                -1  1    296448  models.common.C3                        [256, 256, 1, False]          
 24      [17, 20, 23]  1     10824  models.yolo.Detect                      [3, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [64, 128, 256]]
Model summary: 270 layers, 1767976 parameters, 1767976 gradients, 4.2 GFLOPs

2022-07-28 15:16:59 sparseml.optim.manager INFO     Created recipe manager with metadata: {
 "__metadata__": null
}
Created recipe manager with metadata: {
 "__metadata__": null
}

PyTorch: starting from best.pt with output shape (1, 6300, 8) (7.3 MB)
2022-07-28 15:17:00.223833: I tensorflow/core/util/util.cc:169] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.

TensorFlow SavedModel: starting export with tensorflow 2.9.1...

TensorFlow SavedModel: export failure: 'Model' object has no attribute 'nc'

TensorFlow Lite: starting export with tensorflow 2.9.1...

TensorFlow Lite: export failure: 'NoneType' object has no attribute 'call'

Any suggestion and help

@dani3l125
Copy link

Hello @sharoseali , have you figured out how to convent to tflite already?

@sharoseali
Copy link
Author

Hi @dani3l125 , no I gave up and move on, i think conversion codes should also be modified to convert sparsified model. Good luck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants