Spaces:
Sleeping
Sleeping
this work
Browse files
app.py
CHANGED
@@ -10,14 +10,7 @@ from streamlit_drawable_canvas import st_canvas
|
|
10 |
from modules.streamlit_utils import *
|
11 |
from glob import glob
|
12 |
|
13 |
-
import
|
14 |
-
import subprocess
|
15 |
-
|
16 |
-
# Run the setup script if the package directory does not exist
|
17 |
-
if not os.path.exists('Streamlit-Image-Annotation'):
|
18 |
-
subprocess.run(['bash', 'setup.sh'], check=True)
|
19 |
-
|
20 |
-
from streamlit_image_annotation import detection
|
21 |
from modules.toXML import create_XML
|
22 |
|
23 |
def configure_page():
|
@@ -122,39 +115,7 @@ def launch_prediction(cropped_image, score_threshold, is_mobile, screen_width):
|
|
122 |
|
123 |
from modules.eval import develop_prediction, generate_data
|
124 |
from modules.utils import class_dict
|
125 |
-
def modify_results(percentage_text_dist_thresh=0.5):
|
126 |
-
with st.expander("Method and Style modification (beta version)"):
|
127 |
-
label_list = list(class_dict.values())
|
128 |
-
bboxes = [[int(coord) for coord in box] for box in st.session_state.prediction['boxes']]
|
129 |
-
for i in range(len(bboxes)):
|
130 |
-
bboxes[i][2] = bboxes[i][2] - bboxes[i][0]
|
131 |
-
bboxes[i][3] = bboxes[i][3] - bboxes[i][1]
|
132 |
-
labels = [int(label) for label in st.session_state.prediction['labels']]
|
133 |
-
uploaded_image = prepare_image(st.session_state.crop_image, new_size=(1333, 1333), pad=False)
|
134 |
-
scale = 2000 / uploaded_image.size[0]
|
135 |
-
new_labels = detection(
|
136 |
-
image=uploaded_image, bboxes=bboxes, labels=labels,
|
137 |
-
label_list=label_list, line_width=3, width=2000, use_space=False
|
138 |
-
)
|
139 |
-
|
140 |
-
if new_labels is not None:
|
141 |
-
new_lab = np.array([label['label_id'] for label in new_labels])
|
142 |
-
|
143 |
-
# Convert back to original format
|
144 |
-
bboxes = np.array([label['bbox'] for label in new_labels])
|
145 |
-
for i in range(len(bboxes)):
|
146 |
-
bboxes[i][2] = bboxes[i][2] + bboxes[i][0]
|
147 |
-
bboxes[i][3] = bboxes[i][3] + bboxes[i][1]
|
148 |
|
149 |
-
scores = st.session_state.prediction['scores']
|
150 |
-
keypoints = st.session_state.prediction['keypoints']
|
151 |
-
#print('Old prediction:', st.session_state.prediction['keypoints'])
|
152 |
-
boxes, labels, scores, keypoints, flow_links, best_points, pool_dict = develop_prediction(bboxes, new_lab, scores, keypoints, class_dict, correction=False)
|
153 |
-
|
154 |
-
st.session_state.prediction = generate_data(st.session_state.prediction['image'], boxes, labels, scores, keypoints, flow_links, best_points, pool_dict, class_dict)
|
155 |
-
st.session_state.text_mapping = mapping_text(st.session_state.prediction, st.session_state.text_pred, print_sentences=False, percentage_thresh=percentage_text_dist_thresh)
|
156 |
-
|
157 |
-
#print('New prediction:', st.session_state.prediction['keypoints'])
|
158 |
|
159 |
|
160 |
def display_bpmn_modeler(is_mobile, screen_width):
|
@@ -199,8 +160,8 @@ def main():
|
|
199 |
with st.spinner('Waiting for result display...'):
|
200 |
display_options(st.session_state.crop_image, st.session_state.score_threshold, is_mobile, int(5/6 * screen_width))
|
201 |
|
202 |
-
if not is_mobile:
|
203 |
-
modify_results()
|
204 |
|
205 |
with st.expander("Options for BPMN modeler"):
|
206 |
modeler_options(is_mobile)
|
|
|
10 |
from modules.streamlit_utils import *
|
11 |
from glob import glob
|
12 |
|
13 |
+
#from streamlit_image_annotation import detection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
from modules.toXML import create_XML
|
15 |
|
16 |
def configure_page():
|
|
|
115 |
|
116 |
from modules.eval import develop_prediction, generate_data
|
117 |
from modules.utils import class_dict
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
|
121 |
def display_bpmn_modeler(is_mobile, screen_width):
|
|
|
160 |
with st.spinner('Waiting for result display...'):
|
161 |
display_options(st.session_state.crop_image, st.session_state.score_threshold, is_mobile, int(5/6 * screen_width))
|
162 |
|
163 |
+
#if not is_mobile:
|
164 |
+
#modify_results()
|
165 |
|
166 |
with st.expander("Options for BPMN modeler"):
|
167 |
modeler_options(is_mobile)
|