lint commited on
Commit
b1a938f
·
1 Parent(s): 934eae2

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. demo.yaml +7 -10
  2. gradify.py +4 -8
demo.yaml CHANGED
@@ -27,13 +27,10 @@ kwargs:
27
  - label: image
28
  postprocessing: null
29
  func_kwargs: {}
30
- ldict:
31
- class_string: gradify.exec_to_dict
32
- kwargs:
33
- source: "from PIL import Image\n\n\ndef apply_sepia_filter(image):\n \
34
- \ width, height = image.size\n for x in range(width):\n for\
35
- \ y in range(height):\n r, g, b = image.getpixel((x, y))\n\
36
- \ new_r = int(r * 0.393 + g * 0.769 + b * 0.189)\n \
37
- \ new_g = int(r * 0.349 + g * 0.686 + b * 0.168)\n new_b\
38
- \ = int(r * 0.272 + g * 0.534 + b * 0.131)\n image.putpixel((x,\
39
- \ y), (new_r, new_g, new_b))\n return image\n"
 
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"
 
 
 
gradify.py CHANGED
@@ -1,7 +1,10 @@
1
 
2
 
3
- def gradify_closure(ldict, argmaps, func_kwargs={}):
4
 
 
 
 
5
  from types import FunctionType
6
  for k, v in ldict.items():
7
  if isinstance(v, FunctionType):
@@ -29,10 +32,3 @@ def gradify_closure(ldict, argmaps, func_kwargs={}):
29
  raise gr.Error(f"Error: {e}")
30
 
31
  return gradify_func
32
-
33
- def exec_to_dict(source, target=None):
34
-
35
- ldict = {}
36
- exec(source, globals(), ldict)
37
-
38
- return ldict.get(target, None) if target else ldict
 
1
 
2
 
3
+ def gradify_closure(source, argmaps, func_kwargs={}):
4
 
5
+ ldict = {}
6
+ exec(source, globals(), ldict)
7
+
8
  from types import FunctionType
9
  for k, v in ldict.items():
10
  if isinstance(v, FunctionType):
 
32
  raise gr.Error(f"Error: {e}")
33
 
34
  return gradify_func