VikParuchuri / surya

OCR, layout analysis, reading order, line detection in 90+ languages
https://www.datalab.to
GNU General Public License v3.0
9.77k stars 632 forks source link

The detection does not work correctly #49

Open Wangyelan opened 6 months ago

Wangyelan commented 6 months ago

c63e3280c5bf317d3b16c6f2c45f30f Why the result of the detection is same to the image of the original image even I choose the image from the project?

Wangyelan commented 6 months ago

And the ocr can't work,what's wrong with them?

VikParuchuri commented 6 months ago

I can't reproduce this issue (detection and OCR work fine for me on this same image). Do you see any log error messages?

Wangyelan commented 6 months ago

No error,but some warning. D:\Anaconda\Lib\site-packages\surya\detection.py:92: RuntimeWarning: invalid value encountered in cast heat_img = Image.fromarray((heatmap 255).astype(np.uint8)) D:\Anaconda\Lib\site-packages\surya\detection.py:93: RuntimeWarning: invalid value encountered in cast aff_img = Image.fromarray((affinity_map 255).astype(np.uint8)) D:\Anaconda\Lib\site-packages\surya\postprocessing\affinity.py:28: RuntimeWarning: invalid value encountered in cast scaled_sobel = np.uint8(255 * abs_sobelx / np.max(abs_sobelx))

SachukS commented 2 months ago

I get the same warning. Have anyone solved this problem?

No error,but some warning. D:\Anaconda\Lib\site-packages\surya\detection.py:92: RuntimeWarning: invalid value encountered in cast heat_img = Image.fromarray((heatmap 255).astype(np.uint8)) D:\Anaconda\Lib\site-packages\surya\detection.py:93: RuntimeWarning: invalid value encountered in cast aff_img = Image.fromarray((affinity_map 255).astype(np.uint8)) D:\Anaconda\Lib\site-packages\surya\postprocessing\affinity.py:28: RuntimeWarning: invalid value encountered in cast scaled_sobel = np.uint8(255 * abs_sobelx / np.max(abs_sobelx))

jamison-golson commented 3 weeks ago

Was anybody able to solve this problem @Wangyelan @SachukS @VikParuchuri . I am encountering the same warnings. When I run the provided example code:

from PIL import Image
from surya.ocr import run_ocr
from surya.model.detection.model import load_model as load_det_model, load_processor as load_det_processor
from surya.model.recognition.model import load_model as load_rec_model
from surya.model.recognition.processor import load_processor as load_rec_processor

image = Image.open(IMAGE)
langs = ["en"] # Replace with your languages - optional but recommended
det_processor, det_model = load_det_processor(), load_det_model()
rec_model, rec_processor = load_rec_model(), load_rec_processor()

predictions = run_ocr([image], [langs], det_model, det_processor, rec_model, rec_processor)

I receive the same warnings as OP but the code runs perfectly fine. No errors occur.

The response I receive is empty though: [OCRResult(text_lines=[], languages=['en'], image_bbox=[0.0, 0.0, 2048.0, 1627.0])]

Any help would be great because I would really enjoy spinning up the GUI on my local machine and giving it a try. Thanks in advanced!