Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- demo.yaml +12 -11
- gradify.py +3 -3
demo.yaml
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
lite_metadata:
|
2 |
-
gradio_version: 3.
|
3 |
liteobj_version: 0.0.7
|
4 |
class_string: gradio.interface.Interface
|
5 |
kwargs:
|
@@ -11,26 +11,27 @@ kwargs:
|
|
11 |
css: null
|
12 |
allow_flagging: never
|
13 |
inputs:
|
14 |
-
- class_string: gradio.components.Image
|
15 |
kwargs:
|
16 |
label: image
|
17 |
type: pil
|
18 |
outputs:
|
19 |
-
- class_string: gradio.components.Image
|
20 |
kwargs:
|
21 |
label: output
|
22 |
type: pil
|
23 |
fn:
|
24 |
-
class_string: gradify.
|
25 |
kwargs:
|
26 |
argmaps:
|
27 |
- label: image
|
28 |
postprocessing: null
|
29 |
func_kwargs: {}
|
30 |
-
source: "from PIL import Image\n\
|
31 |
-
\ height = image.size\n
|
32 |
-
\ r, g, b =
|
33 |
-
\ 0.393
|
34 |
-
\ 0.686
|
35 |
-
\ 0.131)\n
|
36 |
-
\ image\
|
|
|
|
1 |
lite_metadata:
|
2 |
+
gradio_version: 3.36.1
|
3 |
liteobj_version: 0.0.7
|
4 |
class_string: gradio.interface.Interface
|
5 |
kwargs:
|
|
|
11 |
css: null
|
12 |
allow_flagging: never
|
13 |
inputs:
|
14 |
+
- class_string: gradio.components.image.Image
|
15 |
kwargs:
|
16 |
label: image
|
17 |
type: pil
|
18 |
outputs:
|
19 |
+
- class_string: gradio.components.image.Image
|
20 |
kwargs:
|
21 |
label: output
|
22 |
type: pil
|
23 |
fn:
|
24 |
+
class_string: gradify.closure
|
25 |
kwargs:
|
26 |
argmaps:
|
27 |
- label: image
|
28 |
postprocessing: null
|
29 |
func_kwargs: {}
|
30 |
+
source: "from PIL import Image\n\ndef apply_sepia_filter(image):\n width,\
|
31 |
+
\ height = image.size\n pixels = image.load()\n for i in range(width):\n\
|
32 |
+
\ for j in range(height):\n r, g, b = pixels[i, j]\n \
|
33 |
+
\ tr = int(0.393 * r + 0.769 * g + 0.189 * b)\n tg = int(0.349\
|
34 |
+
\ * r + 0.686 * g + 0.168 * b)\n tb = int(0.272 * r + 0.534 * g\
|
35 |
+
\ + 0.131 * b)\n pixels[i, j] = (min(tr, 255), min(tg, 255), min(tb,\
|
36 |
+
\ 255))\n return image\nimage = Image.open('input_image.jpg')\nsepia_image\
|
37 |
+
\ = apply_sepia_filter(image)\nsepia_image.show()"
|
gradify.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
|
2 |
|
3 |
-
def
|
4 |
|
5 |
ldict = {}
|
6 |
exec(source, globals(), ldict)
|
@@ -14,7 +14,7 @@ def gradify_closure(source, argmaps, func_kwargs={}):
|
|
14 |
globals().update(ldict)
|
15 |
func_kwargs = dict(func_kwargs)
|
16 |
|
17 |
-
def
|
18 |
|
19 |
try:
|
20 |
for (arg, argmap) in zip(args, argmaps):
|
@@ -31,4 +31,4 @@ def gradify_closure(source, argmaps, func_kwargs={}):
|
|
31 |
import gradio as gr
|
32 |
raise gr.Error(f"Error: {e}")
|
33 |
|
34 |
-
return
|
|
|
1 |
|
2 |
|
3 |
+
def closure(source, argmaps, func_kwargs={}):
|
4 |
|
5 |
ldict = {}
|
6 |
exec(source, globals(), ldict)
|
|
|
14 |
globals().update(ldict)
|
15 |
func_kwargs = dict(func_kwargs)
|
16 |
|
17 |
+
def gradio_func(*args):
|
18 |
|
19 |
try:
|
20 |
for (arg, argmap) in zip(args, argmaps):
|
|
|
31 |
import gradio as gr
|
32 |
raise gr.Error(f"Error: {e}")
|
33 |
|
34 |
+
return gradio_func
|