Skip to content

Conversation

@ShivaanshGusain
Copy link

Summary of Changes

This PR addresses two compatibility issues encountered when setting up the environment with recent library versions (specifically PaddleOCR v2.9.1).

  1. Fix PaddleOCR Initialization
    Newer versions of paddleocr have deprecated/removed arguments like max_batch_size, use_gpu, and use_dilation from the constructor. Keeping them causes a ValueError crash on startup.
    Change: Updated PaddleOCR() initialization to rely on default argument parsing, which correctly auto-detects GPU support.

  2. Robust Box Sorting
    Occasionally, filtered_boxes contains mixed types (dictionaries and raw lists) depending on the detection results. This causes the sorted() function (line ~435) to crash with an AttributeError because raw lists do not have keys.
    Change: Added a safety check loop (safe_boxes) to ensure all elements in filtered_boxes are standardized dictionaries before sorting.

Testing

  • Verified environment setup on Windows with Python 3.10 and PaddleOCR 2.9.1.
  • Validated that the model loads and performs inference without crashing.

@ShivaanshGusain
Copy link
Author

@microsoft-github-policy-service agree

@ShivaanshGusain
Copy link
Author

Hi @ataymano, this is the fix for setting up the environment with the latest version of paddleocr (v2.9.1) -

Fixed PaddleOCR Initialization: Newer versions of paddleocr have deprecated or removed the max_batch_size, use_gpu, and use_dilation arguments. Passing them was causing a ValueError on startup. I’ve updated the initialization to rely on the default argument parsing, which correctly handles GPU detection automatically.

I noticed that filtered_boxes occasionally contained mixed types (dictionaries and raw lists) depending on the detection results, which caused the sorted() function to crash with an AttributeError. I added a safety check to standardize all elements to dictionaries before sorting.

I verified these changes on Windows with Python 3.11 and PaddleOCR 2.9.1. The model now loads correctly and performs inference without crashing.

test_screenshot_debug test_screenshot

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

Successfully merging this pull request may close these issues.

1 participant