TF + PyTorch installed (same env): RuntimeError: Given input size: (128x1x16). Calculated output size: (128x0x8). Output size is too small" #1884
Replies: 11 comments
-
Hi @sohamyedgaonkar 👋🏼, Thanks for reporting would it be possible to share an example that we can reproduce the issue ? |
Beta Was this translation helpful? Give feedback.
-
yeah sure |
Beta Was this translation helpful? Give feedback.
-
Mh I can't reproduce it 🤔 from doctr.io import DocumentFile
from doctr.models import ocr_predictor
doc = DocumentFile.from_images("/home/felix/Desktop/testi.png")
model = ocr_predictor(pretrained=True)
res = model(doc)
res.show()
json_res = res.export() Tested with TF and PyTorch backend |
Beta Was this translation helpful? Give feedback.
-
Which pytorch version do you use ? |
Beta Was this translation helpful? Give feedback.
-
Name: torch Can you please check on google colab |
Beta Was this translation helpful? Give feedback.
-
On it and yes here I can reproduce the issue ...strange |
Beta Was this translation helpful? Give feedback.
-
For the moment you can use onnxtr (same as doctr but prod optimized and doesn't requires pytorch or tensorflow) https://colab.research.google.com/drive/1Q4dNqywh-q-GILKiIznD6P9gUa4df50r?usp=sharing |
Beta Was this translation helpful? Give feedback.
-
Ok got it It's an dependency issue if both pytorch and tensorflow are installed ..protobuff forces anything strange Uninstalling tensorflow before solves the issue
|
Beta Was this translation helpful? Give feedback.
-
great ! thanks for your timely response . |
Beta Was this translation helpful? Give feedback.
-
Will keep the issue open if someone else has the same issue ... unfortunately I can't do anything from my end because it conflicts from TF dependencies |
Beta Was this translation helpful? Give feedback.
-
Hey, I believe I found a work around without uninstalling tensorflow. I was also getting the "RuntimeError: Given input size: (128x1x16). Calculated output size: (128x0x8). Output size is too small" error for some images that are a regular size (750-1600px width/height) Sometimes I was able to run an image, but the blocks repeatedly came out empty -- I tried 8+ images and pdfs. I have both Pytorch and Tensorflow installed
Solution:
Run this BEFORE initializing the model. This simply disables tensorflow temporarily. Give it a shot, I hope it helps! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug description
Whenever I am trying to run the basic flow the readme page for my own image .
This is what error is hitting up again and again
even when i am trying on local computer and Google collab
RuntimeError Traceback (most recent call last)
in <cell line: 0>()
7 doc = DocumentFile.from_images(r"/content/data-set.png")
8 # Analyze
----> 9 result = model(doc)
10 # Display the result (requires matplotlib & mplcursors to be installed)
11 result.show()
19 frames
/usr/local/lib/python3.11/dist-packages/torch/nn/functional.py in _max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode, return_indices)
828 if stride is None:
829 stride = torch.jit.annotate(List[int], [])
--> 830 return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)
831
832
RuntimeError: Given input size: (128x1x16). Calculated output size: (128x0x8). Output size is too small
Code snippet to reproduce the bug
from doctr.io import DocumentFile
from doctr.models import ocr_predictor
model = ocr_predictor(pretrained=True)
Image
doc = DocumentFile.from_images(r"c:\Users\DELL\Desktop\data-set.png")
Analyze
result = model(doc)
Display the result (requires matplotlib & mplcursors to be installed)
result.show()
Error traceback
in <cell line: 0>()
7 doc = DocumentFile.from_images(r"/content/data-set.png")
8 # Analyze
----> 9 result = model(doc)
10 # Display the result (requires matplotlib & mplcursors to be installed)
11 result.show()
19 frames
/usr/local/lib/python3.11/dist-packages/torch/nn/functional.py in _max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode, return_indices)
828 if stride is None:
829 stride = torch.jit.annotate(List[int], [])
--> 830 return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)
831
832
RuntimeError: Given input size: (128x1x16). Calculated output size: (128x0x8). Output size is too small
Environment
Google collab after running !pip install "python-doctr[tf]"
Deep Learning backend
is_tf_available: True
is_torch_available: True
Beta Was this translation helpful? Give feedback.
All reactions