Closed Naofel-eal closed 1 year ago
Summon TRT guru @NatanBagrov
Try with this repo https://github.com/Linaom1214/TensorRT-For-YOLO-Series
ONNX --> TensorRT python export.py -o yolo_nas_m.onnx -e yolonas.trt
For inference use this --> python trt.py -e yolo_nas.trt
Edit utils/util.py , Add this after line 107, you can see the results.
boxes = torch.from_numpy(data[1]).view(1,8400,4)
scores = torch.from_numpy(data[0]).view(1,8400,80)
print(f"boxes: {boxes.shape}")
print(f"outputs: {scores.shape}")
Hi @Naofel-eal , could you share more details about the error messages you're getting?
Hi @NatanBagrov, For example, I tested the repo mentioned by @pranoyr (thank you for your help !) but I got the following error during the inference:
\utils\utils.py", line 109, in inference
num, final_boxes, final_scores, final_cls_inds = data
ValueError: not enough values to unpack (expected 4, got 2)
I also tested this stackoverflow answer but I don't know how to get the bounding box from the output. The result has a length of 2, result[0].shape = (2, 8400) and result[1].shape = (2, 16800) and I don't know what it means. Answer: https://stackoverflow.com/questions/59280745/inference-with-tensorrt-engine-file-on-python/67492525#67492525
Hmmm... that's weird. From what I see here: https://github.com/Deci-AI/super-gradients/blob/master/src/super_gradients/training/models/detection_models/yolo_nas/dfl_heads.py#L225-L228 I would expect 2 tensors, one with a shape of (4, 8400) and the other with a shape of (80, 8400), or something like that. Maybe @BloodAxe or @Louis-Dupont can help
Maybe I made a mistake when exporting to .onnx or .trt, I am a beginner. Is the export script in the first message correct ?
I tested this repo https://github.com/Linaom1214/TensorRT-For-YOLO-Series/blob/main/trt.py. The inference works very well with a yolov8.trt model but not for the yolonas.trt model. I think the conversion for yolonas from .pth to .trt doesn't works well. Is there any offficial way to do that ?
We just added model.export
API which strongly simplifies that flow, it is available in master and will be released in 3.2.0
https://github.com/Deci-AI/super-gradients/blob/master/documentation/source/models_export.md
This will soon be added to the documentation interface
Hello, I have some issues trying to infer an image with YOLO-NAS-S model converted to .engine. Has anyone managed to do this ?
I used this script to export the custom model to .onnx:
And this command to convert the .onnx to .engine:
But all the scripts I tested to infer an image failed. Does anyone have a working python program that infers an image ?