You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from PIL import Image
from surya.ocr import run_ocr
from surya.model.detection import segformer
from surya.model.recognition.model import load_model
from surya.model.recognition.processor import load_processor
IMAGE_PATH = "static\images\excerpt_text.png"
image = Image.open(IMAGE_PATH)
langs = ["en"] # Replace with your languages
det_processor, det_model = segformer.load_processor(), segformer.load_model()
rec_model, rec_processor = load_model(), load_processor()
I cannot reproduce this. I ran the exact same code with the latest version, and it worked fine. Can you share the image you're using? Also verify that you're using the latest version of surya.
When I try to run the following code
from PIL import Image
from surya.ocr import run_ocr
from surya.model.detection import segformer
from surya.model.recognition.model import load_model
from surya.model.recognition.processor import load_processor
IMAGE_PATH = "static\images\excerpt_text.png"
image = Image.open(IMAGE_PATH)
langs = ["en"] # Replace with your languages
det_processor, det_model = segformer.load_processor(), segformer.load_model()
rec_model, rec_processor = load_model(), load_processor()
predictions = run_ocr([image], [langs], det_model, det_processor, rec_model, rec_processor)
I am getting error :
IndexError Traceback (most recent call last)
Cell In[11], line 13
10 det_processor, det_model = segformer.load_processor(), segformer.load_model()
11 rec_model, rec_processor = load_model(), load_processor()
---> 13 predictions = run_ocr([image], [langs], det_model, det_processor, rec_model, rec_processor)
File ~\Desktop\GenAI\surya\surya\ocr.py:68, in run_ocr(images, langs, det_model, det_processor, rec_model, rec_processor, batch_size)
66 for idx, (det_pred, image, lang) in enumerate(zip(det_predictions, images, langs)):
67 polygons = [p.polygon for p in det_pred.bboxes]
---> 68 slices = slice_polys_from_image(image, polygons)
69 slice_map.append(len(slices))
70 all_langs.extend([lang] * len(slices))
File ~\Desktop\GenAI\surya\surya\input\processing.py:86, in slice_polys_from_image(image, polys)
84 lines = []
85 for idx, poly in enumerate(polys):
---> 86 lines.append(slice_and_pad_poly(image_array, poly))
87 return lines
File ~\Desktop\GenAI\surya\surya\input\processing.py:104, in slice_and_pad_poly(image_array, coordinates)
101 cv2.fillPoly(mask, [np.int32(coordinates)], 1)
102 mask = np.stack([mask] * 3, axis=-1)
--> 104 cropped_polygon[mask == 0] = settings.RECOGNITION_PAD_VALUE
105 rectangle_image = Image.fromarray(cropped_polygon)
107 return rectangle_image
IndexError: boolean index did not match indexed array along dimension 2; dimension is 4 but corresponding boolean dimension is 3
The text was updated successfully, but these errors were encountered: