JaredBailey commited on
Commit
9cd379e
·
verified ·
1 Parent(s): a14971f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -108,6 +108,7 @@ with row3_col5:
108
  # load model
109
  if 'model' not in st.session_state:
110
  st.session_state.model = YOLO("/home/user/app/models/head_model/best.pt") # load
 
111
 
112
  #####
113
  ###
@@ -139,7 +140,8 @@ if st.session_state.image is not None:
139
  components.html("""<hr style="height:2px;border:none;color:#333;background-color:#333;" /> """)
140
 
141
  # predictions
142
- results = st.session_state.model.predict(tiles) # predict
 
143
 
144
 
145
  _, row4_col2, row4_col3, _ = st.columns([1,4,4,1], gap="medium")
@@ -154,10 +156,10 @@ if st.session_state.image is not None:
154
  with row4b_col3:
155
  if st.button("Next"):
156
  if st.session_state.image_counter < len(results):
157
- st.session_state.image_counter -= 1
158
 
159
  # Plot predicted image
160
- im_bgr = results[st.session_state.image_counter].plot() # BGR-order numpy array
161
  im_rgb = Image.fromarray(im_bgr[..., ::-1]) # RGB-order PIL image
162
  st.image(im_rgb)
163
 
 
108
  # load model
109
  if 'model' not in st.session_state:
110
  st.session_state.model = YOLO("/home/user/app/models/head_model/best.pt") # load
111
+
112
 
113
  #####
114
  ###
 
140
  components.html("""<hr style="height:2px;border:none;color:#333;background-color:#333;" /> """)
141
 
142
  # predictions
143
+ if 'results' not in st.session_state:
144
+ st.sessionstate.results = st.session_state.model.predict(tiles) # predict
145
 
146
 
147
  _, row4_col2, row4_col3, _ = st.columns([1,4,4,1], gap="medium")
 
156
  with row4b_col3:
157
  if st.button("Next"):
158
  if st.session_state.image_counter < len(results):
159
+ st.session_state.image_counter += 1
160
 
161
  # Plot predicted image
162
+ im_bgr = st.sessionstate.results[st.session_state.image_counter].plot() # BGR-order numpy array
163
  im_rgb = Image.fromarray(im_bgr[..., ::-1]) # RGB-order PIL image
164
  st.image(im_rgb)
165