Spaces:
Runtime error
Runtime error
Commit
·
dc75c91
1
Parent(s):
5a67d38
update
Browse files
app.py
CHANGED
@@ -221,8 +221,8 @@ def process_image(image_path, flag_lower, flag_upper, plant_lower, plant_upper,
|
|
221 |
return None, None, None, None, None, None, None, None, None, None
|
222 |
|
223 |
# Initial quadrilateral index
|
224 |
-
selected_quad_index = 0
|
225 |
-
centroids = get_points_from_contours(valid_quadrilaterals[selected_quad_index])
|
226 |
# Function to update displayed quadrilateral based on selected index
|
227 |
def update_displayed_quadrilateral(index):
|
228 |
# Extract the four points of the current quadrilateral
|
@@ -230,16 +230,16 @@ def process_image(image_path, flag_lower, flag_upper, plant_lower, plant_upper,
|
|
230 |
return centroids
|
231 |
|
232 |
# Show initial quadrilateral
|
233 |
-
centroids = update_displayed_quadrilateral(selected_quad_index)
|
234 |
|
235 |
with btn_back:
|
236 |
if st.button('Previous'):
|
237 |
-
selected_quad_index = max(selected_quad_index - 1, 0)
|
238 |
-
update_displayed_quadrilateral(selected_quad_index)
|
239 |
with btn_next:
|
240 |
if st.button('Next'):
|
241 |
-
selected_quad_index = min(selected_quad_index + 1, len(valid_quadrilaterals) - 1)
|
242 |
-
update_displayed_quadrilateral(selected_quad_index)
|
243 |
|
244 |
poly_mask = create_polygon_mask(centroids, flag_mask.shape)
|
245 |
|
@@ -559,6 +559,9 @@ if 'dir_uploaded_images_small' not in st.session_state:
|
|
559 |
st.session_state['dir_uploaded_images_small'] = os.path.join(st.session_state['dir_home'],'uploads_small')
|
560 |
validate_dir(os.path.join(st.session_state['dir_home'],'uploads_small'))
|
561 |
|
|
|
|
|
|
|
562 |
|
563 |
st.title("GreenSight")
|
564 |
st.write("Simple color segmentation app to estimate the vegetation coverage in a plot. Corners of the plot need to be marked with solid, uniforly colored flags.")
|
|
|
221 |
return None, None, None, None, None, None, None, None, None, None
|
222 |
|
223 |
# Initial quadrilateral index
|
224 |
+
st.session_state['selected_quad_index'] = 0
|
225 |
+
centroids = get_points_from_contours(valid_quadrilaterals[st.session_state['selected_quad_index']])
|
226 |
# Function to update displayed quadrilateral based on selected index
|
227 |
def update_displayed_quadrilateral(index):
|
228 |
# Extract the four points of the current quadrilateral
|
|
|
230 |
return centroids
|
231 |
|
232 |
# Show initial quadrilateral
|
233 |
+
centroids = update_displayed_quadrilateral(st.session_state['selected_quad_index'])
|
234 |
|
235 |
with btn_back:
|
236 |
if st.button('Previous'):
|
237 |
+
st.session_state['selected_quad_index'] = max(st.session_state['selected_quad_index'] - 1, 0)
|
238 |
+
update_displayed_quadrilateral(st.session_state['selected_quad_index'])
|
239 |
with btn_next:
|
240 |
if st.button('Next'):
|
241 |
+
st.session_state['selected_quad_index'] = min(st.session_state['selected_quad_index'] + 1, len(valid_quadrilaterals) - 1)
|
242 |
+
update_displayed_quadrilateral(st.session_state['selected_quad_index'])
|
243 |
|
244 |
poly_mask = create_polygon_mask(centroids, flag_mask.shape)
|
245 |
|
|
|
559 |
st.session_state['dir_uploaded_images_small'] = os.path.join(st.session_state['dir_home'],'uploads_small')
|
560 |
validate_dir(os.path.join(st.session_state['dir_home'],'uploads_small'))
|
561 |
|
562 |
+
if 'selected_quad_index' not in st.session_state:
|
563 |
+
st.session_state['selected_quad_index'] = 0
|
564 |
+
|
565 |
|
566 |
st.title("GreenSight")
|
567 |
st.write("Simple color segmentation app to estimate the vegetation coverage in a plot. Corners of the plot need to be marked with solid, uniforly colored flags.")
|