update
Browse files
utils.py
CHANGED
@@ -88,20 +88,27 @@ def infer_uploaded_image(conf, model):
|
|
88 |
names = res[0].names
|
89 |
|
90 |
dnames = []
|
|
|
91 |
for cid in dclasses:
|
|
|
|
|
|
|
|
|
|
|
92 |
dnames.append(names[cid])
|
93 |
|
94 |
-
#print('names', names)
|
95 |
res_plotted = res[0].plot()[:, :, ::-1]
|
96 |
|
97 |
with col2:
|
98 |
st.image(res_plotted,
|
99 |
-
caption="
|
100 |
use_column_width=True)
|
101 |
try:
|
102 |
with st.expander("Detection Results"):
|
103 |
-
for box in boxes:
|
104 |
-
|
|
|
|
|
105 |
except Exception as ex:
|
106 |
st.write("No image is uploaded yet!")
|
107 |
st.write(ex)
|
|
|
88 |
names = res[0].names
|
89 |
|
90 |
dnames = []
|
91 |
+
ndetected = {}
|
92 |
for cid in dclasses:
|
93 |
+
if names[cid] in ndetected:
|
94 |
+
count = ndetected[names[cid]]
|
95 |
+
else:
|
96 |
+
count = 0
|
97 |
+
ndetected.update( {names[cid]:count+1} )
|
98 |
dnames.append(names[cid])
|
99 |
|
|
|
100 |
res_plotted = res[0].plot()[:, :, ::-1]
|
101 |
|
102 |
with col2:
|
103 |
st.image(res_plotted,
|
104 |
+
caption="{} classes detected".format(len(dnames)),
|
105 |
use_column_width=True)
|
106 |
try:
|
107 |
with st.expander("Detection Results"):
|
108 |
+
#for box in boxes:
|
109 |
+
# st.write(box.xywh)
|
110 |
+
for cname in ndetected:
|
111 |
+
st.write("{} x{}".format(cname, ndetected[cname]))
|
112 |
except Exception as ex:
|
113 |
st.write("No image is uploaded yet!")
|
114 |
st.write(ex)
|