Can not use yolov5 batch inference

When I use command like below

python --source ./data/images/ --image-size 320

I can get all right results.

But when I use torch.hub.load method

model = torch.hub.load('ultralytics/yolov5', 'yolov5s') 
list_img = glob("./yolov5/data/images/*.jpg")
results = model(list_img, 320)

Only first image can be predicted.
Even I changed the data source, I faced same situation.

Any suggestions?
Thank you.


This seems a customer app issue.
Have you checked with the author if the code support batch inference?


Yes , I can use same function on my laptop with 1080ti.


Could you check if the package between Nano and desktop is identical or not first?

More, may I know how you install the PyTorch?
Do you use our prebuilt shared in the below topic?


I use the torch.whl file you provided and also follow the instrction of installation.
If “package” you mentioned is pytorch, I have already tried version from 1.7 ~1.10 on Jetson Nano.
Or if “package” you mentioned is yolov5, I use same latest version.
(Btw, it is torch 1.7.0 on my desktop.)
Could you try on your board for reproducing this situation?


Just want to confirm first.

Do you get the expected output on a desktop environment with PyTorch?
If yes, which version do you use for desktop?


It seems like the outputs is correct.
And as you can see, the pytorch version is 1.7.0.

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.


The screenshot you shared above can detect two images correctly.
Do you run it on Nano?


I can not reproduce same results on nano

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.