Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,7 +19,7 @@ def process_img(img_path):
|
|
| 19 |
|
| 20 |
st.title("Table Extract")
|
| 21 |
file_name = st.file_uploader("Upload a repport image")
|
| 22 |
-
|
| 23 |
if file_name is not None:
|
| 24 |
col1, col2 = st.columns(2)
|
| 25 |
|
|
@@ -30,20 +30,20 @@ if file_name is not None:
|
|
| 30 |
bbox,confidance , classes , nc = bbox[0].numpy(),confidance[0].numpy(),classes[0].numpy(),nc[0].numpy()
|
| 31 |
|
| 32 |
for i in range(nc):
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
|
| 48 |
col2.image(copy_img, use_column_width=True)
|
| 49 |
|
|
|
|
| 19 |
|
| 20 |
st.title("Table Extract")
|
| 21 |
file_name = st.file_uploader("Upload a repport image")
|
| 22 |
+
print(type(file_name),file_name)
|
| 23 |
if file_name is not None:
|
| 24 |
col1, col2 = st.columns(2)
|
| 25 |
|
|
|
|
| 30 |
bbox,confidance , classes , nc = bbox[0].numpy(),confidance[0].numpy(),classes[0].numpy(),nc[0].numpy()
|
| 31 |
|
| 32 |
for i in range(nc):
|
| 33 |
+
if confidance[i] >= threshold:
|
| 34 |
+
x1,y1,x2,y2 = bbox[i]*640
|
| 35 |
+
class_name = labels[int(classes[i])]
|
| 36 |
+
if class_name =="Header":
|
| 37 |
+
color = (0,0,255) #Blue color
|
| 38 |
+
cv2.rectangle(copy_img, (int(x1), int(y1)), (int(x2), int(y2)),color, 2)
|
| 39 |
+
|
| 40 |
+
if class_name =="Column":
|
| 41 |
+
color = (0,255,0) #Green color
|
| 42 |
+
cv2.rectangle(copy_img, (int(x1), int(y1)), (int(x2), int(y2)),color, 2)
|
| 43 |
+
|
| 44 |
+
if class_name =="Table":
|
| 45 |
+
color = (255,0,0) #Red color
|
| 46 |
+
cv2.rectangle(copy_img, (int(x1), int(y1)), (int(x2), int(y2)),color, 2)
|
| 47 |
|
| 48 |
col2.image(copy_img, use_column_width=True)
|
| 49 |
|