Skip to content
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

TypeError when using batch_layout_detection for multiple images #272

Open
ChernXiangyu opened this issue Dec 25, 2024 · 0 comments
Open

Comments

@ChernXiangyu
Copy link

Screenshot 2024-12-25 at 23 39 59

Hi guys, I met this problem when trying to perform layout analysis in batches with the sample code in README. I guess this may because img_counts has become list of list when using multiple images as input.

I am running this code in Jupyter notebook in vscode, using M4Pro MacBook, macOS Squoia 15.2. Python 3.11.

Thanks in advance!

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[17], line 16
     14 # layout_predictions is a list of dicts, one per image
     15 line_predictions = batch_text_detection(imgs[:2], det_model, det_processor)
---> 16 layout_predictions = batch_layout_detection(imgs[:2], model, processor, line_predictions)
     18 layout_predictions

File /opt/miniconda3/envs/fin-rag/lib/python3.11/site-packages/surya/layout.py:80, in batch_layout_detection(images, model, processor, batch_size, top_k)
     77 end_idx = 1
     78 while end_idx < len(img_counts):
     79     if any([
---> 80         sum(img_counts[start_idx:end_idx]) >= batch_size,
     81         sum(img_counts[start_idx:end_idx + 1]) > batch_size,
     82     ]):
     83         batches.append((start_idx, end_idx))
     84         start_idx = end_idx

TypeError: '>=' not supported between instances of 'int' and 'list'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant