Skip to main content

Hi, 

I am also working on same thing deploying the YOLOPv2 model on to Metis M2. I have downloadded the data set from bdd100k and arranged in this manner.
voyager-sdk/
├── data/
│   └── yolopv2_dataset/
│       ├── images/
│       ├── labels/
│       ├── cal.txt
│       ├── val.txt
│       └── data.yaml
├── customers/
│   └── my_yolopv2/
│       └── yolopv2.pt
└── yolopv2-custom.yaml

so when i am trying to deploy the model using yaml I am getting this error

(venv) aravind@aravind-H610M-H-V2:~/Desktop/voyager-sdk$ ./deploy.py customers/my_yolopv2/yolopv2.yaml
INFO    : Using device metis-0:1:0
INFO    : Detected Metis type as pcie
INFO    : Compiling network yolopv2-custom /home/aravind/Desktop/voyager-sdk/customers/my_yolopv2/yolopv2.yaml
INFO    : Compile model: yolopv2-custom
INFO    : Imported DataAdapter ObjDataAdaptor from /home/aravind/Desktop/voyager-sdk/ax_datasets/objdataadapter.py
/home/aravind/.cache/axelera/venvs/93f45ae3/lib/python3.10/site-packages/torch/serialization.py:779: UserWarning: 'torch.load' received a zip file that looks like a TorchScript archive dispatching to 'torch.jit.load' (call 'torch.jit.load' directly to silence this warning)
  warnings.warn("'torch.load' received a zip file that looks like a TorchScript archive"
WARNING ⚠️ The file '/home/aravind/Desktop/voyager-sdk/customers/my_yolopv2/yolopv2_clean.pt' appears to be improperly saved or formatted. For optimal results, use model.save('filename.pt') to correctly save YOLO models.
ERROR   : 'RecursiveScriptModule' object has no attribute 'model'
INFO    : Compiling c-yolopv2-custom took 2.406 seconds
ERROR   : Failed to deploy network

 

Can any one help me with this..

Here is my YAML script for your reference 
 

axelera-model-format: 1.0.0

name: yolopv2-custom
description: "YOLOPv2 pretrained model deployed for lane detection using custom dataset"

pipeline:
- yolopv2-custom:
model_name: yolopv2-custom
template_path: $AXELERA_FRAMEWORK/pipeline-template/yolo-letterbox.yaml
postprocess:
- decodeyolo:
max_nms_boxes: 30000
conf_threshold: 0.25
nms_iou_threshold: 0.45
nms_class_agnostic: false
nms_top_k: 300

models:
yolopv2-custom:
class: AxUltralyticsYOLO
class_path: $AXELERA_FRAMEWORK/ax_models/yolo/ax_ultralytics.py
weight_path: $AXELERA_FRAMEWORK/customers/my_yolopv2/yolopv2_clean.pt
task_category: ObjectDetection
input_tensor_layout: NCHW
input_tensor_shape: p1, 3, 640, 640]
input_color_format: RGB
num_classes: 10
dataset: yolopv2-dataset

datasets:
yolopv2-dataset:
class: ObjDataAdaptor
class_path: $AXELERA_FRAMEWORK/ax_datasets/objdataadapter.py
data_dir_name: yolopv2_dataset
repr_imgs_dir_path: $AXELERA_FRAMEWORK/data/yolopv2_dataset/images
label_type: YOLOv8
labels: data.yaml
cal_data: cal.txt
val_data: val.txt

#model-env:
# dependencies:
# - torch
# - ultralytics

 

Hi ​@Saiteja, welcome to the big show!

It’s awesome that you’re working on a lane detection project too - love this idea. Where will you be deploying the project?

With regards to the error you’re seeing, I notice it says 'torch.load' received a zip file that looks like a TorchScript archive, so the model looks like it’s a TorchScript archive rather than PyTorch. Are you able to re-export it in a format compatible with Voyager SDK?

This might help:

https://github.com/axelera-ai-hub/voyager-sdk/blob/release/v1.2.5/docs/tutorials/custom_model.md

Let me know how it goes!

 

 


Hi ​@Spanner 

Thank you for sharing the link. I am using the documentation in git hub. from the beginning.I following the documentation as it is...

When I am trying to run the deploy.py code 
I am encountering quantisation error like this…

(venv) aravind@aravind-H610M-H-V2:~/Desktop/voyager-sdk$ ./deploy.py customers/my_yolopv2/yolopv2.yaml
INFO : Using device metis-0:1:0
INFO : Detected Metis type as pcie
INFO : Compiling network yolopv2-custom /home/aravind/Desktop/voyager-sdk/customers/my_yolopv2/yolopv2.yaml
INFO : Compile model: yolopv2-custom
INFO : Imported DataAdapter ObjDataAdaptor from /home/aravind/Desktop/voyager-sdk/ax_datasets/objdataadapter.py
INFO : Using representative images from /home/aravind/Desktop/voyager-sdk/data/yolopv2_dataset/images with backend ImageReader.PIL,pipeline input color format ColorFormat.RGB
INFO : Prequantizing c-yolopv2-custom: yolopv2-custom
INFO : Using device metis-0:1:0
INFO : Quantizing network yolopv2-custom /home/aravind/Desktop/voyager-sdk/customers/my_yolopv2/yolopv2.yaml yolopv2-custom
INFO : Compile model: yolopv2-custom
INFO : Imported DataAdapter ObjDataAdaptor from /home/aravind/Desktop/voyager-sdk/ax_datasets/objdataadapter.py
INFO : Using representative images from /home/aravind/Desktop/voyager-sdk/data/yolopv2_dataset/images with backend ImageReader.PIL,pipeline input color format ColorFormat.RGB
WARNING : There are over 10 quantized dir, removing /home/aravind/Desktop/voyager-sdk/build/yolopv2-custom/yolopv2-custom/quantized_10
Calibrating... ✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨ | 100% | 1.80it/s | 200
/home/aravind/.cache/axelera/venvs/93f45ae3/lib/python3.10/site-packages/torch/nn/functional.py:3734: UserWarning: nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.
warnings.warn("nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.")
ERROR : Traceback (most recent call last):
ERROR : File "<frozen compiler.top_level>", line 559, in quantize
ERROR : File "<frozen qtools_tvm_interface.graph_exporter_v2.graph_exporter>", line 259, in export
ERROR : ValueError: Some modules couldn't be simplified: {<class 'qtoolsv2.intermediate_representation.operators.constant.Constant'>}.
ERROR :
ERROR : The above exception was the direct cause of the following exception:
ERROR :
ERROR : Traceback (most recent call last):
ERROR : File "/home/aravind/Desktop/voyager-sdk/axelera/app/compile.py", line 429, in compile
ERROR : the_manifest = top_level.compile(model, compilation_cfg, output_path)
ERROR : File "<frozen compiler.top_level>", line 833, in compile
ERROR : File "<frozen compiler.top_level>", line 561, in quantize
ERROR : axelera.compiler.exceptions.GraphExporterError: Quantized graph simplification failed:
ERROR : Some modules couldn't be simplified: {<class 'qtoolsv2.intermediate_representation.operators.constant.Constant'>}.
ERROR : Quantized graph simplification failed:
ERROR : Some modules couldn't be simplified: {<class 'qtoolsv2.intermediate_representation.operators.constant.Constant'>}.
INFO : Quantizing c-yolopv2-custom: yolopv2-custom took 133.916 seconds
ERROR : Failed to deploy network
ERROR : Failed to prequantize c-yolopv2-custom: yolopv2-custom
INFO : Compiling c-yolopv2-custom took 138.345 seconds
(venv) aravind@aravind-H610M-H-V2:~/Desktop/voyager-sdk$


can you help me with this..
 


Did you try re-exporting the model using the standard PyTorch format ​@Saiteja? It could be that the second issue is because the current TorchScript model includes operators that the quantiser can’t trace or simplify.

I found this, which might help with saving it in the correct format, and then we can see how things are working from there 👍

# If using Ultralytics YOLO
model = YOLO("path/to/model.yaml")
model.save("yolopv2_clean.pt")

 


Reply