Spaces:
Runtime error
Runtime error
napatswift
commited on
Commit
·
1e41e52
1
Parent(s):
a03e1e7
Update app and weights
Browse files- main.py +6 -4
- model/table-det/model.pth +2 -2
main.py
CHANGED
@@ -86,26 +86,28 @@ def get_bbox(mask_array):
|
|
86 |
|
87 |
def predict(image_input):
|
88 |
logger.info(f"Image input: {image_input}")
|
89 |
-
|
90 |
# Inference the tables in the image.
|
91 |
result = inference_detector(table_det, image_input)
|
92 |
|
93 |
# Get the masks of the tables.
|
94 |
mask_images = result.pred_instances.masks.cpu().numpy()
|
95 |
scores = result.pred_instances.scores.cpu().numpy()
|
|
|
96 |
|
97 |
logger.info(f"Result: {result}")
|
98 |
|
99 |
bbox_list = []
|
100 |
|
101 |
# Filter out the masks with a score less than 0.5.
|
102 |
-
filtered_mask_images = mask_images
|
|
|
103 |
|
104 |
# Get the bounding boxes of the tables.
|
105 |
-
for mask_image in
|
106 |
bbox_list.extend(get_bbox(mask_image.astype(np.uint8)))
|
107 |
|
108 |
-
return bbox_list
|
109 |
|
110 |
|
111 |
def run():
|
|
|
86 |
|
87 |
def predict(image_input):
|
88 |
logger.info(f"Image input: {image_input}")
|
89 |
+
|
90 |
# Inference the tables in the image.
|
91 |
result = inference_detector(table_det, image_input)
|
92 |
|
93 |
# Get the masks of the tables.
|
94 |
mask_images = result.pred_instances.masks.cpu().numpy()
|
95 |
scores = result.pred_instances.scores.cpu().numpy()
|
96 |
+
bboxes = result.pred_instances.bboxes.cpu().numpy()
|
97 |
|
98 |
logger.info(f"Result: {result}")
|
99 |
|
100 |
bbox_list = []
|
101 |
|
102 |
# Filter out the masks with a score less than 0.5.
|
103 |
+
filtered_mask_images = mask_images[scores > 0.5]
|
104 |
+
filtered_bboxes = bboxes[scores > 0.5]
|
105 |
|
106 |
# Get the bounding boxes of the tables.
|
107 |
+
for mask_image in filtered_mask_images:
|
108 |
bbox_list.extend(get_bbox(mask_image.astype(np.uint8)))
|
109 |
|
110 |
+
return {'rect-fit': bbox_list, 'bbox': filtered_bboxes}
|
111 |
|
112 |
|
113 |
def run():
|
model/table-det/model.pth
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fc857b4c227cf5ee04c66fc6909cb4d63dd19f412cec20721e1d79b0b9fb242e
|
3 |
+
size 351847113
|