Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -66,6 +66,7 @@ def translation(img):
|
|
| 66 |
tm=np.array([[1,0,tx],[0,1,ty]],dtype=np.float32)
|
| 67 |
trans_img=cv2.warpAffine(img,tm,dsize=(img.shape[1],img.shape[0]),borderMode=cv2.BORDER_REFLECT)
|
| 68 |
img_trans_rgb = cv2.cvtColor(trans_img, cv2.COLOR_BGR2RGB)
|
|
|
|
| 69 |
st.image(img_trans_rgb, caption="Translation Applied", use_container_width=True)
|
| 70 |
|
| 71 |
def rotation(img):
|
|
@@ -105,6 +106,15 @@ def cropping(img):
|
|
| 105 |
img_crop_rgb=cv2.cvtColor(img_crop,cv2.COLOR_BGR2RGB)
|
| 106 |
st.image(img_crop_rgb, caption="Shearing Applied", use_container_width=True)
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
if uploaded_file is not None:
|
| 110 |
# Converting the image into array
|
|
|
|
| 66 |
tm=np.array([[1,0,tx],[0,1,ty]],dtype=np.float32)
|
| 67 |
trans_img=cv2.warpAffine(img,tm,dsize=(img.shape[1],img.shape[0]),borderMode=cv2.BORDER_REFLECT)
|
| 68 |
img_trans_rgb = cv2.cvtColor(trans_img, cv2.COLOR_BGR2RGB)
|
| 69 |
+
save_image(img_trans_rgb)
|
| 70 |
st.image(img_trans_rgb, caption="Translation Applied", use_container_width=True)
|
| 71 |
|
| 72 |
def rotation(img):
|
|
|
|
| 106 |
img_crop_rgb=cv2.cvtColor(img_crop,cv2.COLOR_BGR2RGB)
|
| 107 |
st.image(img_crop_rgb, caption="Shearing Applied", use_container_width=True)
|
| 108 |
|
| 109 |
+
def save_image(image, folder_name="output_images"):
|
| 110 |
+
if not os.path.exists(folder_name):
|
| 111 |
+
os.makedirs(folder_name)
|
| 112 |
+
|
| 113 |
+
image_name = f"image_{len(os.listdir(folder_name)) + 1}.jpg"
|
| 114 |
+
image_path = os.path.join(folder_name, image_name)
|
| 115 |
+
cv2.imwrite(image_path, image)
|
| 116 |
+
st.success(f"Image saved to {image_path}")
|
| 117 |
+
|
| 118 |
|
| 119 |
if uploaded_file is not None:
|
| 120 |
# Converting the image into array
|