New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime error during model.predict() call #33
Comments
Just to clarify, is your image 500x500 or 500x500x3? If it's the former, then that might be the issue, as Detecto expects images to be in RGB format. If it's the latter, perhaps try calling |
yes, sorry the size is 500x500x3 and using predict_top(image) still produce same error. Secondly, model.predict(image) also produce same error. |
Hm... I'm not too sure, as it seems to be some issue arising from torchvision code. Could you share what version of torchvision you're using? |
torchvision version: 0.6.0+cu101 |
I would recommend trying to use a default Model and/or another image to see if the same error occurs, which will allow you to isolate where the error is happening. |
I'm getting the same error - it also persists after I've tried all of the above things. Should be noted that I'm using Google Colab here, and would assume OP is also, judging by their use of Python 3.6 |
Are you able to share a full stack trace and/or the code your running? This will help me better isolate where the error is occurring. |
Yep, for sure! One thing to note is that while the Detecto main module shows its path here as /content/drive/My Drive/dt2/jgdt/core.py (not what you'd expect if I was using a pip installation of Detecto), this is only because I'm working with a very slightly modified fork of Detecto that enables Tensorflow-style auto-saving of the model. I get this error with the standard Detecto installation as well, so that's definitely not the problem. RuntimeError Traceback (most recent call last) 8 frames /content/drive/My Drive/dt2/jgdt/core.py in predict(self, images) /content/drive/My Drive/dt2/jgdt/core.py in _get_raw_predictions(self, images) /usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in call(self, *input, **kwargs) /usr/local/lib/python3.6/dist-packages/torchvision/models/detection/generalized_rcnn.py in forward(self, images, targets) /usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in call(self, *input, **kwargs) /usr/local/lib/python3.6/dist-packages/torchvision/models/detection/roi_heads.py in forward(self, features, proposals, image_shapes, targets) /usr/local/lib/python3.6/dist-packages/torchvision/models/detection/roi_heads.py in postprocess_detections(self, class_logits, box_regression, proposals, image_shapes) /usr/local/lib/python3.6/dist-packages/torchvision/models/detection/_utils.py in decode(self, rel_codes, boxes) RuntimeError: cannot reshape tensor of 0 elements into shape [0, -1] because the unspecified dimension size -1 can be any value and is ambiguous |
Here are some suggestions:
If none of those work, I'd also recommend posting an issue in the PyTorch or torchvision repos; they may be able to help you more than I can as it seems the error is arising from within their package. |
None of these solutions work, unfortunately :( I just shared the model/dataset that's producing this error via Drive. Thanks for your help! |
Hi! I am getting the same error as well. Trained my model on kaggle with the latest environment preference. Any suggestions? |
Just want to check that none of the above solutions work? If so, could you take a look at #36 and see if that helps at all? |
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 |
Closing due to inactivity - if anyone else comes across this issue, feel free to re-open this or create a new one |
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
/usr/local/lib/python3.6/dist-packages/torchvision/models/detection/_utils.py in decode(self, rel_codes, boxes)
The text was updated successfully, but these errors were encountered: