Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -24,18 +24,22 @@ def convert_document(file, output_format):
|
|
24 |
|
25 |
return converted_text, metadata
|
26 |
|
27 |
-
# Define the Gradio interface
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
output_metadata = gr.outputs.JSON(label="Metadata")
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
)
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
app.launch()
|
|
|
24 |
|
25 |
return converted_text, metadata
|
26 |
|
27 |
+
# Define the Gradio interface using new component syntax
|
28 |
+
with gr.Blocks() as app:
|
29 |
+
gr.Markdown("# Document Converter with Docling")
|
30 |
+
gr.Markdown("Upload a document, choose the output format, and get the converted text with metadata.")
|
|
|
31 |
|
32 |
+
file_input = gr.File(label="Upload Document")
|
33 |
+
format_input = gr.Radio(["Markdown", "JSON"], label="Choose Output Format")
|
34 |
+
output_text = gr.Textbox(label="Converted Document")
|
35 |
+
output_metadata = gr.JSON(label="Metadata")
|
36 |
+
|
37 |
+
# Define the process button and bind it to the function
|
38 |
+
convert_button = gr.Button("Convert")
|
39 |
+
convert_button.click(
|
40 |
+
convert_document,
|
41 |
+
inputs=[file_input, format_input],
|
42 |
+
outputs=[output_text, output_metadata]
|
43 |
+
)
|
44 |
|
45 |
app.launch()
|