-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Tflite Export Failure with INT8 Quantization and Dimension Mismatch #12689
Comments
@glenn-jocher I was able to resolve the dimension mismatch error by adding the following lines of code (middle section):
Now I am facing a new error. The error message is: TensorFlow SavedModel: starting TFLite export with onnx2tf 1.17.5... |
Update: I deleted the latest version and used |
Hello! Thanks for the update and for identifying a workaround by reverting to an older version of YOLOv8. We appreciate your feedback as it helps us improve. We'll investigate the issue with the latest version and aim to resolve it in upcoming updates. Your patience and contributions to making YOLOv8 better are greatly valued! 🚀 If you encounter any other issues or have further insights, please feel free to share. |
Search before asking
YOLOv8 Component
Export
Bug
Hi,
I'm encountering an issue when attempting to convert a YOLOv8 segmentation model to
tflite
format with INT8 quantization. The process fails with an error indicating a dimension mismatch during the permutation step. This issue did not occur with the older version of YOLOv8 and has only appeared after upgrading to the latest version.@glenn-jocher I would appreciate it if you could help me to fix this issue.
Thanks
Ultralytics YOLOv8.2.15 🚀 Python-3.10.13 torch-2.1.0 CPU (11th Gen Intel Core(TM) i9-11900KF 3.50GHz)⚠️ tensorflow<=2.13.1 is required, but tensorflow==2.14.0 is currently installed #5161⚠️ No labels found in D:\H\Project\Code\yolov8\Data\calibration.cache. See https://docs.ultralytics.com/datasets/detect for dataset formatting guidance.⚠️ No labels found in D:\H\Project\Code\yolov8\Data\calibration.cache, training may not work correctly. See https://docs.ultralytics.com/datasets/detect for dataset formatting guidance.
YOLOv8n-seg summary (fused): 195 layers, 3258454 parameters, 0 gradients, 12.0 GFLOPs
PyTorch: starting from 'Yolov8_Seg\YOLOv8n-Seg-SGD-1000epochs-batch16-imgsz480-data_23719\weights\best.pt' with input shape (1, 3, 480, 480) BCHW and output shape(s) ((1, 38, 4725), (1, 32, 120, 120)) (6.6 MB)
TensorFlow SavedModel: starting export with tensorflow 2.14.0...
WARNING
ONNX: starting export with onnx 1.14.1 opset 17...
ONNX: simplifying with onnxsim 0.4.35...
ONNX: export success ✅ 1.3s, saved as 'Yolov8_Seg\YOLOv8n-Seg-SGD-1000epochs-batch16-imgsz480-data_23719\weights\best.onnx' (12.6 MB)
TensorFlow SavedModel: collecting INT8 calibration images from 'data=Data/export_data.yaml'
Scanning D:\H\Project\Code\yolov8\Data\calibration... 0 images, 340 backgrounds, 0 corrupt: 100%|██████████| 340/340 [00:00<00:00, 7435.55it/s]
WARNING
New cache created: D:\H\Project\Code\yolov8\Data\calibration.cache
WARNING
TensorFlow SavedModel: export failure ❌ 1.4s: permute(sparse_coo): number of dimensions in the tensor input does not match the length of the desired ordering of dimensions i.e. input.dim() = 4 is not equal to len(dims) = 3
Traceback (most recent call last):
File "C:\Users\Hamed\miniconda3\envs\yolov8\lib\site-packages\IPython\core\interactiveshell.py", line 3526, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
model.export(format="tflite", data = 'Data/export_data.yaml',imgsz=480, int8=True)
File "C:\Users\Hamed\miniconda3\envs\yolov8\lib\site-packages\ultralytics\engine\model.py", line 602, in export
return Exporter(overrides=args, _callbacks=self.callbacks)(model=self.model)
File "C:\Users\Hamed\miniconda3\envs\yolov8\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "C:\Users\Hamed\miniconda3\envs\yolov8\lib\site-packages\ultralytics\engine\exporter.py", line 305, in call
f[5], keras_model = self.export_saved_model()
File "C:\Users\Hamed\miniconda3\envs\yolov8\lib\site-packages\ultralytics\engine\exporter.py", line 142, in outer_func
raise e
File "C:\Users\Hamed\miniconda3\envs\yolov8\lib\site-packages\ultralytics\engine\exporter.py", line 137, in outer_func
f, model = inner_func(*args, **kwargs)
File "C:\Users\Hamed\miniconda3\envs\yolov8\lib\site-packages\ultralytics\engine\exporter.py", line 866, in export_saved_model
im = batch["img"].permute(1, 2, 0)[None] # list to nparray, CHW to BHWC
RuntimeError: permute(sparse_coo): number of dimensions in the tensor input does not match the length of the desired ordering of dimensions i.e. input.dim() = 4 is not equal to len(dims) = 3
Environment
No response
Minimal Reproducible Example
No response
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: