Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,6 +60,24 @@ crop=st.checkbox("Crop")
|
|
| 60 |
|
| 61 |
btn=st.button("Preview Image")
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
def translation(img):
|
| 65 |
tx=30 #np.random.randint(2,60)
|
|
@@ -68,7 +86,7 @@ def translation(img):
|
|
| 68 |
trans_img=cv2.warpAffine(img,tm,dsize=(img.shape[1],img.shape[0]),borderMode=cv2.BORDER_REFLECT)
|
| 69 |
img_trans_rgb = cv2.cvtColor(trans_img, cv2.COLOR_BGR2RGB)
|
| 70 |
save_image(img_trans_rgb)
|
| 71 |
-
st.image(img_trans_rgb, caption="Translation Applied", use_container_width=True)
|
| 72 |
|
| 73 |
def rotation(img):
|
| 74 |
#center = (width//2, height//2)
|
|
@@ -117,14 +135,6 @@ def cropping(img):
|
|
| 117 |
# st.success(f"Image saved to {image_path}")
|
| 118 |
|
| 119 |
|
| 120 |
-
def save_image(image, folder_name="output_images"):
|
| 121 |
-
image_name = f"image_{len(os.listdir(folder_name)) + 1}.jpg"
|
| 122 |
-
#image_path = os.path.join(folder_name, image_name)
|
| 123 |
-
path=f"output_images/{image_name}"
|
| 124 |
-
cv2.imwrite(path, image)
|
| 125 |
-
|
| 126 |
-
st.success(f"Image saved to {path}")
|
| 127 |
-
|
| 128 |
|
| 129 |
if uploaded_file is not None:
|
| 130 |
# Converting the image into array
|
|
|
|
| 60 |
|
| 61 |
btn=st.button("Preview Image")
|
| 62 |
|
| 63 |
+
def save_image_and_show(image, folder_name="output_images"):
|
| 64 |
+
if not os.path.exists(folder_name):
|
| 65 |
+
os.makedirs(folder_name)
|
| 66 |
+
|
| 67 |
+
image_name = f"image_{len(os.listdir(folder_name)) + 1}.jpg"
|
| 68 |
+
image_path = os.path.join(folder_name, image_name)
|
| 69 |
+
|
| 70 |
+
# Save the image
|
| 71 |
+
cv2.imwrite(image_path, image)
|
| 72 |
+
|
| 73 |
+
# Show success message
|
| 74 |
+
st.success(f"Image saved to {image_path} (local path)")
|
| 75 |
+
|
| 76 |
+
# Show the image to the user (not the path)
|
| 77 |
+
st.image(image, caption="Saved Image", channels="BGR")
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
|
| 81 |
|
| 82 |
def translation(img):
|
| 83 |
tx=30 #np.random.randint(2,60)
|
|
|
|
| 86 |
trans_img=cv2.warpAffine(img,tm,dsize=(img.shape[1],img.shape[0]),borderMode=cv2.BORDER_REFLECT)
|
| 87 |
img_trans_rgb = cv2.cvtColor(trans_img, cv2.COLOR_BGR2RGB)
|
| 88 |
save_image(img_trans_rgb)
|
| 89 |
+
#st.image(img_trans_rgb, caption="Translation Applied", use_container_width=True)
|
| 90 |
|
| 91 |
def rotation(img):
|
| 92 |
#center = (width//2, height//2)
|
|
|
|
| 135 |
# st.success(f"Image saved to {image_path}")
|
| 136 |
|
| 137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
if uploaded_file is not None:
|
| 140 |
# Converting the image into array
|