Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
@@ -12,6 +12,8 @@ ocr_ru = PaddleOCR(use_angle_cls=True, lang='cyrillic')
|
|
12 |
ocr_arabic = PaddleOCR(use_angle_cls=True, lang='arabic')
|
13 |
ocr_ar = PaddleOCR(use_angle_cls=True, lang='ar')
|
14 |
ocr_korean = PaddleOCR(user_angle_cls=True, lang="korean")
|
|
|
|
|
15 |
#ocr_ch = PaddleOCR(det_model_dir="models/det/ch/ch_PP-OCRv4_det_infer", rec_model_dir="models/rec/ch/ch_PP-OCRv4_rec_infer", cls_model_dir="models/cls/ch_ppocr_mobile_v2.0_cls_infer", rec_char_dict_path="models/dict/ppocr_keys_v1.txt", lang="ch")
|
16 |
|
17 |
|
@@ -23,8 +25,10 @@ def perform_ocr(img, lang):
|
|
23 |
ocr = ocr_ch
|
24 |
elif lang == "Russian" or lang == "Ukrainian":
|
25 |
ocr = ocr_ru
|
26 |
-
elif lang == "Arabic"
|
27 |
ocr = ocr_arabic
|
|
|
|
|
28 |
elif lang == "Only Arabic Lang":
|
29 |
ocr = ocr_ar
|
30 |
elif lang == "Korean":
|
@@ -39,7 +43,7 @@ def perform_ocr(img, lang):
|
|
39 |
scores = [line[1][1] for line in result]
|
40 |
# im_show = draw_ocr(image, boxes, txts, scores, font_path='fonts/simfang.ttf')
|
41 |
|
42 |
-
return [img, result]
|
43 |
|
44 |
demo = gr.Blocks()
|
45 |
|
@@ -52,8 +56,9 @@ with demo:
|
|
52 |
input_button = gr.Button("Run!")
|
53 |
with gr.Column():
|
54 |
output_image = gr.Image()
|
|
|
55 |
output_text = gr.Textbox(label="Results")
|
56 |
|
57 |
-
input_button.click(fn=perform_ocr, inputs=[input_image, input_radio], outputs=[output_image, output_text])
|
58 |
|
59 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
12 |
ocr_arabic = PaddleOCR(use_angle_cls=True, lang='arabic')
|
13 |
ocr_ar = PaddleOCR(use_angle_cls=True, lang='ar')
|
14 |
ocr_korean = PaddleOCR(user_angle_cls=True, lang="korean")
|
15 |
+
ocr_fa = PaddleOCR(user_angle_cls=True, lang="fa")
|
16 |
+
|
17 |
#ocr_ch = PaddleOCR(det_model_dir="models/det/ch/ch_PP-OCRv4_det_infer", rec_model_dir="models/rec/ch/ch_PP-OCRv4_rec_infer", cls_model_dir="models/cls/ch_ppocr_mobile_v2.0_cls_infer", rec_char_dict_path="models/dict/ppocr_keys_v1.txt", lang="ch")
|
18 |
|
19 |
|
|
|
25 |
ocr = ocr_ch
|
26 |
elif lang == "Russian" or lang == "Ukrainian":
|
27 |
ocr = ocr_ru
|
28 |
+
elif lang == "Arabic":
|
29 |
ocr = ocr_arabic
|
30 |
+
elif lang == "Persian":
|
31 |
+
ocr = ocr_fa
|
32 |
elif lang == "Only Arabic Lang":
|
33 |
ocr = ocr_ar
|
34 |
elif lang == "Korean":
|
|
|
43 |
scores = [line[1][1] for line in result]
|
44 |
# im_show = draw_ocr(image, boxes, txts, scores, font_path='fonts/simfang.ttf')
|
45 |
|
46 |
+
return [img, txts, result]
|
47 |
|
48 |
demo = gr.Blocks()
|
49 |
|
|
|
56 |
input_button = gr.Button("Run!")
|
57 |
with gr.Column():
|
58 |
output_image = gr.Image()
|
59 |
+
output_texts = gr.Textbox(label="Texts")
|
60 |
output_text = gr.Textbox(label="Results")
|
61 |
|
62 |
+
input_button.click(fn=perform_ocr, inputs=[input_image, input_radio], outputs=[output_image, output_texts, output_text])
|
63 |
|
64 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|