AkashDataScience commited on
Commit
bf6c79b
·
1 Parent(s): 8dc2d5d

Interface changes

Browse files
Files changed (1) hide show
  1. app.py +35 -30
app.py CHANGED
@@ -98,36 +98,41 @@ examples = [["data/amazon-10-k-2024.pdf"],
98
 
99
  with gr.Blocks(theme=gr.themes.Glass()) as demo:
100
  gr.Markdown(f"# {title}\n{description}")
101
- with gr.Row():
102
- with gr.Column():
103
- pdf = gr.File(label="Input PDFs", file_types=[".pdf"])
104
-
105
- @gr.render(inputs=pdf)
106
- def show_slider(pdf_path):
107
- if pdf_path is None:
108
- page_num = gr.Markdown("## No Input Provided")
109
- else:
110
- page_count = get_pdf_page_count(pdf_path)
111
- page_num = gr.Slider(1, page_count, value=1, step=1, label="Page Number")
112
-
113
- with gr.Row():
114
- clear_btn = gr.ClearButton(components=[pdf, page_num])
115
- submit_btn = gr.Button("Submit", variant='primary')
116
-
117
- submit_btn.click(get_page_image, inputs=[pdf, page_num], outputs=[original, original_runtime]).then(
118
- get_docling_ocr, inputs=[pdf, page_num], outputs=[docling_ocr_out, docling_ocr_runtime]).then(
119
- get_paddle_ocr, inputs=[pdf, page_num], outputs=[paddle_ocr_out, paddle_ocr_runtime]).then(
120
- get_smoldocling_ocr, inputs=[pdf, page_num], outputs=[smoldocling_ocr_out, smoldocling_ocr_runtime])
121
-
122
- with gr.Column():
123
- original = gr.Image(width=640, height=640, label="Original Page", interactive=False)
124
- original_runtime = gr.Textbox(label="Image Extraction Time", type="text", interactive=False)
125
- docling_ocr_out = gr.Textbox(label="Docling OCR Output", type="text", interactive=False)
126
- docling_ocr_runtime = gr.Textbox(label="Docling OCR Time", type="text", interactive=False)
127
- paddle_ocr_out = gr.Textbox(label="Paddle OCR Output", type="text", interactive=False)
128
- paddle_ocr_runtime = gr.Textbox(label="Paddle OCR Time", type="text", interactive=False)
129
- smoldocling_ocr_out = gr.Textbox(label="SmolDocling OCR Output", type="text", interactive=False)
130
- smoldocling_ocr_runtime = gr.Textbox(label="SmolDocling OCR Time", type="text", interactive=False)
 
 
 
 
 
131
 
132
  examples_obj = gr.Examples(examples=examples, inputs=[pdf])
133
 
 
98
 
99
  with gr.Blocks(theme=gr.themes.Glass()) as demo:
100
  gr.Markdown(f"# {title}\n{description}")
101
+ with gr.Column():
102
+ pdf = gr.File(label="Input PDFs", file_types=[".pdf"])
103
+
104
+ @gr.render(inputs=pdf)
105
+ def show_slider(pdf_path):
106
+ if pdf_path is None:
107
+ page_num = gr.Markdown("## No Input Provided")
108
+ else:
109
+ page_count = get_pdf_page_count(pdf_path)
110
+ page_num = gr.Slider(1, page_count, value=1, step=1, label="Page Number")
111
+
112
+ with gr.Row():
113
+ clear_btn = gr.ClearButton(components=[pdf, page_num])
114
+ submit_btn = gr.Button("Submit", variant='primary')
115
+
116
+ submit_btn.click(get_page_image, inputs=[pdf, page_num], outputs=[original, original_runtime]).then(
117
+ get_docling_ocr, inputs=[pdf, page_num], outputs=[docling_ocr_out, docling_ocr_runtime]).then(
118
+ get_paddle_ocr, inputs=[pdf, page_num], outputs=[paddle_ocr_out, paddle_ocr_runtime]).then(
119
+ get_smoldocling_ocr, inputs=[pdf, page_num], outputs=[smoldocling_ocr_out, smoldocling_ocr_runtime])
120
+
121
+ with gr.Column():
122
+ with gr.Row():
123
+ with gr.Column():
124
+ original = gr.Image(width=640, height=640, label="Original Page", interactive=False)
125
+ original_runtime = gr.Textbox(label="Image Extraction Time", type="text", interactive=False)
126
+ with gr.Column():
127
+ docling_ocr_out = gr.Textbox(label="Docling OCR Output", type="text", interactive=False)
128
+ docling_ocr_runtime = gr.Textbox(label="Docling OCR Time", type="text", interactive=False)
129
+ with gr.Row():
130
+ with gr.Column():
131
+ paddle_ocr_out = gr.Textbox(label="Paddle OCR Output", type="text", interactive=False)
132
+ paddle_ocr_runtime = gr.Textbox(label="Paddle OCR Time", type="text", interactive=False)
133
+ with gr.Column():
134
+ smoldocling_ocr_out = gr.Textbox(label="SmolDocling OCR Output", type="text", interactive=False)
135
+ smoldocling_ocr_runtime = gr.Textbox(label="SmolDocling OCR Time", type="text", interactive=False)
136
 
137
  examples_obj = gr.Examples(examples=examples, inputs=[pdf])
138