init
Browse files
app.py
CHANGED
@@ -38,7 +38,7 @@ def upload_to_hub(file_upload, camera_upload, agree):
|
|
38 |
with tempfile.TemporaryDirectory() as path:
|
39 |
for file_path in convert_from_path(file_upload, output_folder=path, paths_only=True, fmt='png')[:10]:
|
40 |
_upload_hub(file_path)
|
41 |
-
|
42 |
_upload_hub(camera_upload)
|
43 |
|
44 |
return gr.update(visible=False), gr.Markdown("""<div style="text-align: center;"><h3>Upload was successful! You can upload another document.</h3></div>"""), gr.update(value=None), gr.update(value=None)
|
@@ -84,6 +84,7 @@ with gr.Blocks(fill_height=True) as demo:
|
|
84 |
camera_upload = gr.Image(label="Upload Image [JPG | PNG] via camera", type="filepath", sources=["webcam"], mirror_webcam=False)
|
85 |
gr.Markdown("Upload a document via file upload.")
|
86 |
file_upload = gr.File(label="Upload File [JPG | PNG | PDF]", file_types=["pdf", "jpg", "png"], type="filepath")
|
|
|
87 |
|
88 |
def toggle_agreement_visibility():
|
89 |
return gr.update(visible=False), gr.update(visible=False), True, gr.update(visible=True)
|
@@ -91,10 +92,7 @@ with gr.Blocks(fill_height=True) as demo:
|
|
91 |
# Clicking the "I Agree" button hides the agreement and shows the upload section
|
92 |
agree_button.click(fn=toggle_agreement_visibility, inputs=None, outputs=[agreement_markdown, agree_button, agree_state, upload_section])
|
93 |
|
94 |
-
|
95 |
-
file_upload.change(fn=upload_to_hub, inputs=[file_upload, camera_upload, agree_state], outputs=[agree_button, success_message, file_upload, camera_upload])
|
96 |
-
camera_upload.change(fn=upload_to_hub, inputs=[file_upload, camera_upload, agree_state], outputs=[agree_button, success_message, file_upload, camera_upload])
|
97 |
-
|
98 |
|
99 |
if __name__ == "__main__":
|
100 |
demo.launch()
|
|
|
38 |
with tempfile.TemporaryDirectory() as path:
|
39 |
for file_path in convert_from_path(file_upload, output_folder=path, paths_only=True, fmt='png')[:10]:
|
40 |
_upload_hub(file_path)
|
41 |
+
if camera_upload:
|
42 |
_upload_hub(camera_upload)
|
43 |
|
44 |
return gr.update(visible=False), gr.Markdown("""<div style="text-align: center;"><h3>Upload was successful! You can upload another document.</h3></div>"""), gr.update(value=None), gr.update(value=None)
|
|
|
84 |
camera_upload = gr.Image(label="Upload Image [JPG | PNG] via camera", type="filepath", sources=["webcam"], mirror_webcam=False)
|
85 |
gr.Markdown("Upload a document via file upload.")
|
86 |
file_upload = gr.File(label="Upload File [JPG | PNG | PDF]", file_types=["pdf", "jpg", "png"], type="filepath")
|
87 |
+
submit_button = gr.Button("Submit")
|
88 |
|
89 |
def toggle_agreement_visibility():
|
90 |
return gr.update(visible=False), gr.update(visible=False), True, gr.update(visible=True)
|
|
|
92 |
# Clicking the "I Agree" button hides the agreement and shows the upload section
|
93 |
agree_button.click(fn=toggle_agreement_visibility, inputs=None, outputs=[agreement_markdown, agree_button, agree_state, upload_section])
|
94 |
|
95 |
+
submit_button.click(fn=upload_to_hub, inputs=[file_upload, camera_upload, agree_state], outputs=[agree_button, success_message, file_upload, camera_upload])
|
|
|
|
|
|
|
96 |
|
97 |
if __name__ == "__main__":
|
98 |
demo.launch()
|