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

IndexError: index 54 is out of bounds for axis 0 with size 39 #1287

Open
KPLinux opened this issue Jul 22, 2024 · 1 comment
Open

IndexError: index 54 is out of bounds for axis 0 with size 39 #1287

KPLinux opened this issue Jul 22, 2024 · 1 comment

Comments

@KPLinux
Copy link

KPLinux commented Jul 22, 2024

I trained a custom model named decryptzero from the deep-text-recognition-benchmark repository. When attempting to test the model using reader = easyocr.Reader(['en'], gpu = True, recog_network='decryptzero'), it gives me an IndexError.

Originally I thought this was because my character list and the English alphabet character list sizes did not match (it said something like IndexError: index 40 is out of bounds for axis 0 with size 39) so I changed my character list to be exactly the same as the alphabet and the IndexError disappeared. Now when I try to OCR a processed image (using OpenCV), it suddenly says the index is 54 when the list length is 39.

I am using the greedy decoder. When I tested the default settings for the English language on a processed image, it worked fine, but my custom model isn't. But both the English model and my custom model "work" fine (in the sense that there are no errors) on an unprocessed image.

@Siddharth-Latthe-07
Copy link

The issue you're encountering seems related to the mismatch between the character list used during the model training and the character list expected during inference. The custom model's character list might not align with the default settings used by EasyOCR, causing the IndexError.

possible suggestions:-

  1. Verify Character List Consistency
    Ensure the character list used during training matches exactly with what is being used during inference. Any discrepancy can cause indexing issues.

  2. Check Model Configuration
    Make sure that the custom model is correctly configured within EasyOCR. Ensure the model path and associated configurations are properly set up.

  3. Debugging the Character List and Indices
    Print out or log the character list and the indices to ensure they match up. Check both during training and inference to ensure they are consistent.

  4. Update EasyOCR's Model Loading
    Modify EasyOCR's model loading code to load your custom character list properly. This may involve tweaking the EasyOCR source code.

  5. Review the Decoder Configuration
    Since you mentioned using a greedy decoder, ensure it's correctly set up and compatible with your character list.

  6. Align the Preprocessing Steps
    Ensure the preprocessing steps for the image (using OpenCV) are consistent between training and inference.

hope this helps to find you the issue,
Thanks

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

2 participants