marcoslucianops / DeepStream-Yolo

NVIDIA DeepStream SDK 7.0 / 6.4 / 6.3 / 6.2 / 6.1.1 / 6.1 / 6.0.1 / 6.0 / 5.1 implementation for YOLO models
MIT License
1.45k stars 356 forks source link

Failed to load python extension: warn(f"Failed to load image Python extension: {e}") #467

Closed mgabell closed 12 months ago

mgabell commented 1 year ago

This error occurs when trying got export the model.

python3 export_yoloV8.py -w yolov8s.pt --dynamic
**/home/aiadmin/.local/lib/python3.8/site-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: 
  warn(f"Failed to load image Python extension: {e}")**
WARNING ⚠️ 'ultralytics.yolo.v8' is deprecated since '8.0.136' and will be removed in '8.1.0'. Please use 'ultralytics.models.yolo' instead.
WARNING ⚠️ 'ultralytics.yolo.utils' is deprecated since '8.0.136' and will be removed in '8.1.0'. Please use 'ultralytics.utils' instead.
Note this warning may be related to loading older models. You can update your model to current structure with:
    import torch
    ckpt = torch.load("model.pt")  # applies to both official and custom models
    torch.save(ckpt, "updated-model.pt")

Starting: yolov8s.pt
Opening YOLOv8 model

Ultralytics YOLOv8.0.172 🚀 Python-3.8.10 torch-1.13.1 CPU (ARMv8 Processor rev 1 (v8l))
YOLOv8s summary (fused): 168 layers, 11156544 parameters, 0 gradients, 28.6 GFLOPs

Creating labels.txt file

Exporting the model to ONNX
Done: yolov8s.onnx

I have tried torch 1.9.0 and torchvision 0.10.0 and then the error goes away, but then I get error raise ValueError("Unsupported ONNX opset version: " + str(opset_version))

I then go back to 1.13.1 and 0.14.1 on torch and torchvision and the image error is back but the conversion seems to be ok. Any idea what will solve the problem? Some say lower the opset and run with a different version of torch and torchvision but what effect will that have on the output?

mgabell commented 12 months ago

This is solved by upgrading pytorch and torchvision to the latest. When running the training the protobuf must be the latest too, but when doing the ONNX conversion its needed to downgrade to 3.19.1.