question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Runtime error during model.predict() call

See original GitHub issue

Hi all, I have trained a detecto model to detect rectangles and squares in image. After training, when I call model.predict(image), the following runtime error occurs. Any guidance to get rid of this. Thanks I am using: python 3.6 torch: 1.5.0+cu101

here is the call traceback

3 image = utils.read_image('/color_matching/sample_photo/img.jpg')
----> 4 predictions = model.predict_top([image])

/usr/local/lib/python3.6/dist-packages/torchvision/models/detection/_utils.py in decode(self, rel_codes, boxes)

183         box_sum += val
184         pred_boxes = self.decode_single(
-->185             rel_codes.reshape(box_sum, -1), concat_boxes)
186 
187         return pred_boxes.reshape(box_sum, -1, 4)

RuntimeError: cannot reshape tensor of 0 elements into shape [0, -1] because the unspecified dimension size -1 can be any value and is ambiguous.

    *:  The image has size(500, 500)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
anirudh-gcommented, Jul 14, 2020

I had the same issue with model.predict(). But once I switched to torch 1.4 and torchvision 0.5.0, it was alright. This seems to be limited to the recent releases of pytorch, atleast for me

0reactions
alankbicommented, Oct 23, 2020

Closing due to inactivity - if anyone else comes across this issue, feel free to re-open this or create a new one

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to solve runtime error while predicting using onnx model?
When i try run the model using sess.run command, i am getting a error as RuntimeError: Input 'data' must not be empty.
Read more >
STATIC PREDICTION OF RUNTIME ERRORS - OpenReview
The goal in the runtime error prediction task is to determine statically ... The model with the resource description recognizes that the input()...
Read more >
how to use python predict on image? | Apple Developer Forums
I've converted model from caffe and trying to run predict like this: e = np.zeros((1,3,224,224)) d = {} d['data'] = e r =...
Read more >
Am getting error trying to predict on a single image CNN pytorch
Traceback (most recent call last): File “pred.py”, line 134, in output = model(data) Runtime Error: Expected 4-dimensional input for ...
Read more >
Fix Attribute Error and Runtime Error in tensorflow and keras
It is easily to encounter package problem for running first machine learning model. When you are playing around with tensorflow and keras, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found