Tanaanan commited on
Commit
e8f128f
·
1 Parent(s): 97cac67

debug detection display

Browse files
Files changed (1) hide show
  1. app.py +12 -20
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
- #st.write(new_im.size)
85
-
86
-
87
-
88
- try:
89
- labels, acc = pred_dict['detection']['labels'][0], pred_dict['detection']['scores'][0]
90
- acc = acc * 100
91
- if labels == "Neg":
92
- labels = "Negative"
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("Process Completed!.....")
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))