process_pdf
Browse filesAdded process_pdf
app.py
CHANGED
@@ -267,7 +267,12 @@ def apply_ocr(cell_coordinates, cropped_table):
|
|
267 |
return df, data
|
268 |
|
269 |
|
270 |
-
def process_pdf(image):
|
|
|
|
|
|
|
|
|
|
|
271 |
cropped_table = detect_and_crop_table(image)
|
272 |
|
273 |
image, cells = recognize_table(cropped_table)
|
@@ -289,7 +294,7 @@ description = """<h3>Sherif's Demo for table extraction with the Table Transform
|
|
289 |
"""
|
290 |
|
291 |
app = gr.Interface(fn=process_pdf,
|
292 |
-
inputs=gr.Image(type="pil"),
|
293 |
outputs=[gr.Image(type="pil", label="Detected table"), gr.Dataframe(label="Table as CSV"), gr.JSON(label="Data as JSON")],
|
294 |
title=title,
|
295 |
description=description)
|
|
|
267 |
return df, data
|
268 |
|
269 |
|
270 |
+
def process_pdf(pdf, image):
|
271 |
+
# if pdf:
|
272 |
+
# image = convert_from_bytes()
|
273 |
+
return process_image(image)
|
274 |
+
|
275 |
+
def process_image(image):
|
276 |
cropped_table = detect_and_crop_table(image)
|
277 |
|
278 |
image, cells = recognize_table(cropped_table)
|
|
|
294 |
"""
|
295 |
|
296 |
app = gr.Interface(fn=process_pdf,
|
297 |
+
inputs=[gr.Interface(file_types=['.pdf'], label="Upload a PDF file"), gr.Image(type="pil", label="Or upload an image file to perform OCR directly")],
|
298 |
outputs=[gr.Image(type="pil", label="Detected table"), gr.Dataframe(label="Table as CSV"), gr.JSON(label="Data as JSON")],
|
299 |
title=title,
|
300 |
description=description)
|