shubham680 commited on
Commit
b81affe
·
verified ·
1 Parent(s): 63a70a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -77,7 +77,7 @@ def save_image_and_show(image, folder_name="output_images"):
77
  st.success(f"Image saved to {image_path} (local path)")
78
 
79
  # Show the image to the user (not the path)
80
- st.image(image, caption="Saved Image", channels="RGB")
81
 
82
 
83
 
@@ -115,7 +115,7 @@ def rotation(img,n=5):
115
  for i in range(n):
116
  #center = (width//2, height//2)
117
  angle=np.random.choice([90, 180, -90])
118
- scale=np.round(np.random.uniform(1,2),2)
119
  r_x=img.shape[0]//2
120
  r_y=img.shape[1]//2
121
  rm=cv2.getRotationMatrix2D((r_y,r_x),angle,scale)
@@ -124,15 +124,17 @@ def rotation(img,n=5):
124
  save_image_and_show(r_img)
125
  #st.image(img_rot_rgb, caption="Rotation Applied", use_container_width=True)
126
 
127
- def scaling(img):
128
- sx=2
129
- sy=2
130
- tx=0
131
- ty=0
132
- sm=np.array([[sx,0,tx],[0,sy,ty]],dtype=np.float32)
133
- s_img=cv2.warpAffine(img,sm,(img.shape[1],img.shape[0]))
134
- img_scal_rgb=cv2.cvtColor(s_img,cv2.COLOR_BGR2RGB)
135
- st.image(img_scal_rgb, caption="Scaling Applied", use_container_width=True)
 
 
136
 
137
  def shearing(img):
138
  sx=1
 
77
  st.success(f"Image saved to {image_path} (local path)")
78
 
79
  # Show the image to the user (not the path)
80
+ st.image(image, caption="Saved Image", channels="BGR")
81
 
82
 
83
 
 
115
  for i in range(n):
116
  #center = (width//2, height//2)
117
  angle=np.random.choice([90, 180, -90])
118
+ scale=np.round(np.random.uniform(1,1.6),2)
119
  r_x=img.shape[0]//2
120
  r_y=img.shape[1]//2
121
  rm=cv2.getRotationMatrix2D((r_y,r_x),angle,scale)
 
124
  save_image_and_show(r_img)
125
  #st.image(img_rot_rgb, caption="Rotation Applied", use_container_width=True)
126
 
127
+ def scaling(img,n=5):
128
+ for i in range(n):
129
+ sx=np.round(np.random.uniform(1,1.6),2)
130
+ sy=np.round(np.random.uniform(1,1.6),2)
131
+ tx=np.random.randint(2,60)
132
+ ty=np.random.randint(1,50)
133
+ sm=np.array([[sx,0,tx],[0,sy,ty]],dtype=np.float32)
134
+ s_img=cv2.warpAffine(img,sm,(img.shape[1],img.shape[0]))
135
+ #img_scal_rgb=cv2.cvtColor(s_img,cv2.COLOR_BGR2RGB)
136
+ save_image_and_show(s_img)
137
+ #st.image(img_scal_rgb, caption="Scaling Applied", use_container_width=True)
138
 
139
  def shearing(img):
140
  sx=1