maximuspowers commited on
Commit
8e64ae4
1 Parent(s): 7dce4c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -3,14 +3,13 @@ import albumentations as A
3
  import cv2
4
  import numpy as np
5
 
6
- def augment_image(image, flip=False, rotate=0, brightness=1.0, noise=0, elastic=False, alpha=1.0, sigma=50):
7
  image = np.array(image)
8
 
9
  aug_list = []
10
  if flip: aug_list.append(A.HorizontalFlip(p=1.0))
11
  if rotate: aug_list.append(A.Rotate(limit=rotate, p=1.0))
12
  if brightness != 1.0: aug_list.append(A.RandomBrightnessContrast(brightness_limit=(brightness-1, brightness-1), p=1.0))
13
- if noise > 0: aug_list.append(A.GaussNoise(var_limit=(noise, noise), p=1.0))
14
  if elastic: aug_list.append(A.ElasticTransform(alpha=alpha, sigma=sigma, alpha_affine=None, p=1.0))
15
 
16
  aug = A.Compose(aug_list)
@@ -18,8 +17,8 @@ def augment_image(image, flip=False, rotate=0, brightness=1.0, noise=0, elastic=
18
 
19
  return augmented["image"]
20
 
21
- def image_augmentor_interface(image, flip, rotate, brightness, noise, elastic, alpha, sigma):
22
- augmented_image = augment_image(image, flip, rotate, brightness, noise, elastic, alpha, sigma)
23
  return augmented_image
24
 
25
  iface = gr.Interface(
@@ -29,7 +28,6 @@ iface = gr.Interface(
29
  gr.Checkbox(label="Flip Horizontally"),
30
  gr.Slider(0, 360, label="Rotate Degrees"),
31
  gr.Slider(0.5, 1.5, step=0.1, value=1, label="Brightness Adjustment"),
32
- gr.Slider(0, 100, step=1, label="Noise Scale"),
33
  gr.Checkbox(label="Elastic Distortion"),
34
  gr.Slider(1.0, 200.0, step=1.0, label="Elastic Alpha (distortion intensity)"),
35
  gr.Slider(1.0, 100.0, step=1.0, label="Elastic Sigma (smoothness)")
 
3
  import cv2
4
  import numpy as np
5
 
6
+ def augment_image(image, flip=False, rotate=0, brightness=1.0, elastic=False, alpha=1.0, sigma=50):
7
  image = np.array(image)
8
 
9
  aug_list = []
10
  if flip: aug_list.append(A.HorizontalFlip(p=1.0))
11
  if rotate: aug_list.append(A.Rotate(limit=rotate, p=1.0))
12
  if brightness != 1.0: aug_list.append(A.RandomBrightnessContrast(brightness_limit=(brightness-1, brightness-1), p=1.0))
 
13
  if elastic: aug_list.append(A.ElasticTransform(alpha=alpha, sigma=sigma, alpha_affine=None, p=1.0))
14
 
15
  aug = A.Compose(aug_list)
 
17
 
18
  return augmented["image"]
19
 
20
+ def image_augmentor_interface(image, flip, rotate, brightness, elastic, alpha, sigma):
21
+ augmented_image = augment_image(image, flip, rotate, brightness, elastic, alpha, sigma)
22
  return augmented_image
23
 
24
  iface = gr.Interface(
 
28
  gr.Checkbox(label="Flip Horizontally"),
29
  gr.Slider(0, 360, label="Rotate Degrees"),
30
  gr.Slider(0.5, 1.5, step=0.1, value=1, label="Brightness Adjustment"),
 
31
  gr.Checkbox(label="Elastic Distortion"),
32
  gr.Slider(1.0, 200.0, step=1.0, label="Elastic Alpha (distortion intensity)"),
33
  gr.Slider(1.0, 100.0, step=1.0, label="Elastic Sigma (smoothness)")