Dabs commited on
Commit
ccca1fa
1 Parent(s): 4cb4ee2

bug in calculations

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -2,15 +2,17 @@ import numpy as np
2
 
3
  import gradio as gr
4
 
5
- def quantize(val, n):
6
- return (np.round(n * val / 255) * 255).astype(np.uint8)
 
 
7
 
8
 
9
- def sepia(n, input_img):
10
- output_img = [quantize(val, n) for val in input_img]
11
  return output_img
12
 
13
 
14
- iface = gr.Interface(sepia, ["number", "image"], "pil")
15
 
16
  iface.launch()
 
2
 
3
  import gradio as gr
4
 
5
+ def quantize(val, factor):
6
+ quantized = (np.round(factor * np.array(val / 255)) * (255 / factor)).astype(int)
7
+ # print(val / 255, factor, factor * np.array(val / 255))
8
+ return quantized
9
 
10
 
11
+ def sepia(factor, input_img):
12
+ output_img = [quantize(np.array(val), factor) for val in input_img]
13
  return output_img
14
 
15
 
16
+ iface = gr.Interface(sepia, [gr.inputs.Slider(1, 10, 1), "image"], "pil")
17
 
18
  iface.launch()