Ankur Goyal commited on
Commit ·
177edb5
1
Parent(s): 2359223
Support enter key submit
Browse files147 unmodified lines14814915015115215315415515615718 unmodified lines1761771781791801811821831841851861871881891901912 unmodified lines194195196197198199200201202203147 unmodified linesgr.Markdown("## 2. Ask a question")with gr.Row(equal_height=True):# NOTE: When https://github.com/gradio-app/gradio/issues/2103 is resolved,# we can support enter-key submitquestion = gr.Textbox(label="Question", placeholder="e.g. What is the invoice number?")model = gr.Radio(choices=list(CHECKPOINTS.keys()),18 unmodified linesupload.change(fn=process_upload, inputs=[upload], outputs=[document, image, output])url.change(fn=process_path, inputs=[url], outputs=[document, image, output])submit_button.click(process_question,inputs=[question, document, model],outputs=[image, output],)# This is handy but commented out for now because we can't "auto submit" questions either# model.change(# process_question, inputs=[question, document, model], outputs=[image, output]# )example_image.change(fn=load_example_document,2 unmodified lines)gr.Markdown("### More Info")gr.Markdown("DocQuery uses LayoutLMv1 fine-tuned on DocVQA, a document visual question"" answering dataset, as well as SQuAD, which boosts its English-language comprehension."" To use it, simply upload an image or PDF, type a question, and click 'submit', or "" click one of the examples to load them.")gr.Markdown("[Github Repo](https://github.com/impira/docquery)")if __name__ == "__main__":147 unmodified lines14814915015115215315415515615715818 unmodified lines1771781791801811821831841851861871881891901911921931941951961972 unmodified lines200201202203204205206207208209210211147 unmodified linesgr.Markdown("## 2. Ask a question")with gr.Row(equal_height=True):question = gr.Textbox(label="Question",placeholder="e.g. What is the invoice number?",lines=1,max_lines=1,)model = gr.Radio(choices=list(CHECKPOINTS.keys()),18 unmodified linesupload.change(fn=process_upload, inputs=[upload], outputs=[document, image, output])url.change(fn=process_path, inputs=[url], outputs=[document, image, output])question.submit(fn=process_question,inputs=[question, document, model],outputs=[image, output],)submit_button.click(process_question,inputs=[question, document, model],outputs=[image, output],)model.change(process_question, inputs=[question, document, model], outputs=[image, output])example_image.change(fn=load_example_document,2 unmodified lines)gr.Markdown("### More Info")gr.Markdown("DocQuery uses LayoutLMv1 fine-tuned on DocVQA, a document visual question"" answering dataset, as well as SQuAD, which boosts its English-language comprehension."" To use it, simply upload an image or PDF, type a question, and click 'submit', or "" click one of the examples to load them.")gr.Markdown("[Github Repo](https://github.com/impira/docquery)")if __name__ == "__main__":
app.py+19-11