Spaces:
Sleeping
Sleeping
Joshnicholas
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -256,15 +256,15 @@ def apply_ocr(cell_coordinates, cropped_table):
|
|
256 |
row_data = row_data + ["" for _ in range(max_num_columns - len(row_data))]
|
257 |
data[str(idx)] = row_data
|
258 |
|
259 |
-
# write to csv
|
260 |
-
with open('output.csv','w') as result_file:
|
261 |
-
|
262 |
|
263 |
-
|
264 |
-
|
265 |
|
266 |
-
# return as Pandas dataframe
|
267 |
-
df = pd.read_csv('output.csv')
|
268 |
|
269 |
return data
|
270 |
|
@@ -276,9 +276,13 @@ def process_pdf(image):
|
|
276 |
|
277 |
cell_coordinates = get_cell_coordinates_by_row(cells)
|
278 |
|
279 |
-
df, data = apply_ocr(cell_coordinates, image)
|
280 |
|
281 |
-
return image, df, data
|
|
|
|
|
|
|
|
|
282 |
|
283 |
|
284 |
title = "Demo: table detection & recognition with Table Transformer (TATR)."
|
|
|
256 |
row_data = row_data + ["" for _ in range(max_num_columns - len(row_data))]
|
257 |
data[str(idx)] = row_data
|
258 |
|
259 |
+
# # write to csv
|
260 |
+
# with open('output.csv','w') as result_file:
|
261 |
+
# wr = csv.writer(result_file, dialect='excel')
|
262 |
|
263 |
+
# for row, row_text in data.items():
|
264 |
+
# wr.writerow(row_text)
|
265 |
|
266 |
+
# # return as Pandas dataframe
|
267 |
+
# df = pd.read_csv('output.csv')
|
268 |
|
269 |
return data
|
270 |
|
|
|
276 |
|
277 |
cell_coordinates = get_cell_coordinates_by_row(cells)
|
278 |
|
279 |
+
# df, data = apply_ocr(cell_coordinates, image)
|
280 |
|
281 |
+
# return image, df, data
|
282 |
+
|
283 |
+
data = apply_ocr(cell_coordinates, image)
|
284 |
+
|
285 |
+
return image, data
|
286 |
|
287 |
|
288 |
title = "Demo: table detection & recognition with Table Transformer (TATR)."
|