Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,32 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
-
from pathlib import Path
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
"data": None,
|
12 |
-
"is_file": True,
|
13 |
-
}
|
14 |
-
for file in DATA_PATH.glob("**/*")
|
15 |
-
if file.is_file()
|
16 |
-
]
|
17 |
-
usage = sum([f['size'] for f in files])
|
18 |
-
return files, f"{usage/(1024.0 ** 3):.3f}GB"
|
19 |
|
20 |
-
|
|
|
|
|
21 |
with gr.Row():
|
22 |
with gr.Column():
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
|
30 |
-
app.launch(allowed_paths=[str(DATA_PATH)])
|
|
|
1 |
+
import numpy as np
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
+
def sepia(input_img, strength):
|
5 |
+
sepia_filter = strength * np.array(
|
6 |
+
[[0.393, 0.769, 0.189], [0.349, 0.686, 0.168], [0.272, 0.534, 0.131]]
|
7 |
+
) + (1-strength) * np.identity(3)
|
8 |
+
sepia_img = input_img.dot(sepia_filter.T)
|
9 |
+
sepia_img /= sepia_img.max()
|
10 |
+
return sepia_img
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
callback = gr.CSVLogger()
|
13 |
+
|
14 |
+
with gr.Blocks() as demo:
|
15 |
with gr.Row():
|
16 |
with gr.Column():
|
17 |
+
img_input = gr.Image()
|
18 |
+
strength = gr.Slider(0, 1, 0.5)
|
19 |
+
img_output = gr.Image()
|
20 |
+
with gr.Row():
|
21 |
+
btn = gr.Button("Flag")
|
22 |
+
|
23 |
+
# This needs to be called at some point prior to the first call to callback.flag()
|
24 |
+
callback.setup([img_input, strength, img_output], "flagged_data_points")
|
25 |
+
|
26 |
+
img_input.change(sepia, [img_input, strength], img_output)
|
27 |
+
strength.change(sepia, [img_input, strength], img_output)
|
28 |
+
|
29 |
+
# We can choose which components to flag -- in this case, we'll flag all of them
|
30 |
+
btn.click(lambda *args: callback.flag(args), [img_input, strength, img_output], None, preprocess=False)
|
31 |
|
32 |
+
demo.launch()
|
|