JaredBailey commited on
Commit
1f181d0
·
verified ·
1 Parent(s): a59c29c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -14
app.py CHANGED
@@ -239,22 +239,21 @@ if st.session_state.screen == 2:
239
  st.rerun()
240
 
241
  # show character locations
242
- # class_names = {0: "Waldo", 1: "Wenda", 2: "Odlaw", 3: "Wizard", 4: "Woof"}
243
- # for idx, pred in enumerate(st.session_state.results):
244
- # #extract detected character names and their confidence scores
245
- # st.session_state.detected_characters = {}
246
- # for cls_id, conf in pred:
247
- # name = class_names[int(cls_id)] # Convert class ID to character name
248
- # if name in st.session_state.detected_characters:
249
- # if conf >= st.session_state.confidence:
250
- # st.session_state.detected_characters[name].append(idx)
251
 
252
  # display locations
253
- st.write(st.session_state.results[0][0])
254
- # st.session_state.locations = ""
255
- # for name, idx in st.session_state.detected_characters.items():
256
- # st.session_state.locations += f" {name} tiles: {str(idx)}, )"
257
- # st.write(st.session_state.locations)
258
 
259
  # plot predicted image
260
  st.markdown(f"<h4 style='text-align: center; color: black;'>Image Tile {str(st.session_state.image_counter + 1)}</h4>", unsafe_allow_html=True)
 
239
  st.rerun()
240
 
241
  # show character locations
242
+ class_names = {0: "Waldo", 1: "Wenda", 2: "Odlaw", 3: "Wizard", 4: "Woof"}
243
+ for idx, pred in enumerate(st.session_state.results):
244
+ #extract detected character names and their confidence scores
245
+ st.session_state.detected_characters = {}
246
+ for x, y, w, h, cls_id, conf in pred:
247
+ name = class_names[int(cls_id)] # Convert class ID to character name
248
+ if name in st.session_state.detected_characters:
249
+ if conf >= st.session_state.confidence:
250
+ st.session_state.detected_characters[name].append(idx)
251
 
252
  # display locations
253
+ st.session_state.locations = ""
254
+ for name, idx in st.session_state.detected_characters.items():
255
+ st.session_state.locations += f" {name} tiles: {str(idx)}, )"
256
+ st.write(st.session_state.locations)
 
257
 
258
  # plot predicted image
259
  st.markdown(f"<h4 style='text-align: center; color: black;'>Image Tile {str(st.session_state.image_counter + 1)}</h4>", unsafe_allow_html=True)