pytorch / android-demo-app

PyTorch android examples of usage in applications
1.48k stars 607 forks source link

Unable to model.forward(), get error tensor shape mismatch of tensor(52) against tensor(80) #299

Open MrKhan96 opened 1 year ago

MrKhan96 commented 1 year ago

Hello, I am trying to follow this guide but the model is loading but upon passing image to tis forward function, it gives the error in the following image. I have tried on custom trained yolov5n model with 416x416 dimensions and another custom traiend model with the same specs as the model in the guide. I have looked into other solutions but this error still persists. image

gendy1300 commented 1 year ago

having the same problem on a model but the other one works I don't know why did you figure anything out?

MrKhan96 commented 1 year ago

I have resolved this for myself, the issue for me was that the script from the yolov5 repo was adding something thst was causing the shape mismatch. When I manually called the pytorch conversion functions on the saved pytorch .pt model(not torchscript or ptl), it worked. Hope this is useful for your case