Spaces:
Sleeping
Sleeping
Commit
·
b120b83
1
Parent(s):
73d504c
Updated code files
Browse files
app.py
CHANGED
@@ -59,19 +59,25 @@ with gr.Blocks() as main_app:
|
|
59 |
with gr.Row():
|
60 |
with gr.Column():
|
61 |
img_input = gr.Image(type="pil", label="Upload an Image")
|
62 |
-
|
63 |
gr.Markdown("""
|
64 |
### Please use this prompt for text extraction
|
65 |
**What text can you identify in this image? Include everything, even if it's partially obscured or in the background.**
|
66 |
""")
|
67 |
-
|
68 |
extract_button = gr.Button("Read Doc!")
|
|
|
|
|
69 |
search_button = gr.Button("Search!")
|
70 |
|
|
|
71 |
with gr.Column():
|
72 |
extracted_text_op = gr.Textbox(label="Output")
|
73 |
search_text_op = gr.HTML(label="Search Results")
|
|
|
|
|
74 |
|
|
|
75 |
extracted_text_state = gr.State()
|
76 |
extract_button.click(
|
77 |
extraction,
|
@@ -79,10 +85,18 @@ with gr.Blocks() as main_app:
|
|
79 |
outputs=[extracted_text_op, extracted_text_state]
|
80 |
)
|
81 |
|
|
|
82 |
search_button.click(
|
83 |
search_text,
|
84 |
inputs=[extracted_text_state, search_input],
|
85 |
outputs=[search_text_op]
|
86 |
)
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
main_app.launch()
|
|
|
59 |
with gr.Row():
|
60 |
with gr.Column():
|
61 |
img_input = gr.Image(type="pil", label="Upload an Image")
|
62 |
+
|
63 |
gr.Markdown("""
|
64 |
### Please use this prompt for text extraction
|
65 |
**What text can you identify in this image? Include everything, even if it's partially obscured or in the background.**
|
66 |
""")
|
67 |
+
query_input = gr.Textbox(label="Enter query for retrieval", placeholder="Query/Prompt")
|
68 |
extract_button = gr.Button("Read Doc!")
|
69 |
+
|
70 |
+
search_input = gr.Textbox(label="Enter search term", placeholder="Search")
|
71 |
search_button = gr.Button("Search!")
|
72 |
|
73 |
+
|
74 |
with gr.Column():
|
75 |
extracted_text_op = gr.Textbox(label="Output")
|
76 |
search_text_op = gr.HTML(label="Search Results")
|
77 |
+
|
78 |
+
download_button = gr.Button("Download Plain Text")
|
79 |
|
80 |
+
# Retrieval
|
81 |
extracted_text_state = gr.State()
|
82 |
extract_button.click(
|
83 |
extraction,
|
|
|
85 |
outputs=[extracted_text_op, extracted_text_state]
|
86 |
)
|
87 |
|
88 |
+
# Search
|
89 |
search_button.click(
|
90 |
search_text,
|
91 |
inputs=[extracted_text_state, search_input],
|
92 |
outputs=[search_text_op]
|
93 |
)
|
94 |
|
95 |
+
# Download
|
96 |
+
download_button.click(
|
97 |
+
lambda text: gr.File.save_text_to_file(text, "extracted_text.txt"),
|
98 |
+
inputs=[extracted_text_state],
|
99 |
+
outputs=[gr.File(label="Download Extracted Text")]
|
100 |
+
)
|
101 |
+
|
102 |
main_app.launch()
|