lint commited on
Commit
1e8ea80
1 Parent(s): 3919aa1

Upload folder using huggingface_hub

Browse files
Dockerfile ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10
2
+
3
+ WORKDIR /code
4
+
5
+ COPY ./requirements.txt /code/requirements.txt
6
+
7
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
+
9
+ # Set up a new user named "user" with user ID 1000
10
+ RUN useradd -m -u 1000 user
11
+ # Switch to the "user" user
12
+ USER user
13
+ # Set home to the user's home directory
14
+ ENV HOME=/home/user \
15
+ PATH=/home/user/.local/bin:$PATH
16
+
17
+ # Set the working directory to the user's home directory
18
+ WORKDIR $HOME/app
19
+
20
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
21
+ COPY --chown=user . $HOME/app
22
+
23
+ CMD ["lite", "demo.yaml", "launch", "--server_name", "0.0.0.0", "--server_port", "7860"]
__pycache__/__init__.cpython-310.pyc ADDED
Binary file (143 Bytes). View file
 
__pycache__/gradify.cpython-310.pyc ADDED
Binary file (1.06 kB). View file
 
demo.yaml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ lite_metadata:
2
+ gradio_version: 3.32.0
3
+ class_string: gradio.interface.Interface
4
+ kwargs:
5
+ title: Gradio Webapp
6
+ description: Given a pil image, apply a sepia filter
7
+ article: null
8
+ thumbnail: null
9
+ theme: gradio/seafoam
10
+ css: null
11
+ allow_flagging: never
12
+ inputs:
13
+ class_string: liteobj.listify
14
+ args:
15
+ - class_string: gradio.components.Image
16
+ kwargs:
17
+ label: image
18
+ type: pil
19
+ outputs:
20
+ class_string: liteobj.listify
21
+ args:
22
+ - class_string: gradio.components.Image
23
+ kwargs:
24
+ label: output
25
+ type: pil
26
+ fn:
27
+ class_string: gradify.gradify_closure
28
+ kwargs:
29
+ argmaps:
30
+ class_string: liteobj.listify
31
+ args:
32
+ - label: image
33
+ postprocessing: null
34
+ func_kwargs: {}
35
+ ldict:
36
+ class_string: gradify.exec_to_dict
37
+ kwargs:
38
+ source: "from PIL import Image\n\n\ndef apply_sepia_filter(image):\n \
39
+ \ width, height = image.size\n for x in range(width):\n for\
40
+ \ y in range(height):\n r, g, b = image.getpixel((x, y))\n\
41
+ \ new_r = int(r * 0.393 + g * 0.769 + b * 0.189)\n \
42
+ \ new_g = int(r * 0.349 + g * 0.686 + b * 0.168)\n new_b\
43
+ \ = int(r * 0.272 + g * 0.534 + b * 0.131)\n image.putpixel((x,\
44
+ \ y), (new_r, new_g, new_b))\n return image\n"
gradify.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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):
8
+ func = ldict.pop(k)
9
+ break
10
+
11
+ globals().update(ldict)
12
+ func_kwargs = dict(func_kwargs)
13
+
14
+ def gradify_func(*args):
15
+
16
+ try:
17
+ for (arg, argmap) in zip(args, argmaps):
18
+
19
+ postprocessing = argmap.get("postprocessing", None)
20
+ if postprocessing:
21
+ arg = eval(postprocessing)(arg)
22
+
23
+ kw_label = argmap["label"]
24
+ func_kwargs[kw_label] = arg
25
+
26
+ return func(**func_kwargs)
27
+ except Exception as e:
28
+ import gradio as gr
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
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio==3.32
2
+ liteobj==0.0.4