lint commited on
Commit
8585771
·
1 Parent(s): dc5879b

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. demo.yaml +12 -11
  2. gradify.py +3 -3
demo.yaml CHANGED
@@ -1,5 +1,5 @@
1
  lite_metadata:
2
- gradio_version: 3.32.0
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.gradify_closure
25
  kwargs:
26
  argmaps:
27
  - label: image
28
  postprocessing: null
29
  func_kwargs: {}
30
- source: "from PIL import Image\n\n\ndef apply_sepia_filter(image):\n width,\
31
- \ height = image.size\n for x in range(width):\n for y in range(height):\n\
32
- \ r, g, b = image.getpixel((x, y))\n new_r = int(r *\
33
- \ 0.393 + g * 0.769 + b * 0.189)\n new_g = int(r * 0.349 + g *\
34
- \ 0.686 + b * 0.168)\n new_b = int(r * 0.272 + g * 0.534 + b *\
35
- \ 0.131)\n image.putpixel((x, y), (new_r, new_g, new_b))\n return\
36
- \ image\n"
 
 
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 gradify_closure(source, argmaps, func_kwargs={}):
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 gradify_func(*args):
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 gradify_func
 
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