update
Browse files
utils.py
CHANGED
@@ -79,16 +79,24 @@ def infer_uploaded_image(conf, model):
|
|
79 |
)
|
80 |
|
81 |
if source_img:
|
82 |
-
if st.button("
|
83 |
with st.spinner("Running..."):
|
84 |
res = model.predict(uploaded_image,
|
85 |
conf=conf)
|
86 |
boxes = res[0].boxes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
res_plotted = res[0].plot()[:, :, ::-1]
|
88 |
|
89 |
with col2:
|
90 |
st.image(res_plotted,
|
91 |
-
caption="Detected
|
92 |
use_column_width=True)
|
93 |
try:
|
94 |
with st.expander("Detection Results"):
|
@@ -114,7 +122,7 @@ def infer_uploaded_video(conf, model):
|
|
114 |
st.video(source_video)
|
115 |
|
116 |
if source_video:
|
117 |
-
if st.button("
|
118 |
with st.spinner("Running..."):
|
119 |
try:
|
120 |
tfile = tempfile.NamedTemporaryFile()
|
|
|
79 |
)
|
80 |
|
81 |
if source_img:
|
82 |
+
if st.button("Detect"):
|
83 |
with st.spinner("Running..."):
|
84 |
res = model.predict(uploaded_image,
|
85 |
conf=conf)
|
86 |
boxes = res[0].boxes
|
87 |
+
dclasses = boxes.cls.numpy(force=True)
|
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="Detected:{}".format(','.join(dnames)),
|
100 |
use_column_width=True)
|
101 |
try:
|
102 |
with st.expander("Detection Results"):
|
|
|
122 |
st.video(source_video)
|
123 |
|
124 |
if source_video:
|
125 |
+
if st.button("Detect"):
|
126 |
with st.spinner("Running..."):
|
127 |
try:
|
128 |
tfile = tempfile.NamedTemporaryFile()
|