Ni3SinghR commited on
Commit
a4c6702
1 Parent(s): bbce30b

Upload gradio_app.py

Browse files
Files changed (1) hide show
  1. gradio_app.py +27 -0
gradio_app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from ocr_project import perform_ocr, process_keyword
3
+
4
+ def process_image(image, language, keyword):
5
+ return process_keyword(image, language, keyword)
6
+
7
+ with gr.Blocks() as interface:
8
+ gr.Markdown("## OCR Image Upload with Keyword Search")
9
+ gr.Markdown("Upload an image, select the language, extract text, and search for keywords within the text.")
10
+
11
+ language_dropdown = gr.Dropdown(choices=["Hindi", "English"], label="Select Language", value="English")
12
+
13
+ image_input = gr.Image(type="pil", label="Upload Image")
14
+
15
+ keyword_input = gr.Textbox(label="Enter keyword to search", placeholder="Type a keyword here")
16
+
17
+ output_box = gr.HTML(label="Extracted Text", elem_id="output")
18
+
19
+ submit_button = gr.Button("Submit")
20
+ clear_button = gr.Button("Clear")
21
+
22
+ submit_button.click(fn=process_image, inputs=[image_input, language_dropdown, keyword_input], outputs=output_box)
23
+
24
+ clear_button.click(fn=lambda: None, inputs=[], outputs=[output_box])
25
+
26
+ if __name__ == "__main__":
27
+ interface.launch(share=True)