sanil-55 commited on
Commit
b2415a8
Β·
verified Β·
1 Parent(s): 25ecb30

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -69
app.py DELETED
@@ -1,69 +0,0 @@
1
- import gradio as gr
2
- import json
3
-
4
- from ocr_text import main as ocr_main
5
- from detect_layout import main as layout_main
6
- from reading_order import main as reading_main
7
-
8
- with open("languages.json", "r", encoding='utf-8') as file:
9
- language_map = json.load(file)
10
-
11
- def model1(image_path, languages):
12
- langs = ""
13
- if languages == [] or not languages:
14
- langs = "English"
15
- else:
16
- for lang in languages:
17
- langs += f"{lang},"
18
- langs = langs[:-1]
19
- print(langs)
20
- annotated = ocr_main(image_path, langs=langs)
21
- return annotated
22
-
23
- def model2(image_path):
24
-
25
- annotated = layout_main(image_path)
26
- return annotated
27
-
28
- def model3(image_path):
29
-
30
- annotated = reading_main(image_path)
31
- return annotated
32
-
33
- def process_image(image, model_func):
34
- if image is None:
35
- return None
36
- result = model_func(image)
37
- return result
38
-
39
- with gr.Blocks() as demo:
40
- gr.Markdown("<center><h1>Surya - Image OCR/Layout/Reading Order</h1></center>")
41
-
42
- with gr.Row():
43
- with gr.Column():
44
- with gr.Row():
45
- input_image = gr.Image(type="filepath", label="Input Image", sources="upload")
46
- with gr.Row():
47
- dropdown = gr.Dropdown(label="Select Languages for OCR", choices=list(language_map.keys()), multiselect=True, value=["English"], interactive=True)
48
- with gr.Row():
49
- btn1 = gr.Button("OCR", variant="primary")
50
- btn2 = gr.Button("Layout", variant="primary")
51
- btn3 = gr.Button("Reading Order", variant="primary")
52
- with gr.Row():
53
- clear = gr.ClearButton()
54
-
55
- with gr.Column():
56
- with gr.Tabs():
57
- with gr.TabItem("OCR"):
58
- output_image1 = gr.Image()
59
- with gr.TabItem("Layout"):
60
- output_image2 = gr.Image()
61
- with gr.TabItem("Reading Order"):
62
- output_image3 = gr.Image()
63
-
64
- btn1.click(fn=model1, inputs=[input_image, dropdown], outputs=output_image1)
65
- btn2.click(fn=model2, inputs=[input_image], outputs=output_image2)
66
- btn3.click(fn=model3, inputs=[input_image], outputs=output_image3)
67
- clear.add(components=[input_image, output_image1, output_image2, output_image3])
68
-
69
- demo.launch()