Spaces:
Build error
Build error
debug detection display
Browse files
app.py
CHANGED
@@ -79,25 +79,17 @@ def get_detection(img_path):
|
|
79 |
(image_scale-new_size[1])//2))
|
80 |
pred_dict = model_type.end2end_detect(new_im, valid_tfms, model, class_map=class_map, detection_threshold=0.6)
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
st.success(f"Result : {labels} with {round(acc, 2)}% confidence.")
|
94 |
-
elif labels == "Pos":
|
95 |
-
labels = "Positive"
|
96 |
-
st.error(f"Result : {labels} with {round(acc, 2)}% confidence.")
|
97 |
-
except IndexError:
|
98 |
-
st.error("Not found ATK image! ; try to take image again..")
|
99 |
-
labels = "None"
|
100 |
-
acc = 0
|
101 |
|
102 |
def get_img_detection(img_path):
|
103 |
|
@@ -166,7 +158,7 @@ elif choice == "Detection (วิเคราะห์โรค)":
|
|
166 |
st.image(get_img_detection(image))
|
167 |
with st.spinner("🤖 On Working... "):
|
168 |
t1 = time.perf_counter()
|
169 |
-
st.subheader("
|
170 |
get_detection(image)
|
171 |
t2 = time.perf_counter()
|
172 |
st.write('time taken to run: {:.2f} sec'.format(t2-t1))
|
|
|
79 |
(image_scale-new_size[1])//2))
|
80 |
pred_dict = model_type.end2end_detect(new_im, valid_tfms, model, class_map=class_map, detection_threshold=0.6)
|
81 |
|
82 |
+
num_count = 1
|
83 |
+
for i,j in zip(pred_dict['detection']['labels'], pred_dict['detection']['scores']):
|
84 |
+
labels = i
|
85 |
+
acc = round((j*100),2)
|
86 |
+
if labels == "Neg":
|
87 |
+
labels = "Negative"
|
88 |
+
st.success(f"{num_count}. '{labels}' with {acc} % confidence.")
|
89 |
+
elif labels == "Pos":
|
90 |
+
labels = "Positive"
|
91 |
+
st.error(f"{num_count}. '{labels}' with {acc} % confidence.")
|
92 |
+
num_count += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
def get_img_detection(img_path):
|
95 |
|
|
|
158 |
st.image(get_img_detection(image))
|
159 |
with st.spinner("🤖 On Working... "):
|
160 |
t1 = time.perf_counter()
|
161 |
+
st.subheader("Detection result...")
|
162 |
get_detection(image)
|
163 |
t2 = time.perf_counter()
|
164 |
st.write('time taken to run: {:.2f} sec'.format(t2-t1))
|