Update app.py
Browse files
app.py
CHANGED
|
@@ -232,7 +232,7 @@ def apply_ocr(cell_coordinates, cropped_table):
|
|
| 232 |
# return as Pandas dataframe
|
| 233 |
df = pd.read_csv('output.csv')
|
| 234 |
|
| 235 |
-
return df
|
| 236 |
|
| 237 |
|
| 238 |
def process_pdf(image):
|
|
@@ -242,18 +242,18 @@ def process_pdf(image):
|
|
| 242 |
|
| 243 |
cell_coordinates = get_cell_coordinates_by_row(cells)
|
| 244 |
|
| 245 |
-
data = apply_ocr(cell_coordinates, image)
|
| 246 |
|
| 247 |
-
return image, data
|
| 248 |
|
| 249 |
|
| 250 |
title = "Demo: table detection & recognition with Table Transformer"
|
| 251 |
description = "Demo for table extraction with the Table Transformer (TATR)."
|
| 252 |
-
examples =[['image.png', 'clip_paper.png']]
|
| 253 |
|
| 254 |
app = gr.Interface(fn=process_pdf,
|
| 255 |
inputs=gr.Image(type="pil"),
|
| 256 |
-
outputs=[gr.Image(type="pil", label="Detected table"), gr.Dataframe(label="Table as CSV")],
|
| 257 |
title=title,
|
| 258 |
description=description,
|
| 259 |
examples=examples)
|
|
|
|
| 232 |
# return as Pandas dataframe
|
| 233 |
df = pd.read_csv('output.csv')
|
| 234 |
|
| 235 |
+
return df, data
|
| 236 |
|
| 237 |
|
| 238 |
def process_pdf(image):
|
|
|
|
| 242 |
|
| 243 |
cell_coordinates = get_cell_coordinates_by_row(cells)
|
| 244 |
|
| 245 |
+
df, data = apply_ocr(cell_coordinates, image)
|
| 246 |
|
| 247 |
+
return image, df, data
|
| 248 |
|
| 249 |
|
| 250 |
title = "Demo: table detection & recognition with Table Transformer"
|
| 251 |
description = "Demo for table extraction with the Table Transformer (TATR)."
|
| 252 |
+
examples = [['image.png', 'clip_paper.png']]
|
| 253 |
|
| 254 |
app = gr.Interface(fn=process_pdf,
|
| 255 |
inputs=gr.Image(type="pil"),
|
| 256 |
+
outputs=[gr.Image(type="pil", label="Detected table"), gr.Dataframe(label="Table as CSV"), gr.JSON(label="Data as JSON")],
|
| 257 |
title=title,
|
| 258 |
description=description,
|
| 259 |
examples=examples)
|