Spaces:
Build error
Build error
Ankur Goyal
commited on
Commit
•
177edb5
1
Parent(s):
2359223
Support enter key submit
Browse files
app.py
CHANGED
@@ -148,10 +148,11 @@ with gr.Blocks() as demo:
|
|
148 |
gr.Markdown("## 2. Ask a question")
|
149 |
|
150 |
with gr.Row(equal_height=True):
|
151 |
-
# NOTE: When https://github.com/gradio-app/gradio/issues/2103 is resolved,
|
152 |
-
# we can support enter-key submit
|
153 |
question = gr.Textbox(
|
154 |
-
label="Question",
|
|
|
|
|
|
|
155 |
)
|
156 |
model = gr.Radio(
|
157 |
choices=list(CHECKPOINTS.keys()),
|
@@ -176,16 +177,21 @@ with gr.Blocks() as demo:
|
|
176 |
upload.change(fn=process_upload, inputs=[upload], outputs=[document, image, output])
|
177 |
url.change(fn=process_path, inputs=[url], outputs=[document, image, output])
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
submit_button.click(
|
180 |
process_question,
|
181 |
inputs=[question, document, model],
|
182 |
outputs=[image, output],
|
183 |
)
|
184 |
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
# )
|
189 |
|
190 |
example_image.change(
|
191 |
fn=load_example_document,
|
@@ -194,10 +200,12 @@ with gr.Blocks() as demo:
|
|
194 |
)
|
195 |
|
196 |
gr.Markdown("### More Info")
|
197 |
-
gr.Markdown(
|
198 |
-
|
199 |
-
|
200 |
-
|
|
|
|
|
201 |
gr.Markdown("[Github Repo](https://github.com/impira/docquery)")
|
202 |
|
203 |
if __name__ == "__main__":
|
|
|
148 |
gr.Markdown("## 2. Ask a question")
|
149 |
|
150 |
with gr.Row(equal_height=True):
|
|
|
|
|
151 |
question = gr.Textbox(
|
152 |
+
label="Question",
|
153 |
+
placeholder="e.g. What is the invoice number?",
|
154 |
+
lines=1,
|
155 |
+
max_lines=1,
|
156 |
)
|
157 |
model = gr.Radio(
|
158 |
choices=list(CHECKPOINTS.keys()),
|
|
|
177 |
upload.change(fn=process_upload, inputs=[upload], outputs=[document, image, output])
|
178 |
url.change(fn=process_path, inputs=[url], outputs=[document, image, output])
|
179 |
|
180 |
+
question.submit(
|
181 |
+
fn=process_question,
|
182 |
+
inputs=[question, document, model],
|
183 |
+
outputs=[image, output],
|
184 |
+
)
|
185 |
+
|
186 |
submit_button.click(
|
187 |
process_question,
|
188 |
inputs=[question, document, model],
|
189 |
outputs=[image, output],
|
190 |
)
|
191 |
|
192 |
+
model.change(
|
193 |
+
process_question, inputs=[question, document, model], outputs=[image, output]
|
194 |
+
)
|
|
|
195 |
|
196 |
example_image.change(
|
197 |
fn=load_example_document,
|
|
|
200 |
)
|
201 |
|
202 |
gr.Markdown("### More Info")
|
203 |
+
gr.Markdown(
|
204 |
+
"DocQuery uses LayoutLMv1 fine-tuned on DocVQA, a document visual question"
|
205 |
+
" answering dataset, as well as SQuAD, which boosts its English-language comprehension."
|
206 |
+
" To use it, simply upload an image or PDF, type a question, and click 'submit', or "
|
207 |
+
" click one of the examples to load them."
|
208 |
+
)
|
209 |
gr.Markdown("[Github Repo](https://github.com/impira/docquery)")
|
210 |
|
211 |
if __name__ == "__main__":
|