mischeiwiller commited on
Commit
3caf593
1 Parent(s): e3c3f88

fix filter function names

Browse files
Files changed (1) hide show
  1. app.py +19 -4
app.py CHANGED
@@ -6,13 +6,12 @@ import kornia as K
6
  from kornia.core import Tensor
7
 
8
 
9
- def filters(file, blur_pool2d, box_blur, gaussian_blur2d, max_blur_pool2d, median_blur):
10
  # load the image using the rust backend
11
  img: Tensor = K.io.load_image(file.name, K.io.ImageLoadType.RGB32)
12
  img = img[None] # 1xCxHxW / fp32 / [0, 1]
13
 
14
  # apply tensor image enhancement
15
- x_out = K.filters.blur_pool2d(x_out, int(blur_pool2d))
16
  x_out: Tensor = K.filters.box_blur(img, (int(box_blur), int(box_blur)))
17
  x_out = K.filters.gaussian_blur2d(x_out,
18
  (int(gaussian_blur2d), int(gaussian_blur2d)),
@@ -22,6 +21,22 @@ def filters(file, blur_pool2d, box_blur, gaussian_blur2d, max_blur_pool2d, media
22
 
23
  return K.utils.tensor_to_image(x_out)
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  examples = [
27
  ["examples/monkey.jpg", 1, 1, 1, 1, 1],
@@ -29,7 +44,7 @@ examples = [
29
  ]
30
 
31
  without_downsampling_demo = gr.Interface(
32
- filters,
33
  [
34
  gr.inputs.Image(type="file"),
35
  gr.inputs.Slider(minimum=1, maximum=10, step=1, default=1, label="Box Blur"),
@@ -46,7 +61,7 @@ without_downsampling_demo = gr.Interface(
46
  )
47
 
48
  with_downsampling_demo = gr.Interface(
49
- filters,
50
  [
51
  gr.inputs.Image(type="file"),
52
  gr.inputs.Slider(minimum=1, maximum=10, step=1, default=1, label="Blur Pool"),
 
6
  from kornia.core import Tensor
7
 
8
 
9
+ def filters_without(file, blur_pool2d, box_blur, gaussian_blur2d, max_blur_pool2d, median_blur):
10
  # load the image using the rust backend
11
  img: Tensor = K.io.load_image(file.name, K.io.ImageLoadType.RGB32)
12
  img = img[None] # 1xCxHxW / fp32 / [0, 1]
13
 
14
  # apply tensor image enhancement
 
15
  x_out: Tensor = K.filters.box_blur(img, (int(box_blur), int(box_blur)))
16
  x_out = K.filters.gaussian_blur2d(x_out,
17
  (int(gaussian_blur2d), int(gaussian_blur2d)),
 
21
 
22
  return K.utils.tensor_to_image(x_out)
23
 
24
+ def filters_with(file, blur_pool2d, box_blur, gaussian_blur2d, max_blur_pool2d, median_blur):
25
+ # load the image using the rust backend
26
+ img: Tensor = K.io.load_image(file.name, K.io.ImageLoadType.RGB32)
27
+ img = img[None] # 1xCxHxW / fp32 / [0, 1]
28
+
29
+ # apply tensor image enhancement
30
+ x_out: Tensor = K.filters.blur_pool2d(x_out, int(blur_pool2d))
31
+ x_out = K.filters.box_blur(img, (int(box_blur), int(box_blur)))
32
+ x_out = K.filters.gaussian_blur2d(x_out,
33
+ (int(gaussian_blur2d), int(gaussian_blur2d)),
34
+ (float(gaussian_blur2d), float(gaussian_blur2d)))
35
+ x_out = K.filters.max_blur_pool2d(x_out, int(max_blur_pool2d))
36
+ x_out = K.filters.median_blur(x_out, (int(median_blur), int(median_blur)))
37
+
38
+ return K.utils.tensor_to_image(x_out)
39
+
40
 
41
  examples = [
42
  ["examples/monkey.jpg", 1, 1, 1, 1, 1],
 
44
  ]
45
 
46
  without_downsampling_demo = gr.Interface(
47
+ filters_without,
48
  [
49
  gr.inputs.Image(type="file"),
50
  gr.inputs.Slider(minimum=1, maximum=10, step=1, default=1, label="Box Blur"),
 
61
  )
62
 
63
  with_downsampling_demo = gr.Interface(
64
+ filters_with,
65
  [
66
  gr.inputs.Image(type="file"),
67
  gr.inputs.Slider(minimum=1, maximum=10, step=1, default=1, label="Blur Pool"),