Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -107,8 +107,8 @@ def translation(img,n=5):
|
|
| 107 |
ty=np.random.randint(1,45)
|
| 108 |
tm=np.array([[1,0,tx],[0,1,ty]],dtype=np.float32)
|
| 109 |
trans_img=cv2.warpAffine(img,tm,dsize=(img.shape[1],img.shape[0]),borderMode=cv2.BORDER_REFLECT)
|
| 110 |
-
img_trans_rgb = cv2.cvtColor(trans_img, cv2.COLOR_BGR2RGB)
|
| 111 |
-
save_image_and_show(
|
| 112 |
#st.image(img_trans_rgb, caption="Translation Applied", use_container_width=True)
|
| 113 |
|
| 114 |
def rotation(img,n=5):
|
|
@@ -128,8 +128,8 @@ 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(
|
| 132 |
-
ty=np.random.randint(1,
|
| 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)
|
|
@@ -140,10 +140,10 @@ def shearing(img,n=5):
|
|
| 140 |
for i in range(n):
|
| 141 |
sx=np.round(np.random.uniform(1,1.5),2)
|
| 142 |
shx=np.round(np.random.uniform(0,0.5),2)
|
| 143 |
-
tx=np.random.randint(
|
| 144 |
shy=np.round(np.random.uniform(0,0.5),2)
|
| 145 |
sy=np.round(np.random.uniform(0,0.5),2)
|
| 146 |
-
ty=np.random.randint(1,
|
| 147 |
shm=np.array([[sx,shx,tx],[shy,sy,ty]],dtype=np.float32)
|
| 148 |
img_all=cv2.warpAffine(img,shm,(img.shape[1],img.shape[0]))
|
| 149 |
save_image_and_show(img_all)
|
|
|
|
| 107 |
ty=np.random.randint(1,45)
|
| 108 |
tm=np.array([[1,0,tx],[0,1,ty]],dtype=np.float32)
|
| 109 |
trans_img=cv2.warpAffine(img,tm,dsize=(img.shape[1],img.shape[0]),borderMode=cv2.BORDER_REFLECT)
|
| 110 |
+
#img_trans_rgb = cv2.cvtColor(trans_img, cv2.COLOR_BGR2RGB)
|
| 111 |
+
save_image_and_show(trans_img)
|
| 112 |
#st.image(img_trans_rgb, caption="Translation Applied", use_container_width=True)
|
| 113 |
|
| 114 |
def rotation(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(1,16)
|
| 132 |
+
ty=np.random.randint(1,12)
|
| 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)
|
|
|
|
| 140 |
for i in range(n):
|
| 141 |
sx=np.round(np.random.uniform(1,1.5),2)
|
| 142 |
shx=np.round(np.random.uniform(0,0.5),2)
|
| 143 |
+
tx=np.random.randint(1,15)
|
| 144 |
shy=np.round(np.random.uniform(0,0.5),2)
|
| 145 |
sy=np.round(np.random.uniform(0,0.5),2)
|
| 146 |
+
ty=np.random.randint(1,20)
|
| 147 |
shm=np.array([[sx,shx,tx],[shy,sy,ty]],dtype=np.float32)
|
| 148 |
img_all=cv2.warpAffine(img,shm,(img.shape[1],img.shape[0]))
|
| 149 |
save_image_and_show(img_all)
|