mischeiwiller commited on
Commit
8efad9d
1 Parent(s): 2a39662

fix variable bug

Browse files
Files changed (1) hide show
  1. app.py +29 -3
app.py CHANGED
@@ -20,11 +20,22 @@ def blur_pool2d_fn(file, blur_pool2d):
20
  img: Tensor = K.io.load_image(file.name, K.io.ImageLoadType.RGB32)
21
  img = img[None] # 1xCxHxW / fp32 / [0, 1]
22
 
23
- # apply tensor image enhancement
24
- x_out: Tensor = K.filters.blur_pool2d(x_out, int(blur_pool2d))
25
 
26
  return K.utils.tensor_to_image(x_out)
27
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  examples = [
30
  ["examples/monkey.jpg", 1, 1, 1, 1, 1],
@@ -59,10 +70,25 @@ blur_pool2d_fn_demo = gr.Interface(
59
  live=True
60
  )
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  demo = gr.TabbedInterface(
63
  [
64
  box_blur_fn_demo,
65
- blur_pool2d_fn_demo
 
66
  ],
67
  [
68
  "Box Blur",
 
20
  img: Tensor = K.io.load_image(file.name, K.io.ImageLoadType.RGB32)
21
  img = img[None] # 1xCxHxW / fp32 / [0, 1]
22
 
23
+ x_out: Tensor = K.filters.blur_pool2d(img, int(blur_pool2d))
 
24
 
25
  return K.utils.tensor_to_image(x_out)
26
 
27
+ def gaussian_blur_fn(file, gaussian_blur2d):
28
+ # load the image using the rust backend
29
+ img: Tensor = K.io.load_image(file.name, K.io.ImageLoadType.RGB32)
30
+ img = img[None] # 1xCxHxW / fp32 / [0, 1]
31
+
32
+ x_out: Tensor = K.filters.gaussian_blur2d(img,
33
+ (int(gaussian_blur2d), int(gaussian_blur2d)),
34
+ (float(gaussian_blur2d), float(gaussian_blur2d)))
35
+
36
+ return K.utils.tensor_to_image(x_out)
37
+
38
+
39
 
40
  examples = [
41
  ["examples/monkey.jpg", 1, 1, 1, 1, 1],
 
70
  live=True
71
  )
72
 
73
+ gaussian_blur_fn_demo = gr.Interface(
74
+ gaussian_blur_fn,
75
+ [
76
+ gr.inputs.Image(type="file"),
77
+ gr.inputs.Slider(minimum=1, maximum=21, step=2, default=1, label="Gaussian Blur")
78
+ ],
79
+ "image",
80
+ examples=examples,
81
+ # title=title,
82
+ # description=description,
83
+ # article=article,
84
+ live=True
85
+ )
86
+
87
  demo = gr.TabbedInterface(
88
  [
89
  box_blur_fn_demo,
90
+ blur_pool2d_fn_demo,
91
+ gaussian_blur_fn_demo
92
  ],
93
  [
94
  "Box Blur",