Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
@@ -21,16 +21,19 @@ language_dict = {name: code for name, code in languages.items()}
|
|
21 |
language_options = list(language_dict.keys())
|
22 |
|
23 |
def ocr_function(img, lang_name):
|
|
|
24 |
# Get the language code from the dictionary
|
25 |
lang_code = language_dict[lang_name]
|
|
|
26 |
predictions = run_ocr([img], [lang_code], det_model, det_processor, rec_model, rec_processor)
|
27 |
-
|
28 |
if predictions:
|
29 |
img_with_text = draw_polys_on_image(predictions[0]["polys"], img)
|
30 |
return img_with_text, predictions[0]["text"]
|
31 |
else:
|
32 |
return img, "No text detected"
|
33 |
|
|
|
34 |
def text_line_detection_function(img):
|
35 |
preds = batch_detection([img], det_model, det_processor)[0]
|
36 |
img_with_lines = draw_polys_on_image(preds["polygons"], img)
|
|
|
21 |
language_options = list(language_dict.keys())
|
22 |
|
23 |
def ocr_function(img, lang_name):
|
24 |
+
print(f"OCR Function Called with lang_name: {lang_name}") # Debug print
|
25 |
# Get the language code from the dictionary
|
26 |
lang_code = language_dict[lang_name]
|
27 |
+
print(f"Language Code: {lang_code}") # Debug print
|
28 |
predictions = run_ocr([img], [lang_code], det_model, det_processor, rec_model, rec_processor)
|
29 |
+
print(f"Predictions: {predictions}") # Debug print
|
30 |
if predictions:
|
31 |
img_with_text = draw_polys_on_image(predictions[0]["polys"], img)
|
32 |
return img_with_text, predictions[0]["text"]
|
33 |
else:
|
34 |
return img, "No text detected"
|
35 |
|
36 |
+
|
37 |
def text_line_detection_function(img):
|
38 |
preds = batch_detection([img], det_model, det_processor)[0]
|
39 |
img_with_lines = draw_polys_on_image(preds["polygons"], img)
|