Spaces:
Build error
Build error
Fix bug
Browse files
app.py
CHANGED
@@ -169,6 +169,7 @@ def visualize_ocr(pil_img, ocr_result):
|
|
169 |
x2 = int(bbox[2])
|
170 |
y2 = int(bbox[3])
|
171 |
cv2.rectangle(image, (x1, y1), (x2, y2), color=(0, 255, 0))
|
|
|
172 |
return cv_to_PIL(image)
|
173 |
|
174 |
|
@@ -192,7 +193,7 @@ def visualize_structure(pil_img, structure_result):
|
|
192 |
# print(x1, y1, x2, y2)
|
193 |
|
194 |
if score >= structure_class_thresholds[structure_class_names[class_id]]:
|
195 |
-
cv2.rectangle(image, (x1, y1), (x2, y2), color=(0,
|
196 |
#cv2.putText(image, str(i)+'-'+str(class_id), (x1-10, y1), cv2.FONT_HERSHEY_SIMPLEX, fontScale=1, color=(0,0,255))
|
197 |
|
198 |
return cv_to_PIL(image)
|
@@ -369,16 +370,16 @@ def main():
|
|
369 |
st.title('Table Extraction Demo')
|
370 |
st.write('\n')
|
371 |
|
|
|
|
|
372 |
tabs = st.tabs(
|
373 |
['Table Detection', 'Table Structure Recognition']
|
374 |
)
|
375 |
|
376 |
-
filename = st.file_uploader('Upload image', type=['png', 'jpeg', 'jpg'])
|
377 |
-
|
378 |
if st.button('Analyze image'):
|
379 |
|
380 |
if filename is None:
|
381 |
-
st.
|
382 |
|
383 |
else:
|
384 |
print(filename)
|
@@ -415,12 +416,7 @@ def main():
|
|
415 |
str_cols[1].image(vis_ocr_img)
|
416 |
str_cols[2].image(vis_str_img)
|
417 |
str_cols[3].image(vis_cells_img)
|
418 |
-
|
419 |
-
try:
|
420 |
-
str_cols[4].dataframe(df)
|
421 |
-
except:
|
422 |
-
pass
|
423 |
-
|
424 |
str_cols[4].download_button('Download table', csv_result, f'table-{i}.csv', 'text/csv', key=f'download-csv-{i}')
|
425 |
|
426 |
st.write('\n')
|
|
|
169 |
x2 = int(bbox[2])
|
170 |
y2 = int(bbox[3])
|
171 |
cv2.rectangle(image, (x1, y1), (x2, y2), color=(0, 255, 0))
|
172 |
+
cv2.putText(image, res['text'], (x1, y1), cv2.FONT_HERSHEY_SIMPLEX, fontScale=0.5, color=(0, 0, 255))
|
173 |
return cv_to_PIL(image)
|
174 |
|
175 |
|
|
|
193 |
# print(x1, y1, x2, y2)
|
194 |
|
195 |
if score >= structure_class_thresholds[structure_class_names[class_id]]:
|
196 |
+
cv2.rectangle(image, (x1, y1), (x2, y2), color=(0, 255, 0))
|
197 |
#cv2.putText(image, str(i)+'-'+str(class_id), (x1-10, y1), cv2.FONT_HERSHEY_SIMPLEX, fontScale=1, color=(0,0,255))
|
198 |
|
199 |
return cv_to_PIL(image)
|
|
|
370 |
st.title('Table Extraction Demo')
|
371 |
st.write('\n')
|
372 |
|
373 |
+
filename = st.file_uploader('Upload image', type=['png', 'jpeg', 'jpg'])
|
374 |
+
|
375 |
tabs = st.tabs(
|
376 |
['Table Detection', 'Table Structure Recognition']
|
377 |
)
|
378 |
|
|
|
|
|
379 |
if st.button('Analyze image'):
|
380 |
|
381 |
if filename is None:
|
382 |
+
st.write('Please upload an image')
|
383 |
|
384 |
else:
|
385 |
print(filename)
|
|
|
416 |
str_cols[1].image(vis_ocr_img)
|
417 |
str_cols[2].image(vis_str_img)
|
418 |
str_cols[3].image(vis_cells_img)
|
419 |
+
#str_cols[4].dataframe(df)
|
|
|
|
|
|
|
|
|
|
|
420 |
str_cols[4].download_button('Download table', csv_result, f'table-{i}.csv', 'text/csv', key=f'download-csv-{i}')
|
421 |
|
422 |
st.write('\n')
|