Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,8 @@ import albumentations as A
|
|
5 |
import random
|
6 |
|
7 |
def apply_augmentations(image, flip_h, flip_v, rotate, crop, gray, scale,
|
8 |
-
prob_flip_h, prob_flip_v, prob_rotate, prob_crop, prob_gray, prob_scale
|
|
|
9 |
augmentations = []
|
10 |
|
11 |
if flip_h:
|
@@ -13,7 +14,7 @@ def apply_augmentations(image, flip_h, flip_v, rotate, crop, gray, scale,
|
|
13 |
if flip_v:
|
14 |
augmentations.append(A.VerticalFlip(p=float(prob_flip_v)))
|
15 |
if rotate:
|
16 |
-
augmentations.append(A.Rotate(limit=
|
17 |
if crop:
|
18 |
augmentations.append(A.RandomResizedCrop(
|
19 |
size=(image.shape[0], image.shape[1]),
|
@@ -89,6 +90,7 @@ def main():
|
|
89 |
with gr.Column():
|
90 |
rotate = gr.Checkbox(label="Rotate")
|
91 |
prob_rotate = gr.Slider(minimum=0, maximum=1, value=0.5, label="Probability")
|
|
|
92 |
|
93 |
with gr.Column():
|
94 |
crop = gr.Checkbox(label="Random Crop")
|
@@ -110,7 +112,8 @@ def main():
|
|
110 |
inputs=[
|
111 |
input_image,
|
112 |
flip_h, flip_v, rotate, crop, gray, scale,
|
113 |
-
prob_flip_h, prob_flip_v, prob_rotate, prob_crop, prob_gray, prob_scale
|
|
|
114 |
],
|
115 |
outputs=output_image
|
116 |
)
|
|
|
5 |
import random
|
6 |
|
7 |
def apply_augmentations(image, flip_h, flip_v, rotate, crop, gray, scale,
|
8 |
+
prob_flip_h, prob_flip_v, prob_rotate, prob_crop, prob_gray, prob_scale,
|
9 |
+
rotation_limit):
|
10 |
augmentations = []
|
11 |
|
12 |
if flip_h:
|
|
|
14 |
if flip_v:
|
15 |
augmentations.append(A.VerticalFlip(p=float(prob_flip_v)))
|
16 |
if rotate:
|
17 |
+
augmentations.append(A.Rotate(limit=(-rotation_limit, rotation_limit), p=float(prob_rotate)))
|
18 |
if crop:
|
19 |
augmentations.append(A.RandomResizedCrop(
|
20 |
size=(image.shape[0], image.shape[1]),
|
|
|
90 |
with gr.Column():
|
91 |
rotate = gr.Checkbox(label="Rotate")
|
92 |
prob_rotate = gr.Slider(minimum=0, maximum=1, value=0.5, label="Probability")
|
93 |
+
rotation_limit = gr.Slider(minimum=0, maximum=90, value=10, label="Rotation Limit (±degrees)")
|
94 |
|
95 |
with gr.Column():
|
96 |
crop = gr.Checkbox(label="Random Crop")
|
|
|
112 |
inputs=[
|
113 |
input_image,
|
114 |
flip_h, flip_v, rotate, crop, gray, scale,
|
115 |
+
prob_flip_h, prob_flip_v, prob_rotate, prob_crop, prob_gray, prob_scale,
|
116 |
+
rotation_limit
|
117 |
],
|
118 |
outputs=output_image
|
119 |
)
|