JaredBailey commited on
Commit
7c8aab6
·
verified ·
1 Parent(s): 5b2d1ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -104,7 +104,11 @@ with row3_col5:
104
  st.image(img_8, use_column_width=True)
105
  if st.button(f"Select Image ↑", key="button_8"):
106
  st.session_state.image = img_8
107
-
 
 
 
 
108
  #####
109
  ###
110
  # Output and Interaction
@@ -134,9 +138,8 @@ if st.session_state.image is not None:
134
  st.write("\n\n")
135
  components.html("""<hr style="height:2px;border:none;color:#333;background-color:#333;" /> """)
136
 
137
- # model
138
- model = YOLO("/home/user/app/models/head_model/best.pt") # load
139
- results = model.predict(tiles) # predict
140
 
141
 
142
  _, row4_col2, row4_col3, _ = st.columns([1,4,4,1], gap="medium")
@@ -145,11 +148,11 @@ if st.session_state.image is not None:
145
  with row4_col3:
146
  row4a_col3, row4b_col3= st.columns([1,1], gap="medium")
147
  with row4a_col3:
148
- if st.button("Back")
149
  if session_state.image_counter > 0:
150
  session_state.image_counter -= 1
151
  with row4b_col3:
152
- if st.button("Next")
153
  if session_state.image_counter < len(results):
154
  session_state.image_counter -= 1
155
 
 
104
  st.image(img_8, use_column_width=True)
105
  if st.button(f"Select Image ↑", key="button_8"):
106
  st.session_state.image = img_8
107
+
108
+ # model
109
+ if st.session_state.model is None:
110
+ session_state.model = YOLO("/home/user/app/models/head_model/best.pt") # load
111
+
112
  #####
113
  ###
114
  # Output and Interaction
 
138
  st.write("\n\n")
139
  components.html("""<hr style="height:2px;border:none;color:#333;background-color:#333;" /> """)
140
 
141
+ # predictions
142
+ results = session_state.model.predict(tiles) # predict
 
143
 
144
 
145
  _, row4_col2, row4_col3, _ = st.columns([1,4,4,1], gap="medium")
 
148
  with row4_col3:
149
  row4a_col3, row4b_col3= st.columns([1,1], gap="medium")
150
  with row4a_col3:
151
+ if st.button("Back"):
152
  if session_state.image_counter > 0:
153
  session_state.image_counter -= 1
154
  with row4b_col3:
155
+ if st.button("Next"):
156
  if session_state.image_counter < len(results):
157
  session_state.image_counter -= 1
158