-
-
Notifications
You must be signed in to change notification settings - Fork 15.9k
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
How to CROP detected rectangle to OCR later? #834
Comments
Hello @TeddyPerkins, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Jupyter Notebook If this is a bug report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you. If this is a custom model or data training question, please note Ultralytics does not provide free personal support. As a leader in vision ML and AI, we do offer professional consulting, from simple expert advice up to delivery of fully customized, end-to-end production solutions for our clients, such as:
For more information please visit https://www.ultralytics.com. |
If you pass Lines 108 to 109 in 5f07782
You can read the file to crop to those positions if I understand you correctly. |
Thank you Mr.Chanvichet, I will try this and let you know. |
@TeddyPerkins you can take There is object cropping and saving code in the training dataloader which you can use for reference: Lines 404 to 421 in a8751e5
|
oh thats so cool, thank you for pointing this out too. |
@TeddyPerkins sure, no problem. The dataloader extraction use-case is obviously to take an existing dataset and extract it's contents into a classification-style dataset, with class-labelled folders etc all automatically. If you just want to do this for a few images with detect.py however, you might want to simply look at the second-stage classifier code. This code is latent (not used currently), but it's use cases is to pass YOLOv5 detections through a second stage classifier to reduce FPs. As part of this it naturally crops detected boxes to feed to the classifier: Lines 80 to 83 in 8666bc5
|
Whoa, this makes it so much easier pipelining other tasks. Thank you so much Mr. Glenn! |
@glenn-jocher, but can I crop trapezoid shapes(Keystone effect) to rectangles though? |
@TeddyPerkins last time I checked every shape can be enclosed by a rectangle. |
U can refer to my reply in the above link. |
@TeddyPerkins Prediction box cropping is now available in YOLOv5 via PR #2827! PyTorch Hub models can use
|
For those who want to crop the image from the generated labels txt, I have compiled the code from detect.py to crop, given the labels. Following is the code snippet. Call crop_image with the associated arguments.
|
@palash04 Thanks for sharing the code snippet! This could be a useful reference for anyone looking to crop images from the generated labels. Hope this helps the community! |
❔Question
I am trying to process a complex (form + table) image. I would like it to crop only few content so then they can be OCR-ed.
Is there any arguments I am missing or code itself.
I saw a solution on Stackoverflow but it was old YOLO.
Any help would be appreciated, Thanks.
Additional context
YOLO -> Crop (How to ?) -> OCR
The text was updated successfully, but these errors were encountered: