Spaces:
Sleeping
Sleeping
Update pages/3ML Project Life Cycle.py
Browse files
pages/3ML Project Life Cycle.py
CHANGED
|
@@ -1309,7 +1309,7 @@ cv2.destroyAllWindows()
|
|
| 1309 |
file_bytes = np.asarray(bytearray(uploaded_file.read()), dtype=np.uint8)
|
| 1310 |
img = cv2.imdecode(file_bytes, 1)
|
| 1311 |
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
| 1312 |
-
st.image(img, caption="Uploaded Image",
|
| 1313 |
|
| 1314 |
# Choose operation
|
| 1315 |
st.markdown("### Choose Transformation")
|
|
@@ -1326,7 +1326,7 @@ cv2.destroyAllWindows()
|
|
| 1326 |
y2 = st.number_input("Y2 (End Row)", min_value=y1 + 1, value=img.shape[0], step=1)
|
| 1327 |
if st.button("Apply Cropping"):
|
| 1328 |
cropped_img = img[y1:y2, x1:x2]
|
| 1329 |
-
st.image(cropped_img, caption="Cropped Image",
|
| 1330 |
|
| 1331 |
elif operation == "Scaling":
|
| 1332 |
st.markdown("### Scaling Parameters")
|
|
@@ -1334,7 +1334,7 @@ cv2.destroyAllWindows()
|
|
| 1334 |
scale_y = st.slider("Scale Y", 0.1, 3.0, 1.0, step=0.1)
|
| 1335 |
if st.button("Apply Scaling"):
|
| 1336 |
scaled_img = cv2.resize(img, None, fx=scale_x, fy=scale_y, interpolation=cv2.INTER_LINEAR)
|
| 1337 |
-
st.image(scaled_img, caption="Scaled Image",
|
| 1338 |
|
| 1339 |
elif operation == "Translation":
|
| 1340 |
st.markdown("### Translation Parameters")
|
|
@@ -1343,7 +1343,7 @@ cv2.destroyAllWindows()
|
|
| 1343 |
if st.button("Apply Translation"):
|
| 1344 |
t_mat = np.float32([[1, 0, tx], [0, 1, ty]])
|
| 1345 |
translated_img = cv2.warpAffine(img, t_mat, (img.shape[1], img.shape[0]))
|
| 1346 |
-
st.image(translated_img, caption="Translated Image",
|
| 1347 |
|
| 1348 |
elif operation == "Shearing":
|
| 1349 |
st.markdown("### Shearing Parameters")
|
|
@@ -1352,7 +1352,7 @@ cv2.destroyAllWindows()
|
|
| 1352 |
if st.button("Apply Shearing"):
|
| 1353 |
shear_mat = np.float32([[1, sh_x, 0], [sh_y, 1, 0]])
|
| 1354 |
sheared_img = cv2.warpAffine(img, shear_mat, (img.shape[1], img.shape[0]))
|
| 1355 |
-
st.image(sheared_img, caption="Sheared Image",
|
| 1356 |
|
| 1357 |
elif operation == "Rotation":
|
| 1358 |
st.markdown("### Rotation Parameters")
|
|
@@ -1361,7 +1361,7 @@ cv2.destroyAllWindows()
|
|
| 1361 |
center = (img.shape[1] // 2, img.shape[0] // 2)
|
| 1362 |
rot_mat = cv2.getRotationMatrix2D(center, angle, 1.0)
|
| 1363 |
rotated_img = cv2.warpAffine(img, rot_mat, (img.shape[1], img.shape[0]))
|
| 1364 |
-
st.image(rotated_img, caption="Rotated Image",
|
| 1365 |
|
| 1366 |
else:
|
| 1367 |
st.warning("Please upload an image file to continue.")
|
|
|
|
| 1309 |
file_bytes = np.asarray(bytearray(uploaded_file.read()), dtype=np.uint8)
|
| 1310 |
img = cv2.imdecode(file_bytes, 1)
|
| 1311 |
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
| 1312 |
+
st.image(img, caption="Uploaded Image", use_container_width=True)
|
| 1313 |
|
| 1314 |
# Choose operation
|
| 1315 |
st.markdown("### Choose Transformation")
|
|
|
|
| 1326 |
y2 = st.number_input("Y2 (End Row)", min_value=y1 + 1, value=img.shape[0], step=1)
|
| 1327 |
if st.button("Apply Cropping"):
|
| 1328 |
cropped_img = img[y1:y2, x1:x2]
|
| 1329 |
+
st.image(cropped_img, caption="Cropped Image", use_container_width=True)
|
| 1330 |
|
| 1331 |
elif operation == "Scaling":
|
| 1332 |
st.markdown("### Scaling Parameters")
|
|
|
|
| 1334 |
scale_y = st.slider("Scale Y", 0.1, 3.0, 1.0, step=0.1)
|
| 1335 |
if st.button("Apply Scaling"):
|
| 1336 |
scaled_img = cv2.resize(img, None, fx=scale_x, fy=scale_y, interpolation=cv2.INTER_LINEAR)
|
| 1337 |
+
st.image(scaled_img, caption="Scaled Image", use_container_width=True)
|
| 1338 |
|
| 1339 |
elif operation == "Translation":
|
| 1340 |
st.markdown("### Translation Parameters")
|
|
|
|
| 1343 |
if st.button("Apply Translation"):
|
| 1344 |
t_mat = np.float32([[1, 0, tx], [0, 1, ty]])
|
| 1345 |
translated_img = cv2.warpAffine(img, t_mat, (img.shape[1], img.shape[0]))
|
| 1346 |
+
st.image(translated_img, caption="Translated Image", use_container_width=True)
|
| 1347 |
|
| 1348 |
elif operation == "Shearing":
|
| 1349 |
st.markdown("### Shearing Parameters")
|
|
|
|
| 1352 |
if st.button("Apply Shearing"):
|
| 1353 |
shear_mat = np.float32([[1, sh_x, 0], [sh_y, 1, 0]])
|
| 1354 |
sheared_img = cv2.warpAffine(img, shear_mat, (img.shape[1], img.shape[0]))
|
| 1355 |
+
st.image(sheared_img, caption="Sheared Image", use_container_width=True)
|
| 1356 |
|
| 1357 |
elif operation == "Rotation":
|
| 1358 |
st.markdown("### Rotation Parameters")
|
|
|
|
| 1361 |
center = (img.shape[1] // 2, img.shape[0] // 2)
|
| 1362 |
rot_mat = cv2.getRotationMatrix2D(center, angle, 1.0)
|
| 1363 |
rotated_img = cv2.warpAffine(img, rot_mat, (img.shape[1], img.shape[0]))
|
| 1364 |
+
st.image(rotated_img, caption="Rotated Image", use_container_width=True)
|
| 1365 |
|
| 1366 |
else:
|
| 1367 |
st.warning("Please upload an image file to continue.")
|