yasserrmd commited on
Commit
a07d796
·
verified ·
1 Parent(s): e2d728a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -12
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
- input_file = gr.inputs.File(label="Upload Document")
29
- output_format = gr.inputs.Radio(["Markdown", "JSON"], label="Choose Output Format")
30
- output_text = gr.outputs.Textbox(label="Converted Document")
31
- output_metadata = gr.outputs.JSON(label="Metadata")
32
 
33
- app = gr.Interface(
34
- fn=convert_document,
35
- inputs=[input_file, output_format],
36
- outputs=[output_text, output_metadata],
37
- title="Document Converter with Docling",
38
- description="Upload a document (PDF, DOCX, or image), choose the output format, and get the converted document text along with metadata.",
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()