Spaces:
Runtime error
Runtime error
Commit
·
46fc025
1
Parent(s):
b29f831
update
Browse files
app.py
CHANGED
@@ -162,6 +162,7 @@ def process_image(image_path, flag_lower, flag_upper, plant_lower, plant_upper,
|
|
162 |
if len(significant_contours) < 4:
|
163 |
return None, None, None, None, None, None, None, None, None, None
|
164 |
elif len(significant_contours) > 4:
|
|
|
165 |
while not st.session_state['keep_quad']:
|
166 |
with loc:
|
167 |
st.warning("Cycle until correct plot bounds are found")
|
@@ -234,7 +235,7 @@ def process_image(image_path, flag_lower, flag_upper, plant_lower, plant_upper,
|
|
234 |
|
235 |
# Sort the centroids
|
236 |
centroids.sort(key=lambda point: (-math.atan2(point[1] - centroid_y, point[0] - centroid_x)) % (2 * np.pi))
|
237 |
-
|
238 |
# Create a polygon mask using the sorted centroids
|
239 |
poly_mask = np.zeros_like(flag_mask)
|
240 |
cv2.fillPoly(poly_mask, [np.array(centroids)], 255)
|
@@ -555,6 +556,8 @@ if 'dir_uploaded_images_small' not in st.session_state:
|
|
555 |
st.session_state['dir_uploaded_images_small'] = os.path.join(st.session_state['dir_home'],'uploads_small')
|
556 |
validate_dir(os.path.join(st.session_state['dir_home'],'uploads_small'))
|
557 |
|
|
|
|
|
558 |
|
559 |
st.title("GreenSight")
|
560 |
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.")
|
|
|
162 |
if len(significant_contours) < 4:
|
163 |
return None, None, None, None, None, None, None, None, None, None
|
164 |
elif len(significant_contours) > 4:
|
165 |
+
st.session_state['keep_quad'] = False
|
166 |
while not st.session_state['keep_quad']:
|
167 |
with loc:
|
168 |
st.warning("Cycle until correct plot bounds are found")
|
|
|
235 |
|
236 |
# Sort the centroids
|
237 |
centroids.sort(key=lambda point: (-math.atan2(point[1] - centroid_y, point[0] - centroid_x)) % (2 * np.pi))
|
238 |
+
|
239 |
# Create a polygon mask using the sorted centroids
|
240 |
poly_mask = np.zeros_like(flag_mask)
|
241 |
cv2.fillPoly(poly_mask, [np.array(centroids)], 255)
|
|
|
556 |
st.session_state['dir_uploaded_images_small'] = os.path.join(st.session_state['dir_home'],'uploads_small')
|
557 |
validate_dir(os.path.join(st.session_state['dir_home'],'uploads_small'))
|
558 |
|
559 |
+
if 'keep_quad' not in st.session_state:
|
560 |
+
st.session_state['keep_quad'] = False
|
561 |
|
562 |
st.title("GreenSight")
|
563 |
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.")
|