Spaces:
Runtime error
Runtime error
bug in calculations
Browse files
app.py
CHANGED
|
@@ -2,15 +2,17 @@ import numpy as np
|
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
-
def quantize(val,
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
-
def sepia(
|
| 10 |
-
output_img = [quantize(val,
|
| 11 |
return output_img
|
| 12 |
|
| 13 |
|
| 14 |
-
iface = gr.Interface(sepia, [
|
| 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()
|