lint commited on
Commit
cfe01af
·
1 Parent(s): ec5eb18

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. Dockerfile +23 -0
  2. __pycache__/gradify.cpython-310.pyc +0 -0
  3. demo.yaml +44 -0
  4. gradify.py +34 -0
  5. requirements.txt +2 -0
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__/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
+ liteobj_version: 0.0.7
4
+ class_string: gradio.interface.Interface
5
+ kwargs:
6
+ title: tetrisfoto01
7
+ description: create tetris foto
8
+ article: null
9
+ thumbnail: null
10
+ theme: gradio/seafoam
11
+ css: null
12
+ allow_flagging: never
13
+ inputs:
14
+ - class_string: gradio.components.Number
15
+ kwargs:
16
+ label: rows
17
+ precision: 0
18
+ - class_string: gradio.components.Number
19
+ kwargs:
20
+ label: cols
21
+ precision: 0
22
+ - class_string: gradio.components.Dataframe
23
+ kwargs:
24
+ label: blocks
25
+ type: array
26
+ outputs:
27
+ - class_string: gradio.components.Dataframe
28
+ kwargs:
29
+ label: output
30
+ type: array
31
+ fn:
32
+ class_string: gradify.gradify_closure
33
+ kwargs:
34
+ argmaps:
35
+ - label: rows
36
+ postprocessing: null
37
+ - label: cols
38
+ postprocessing: null
39
+ - label: blocks
40
+ postprocessing: 'lambda array: [list(map(int, row)) for row in array]'
41
+ func_kwargs: {}
42
+ source: "def create_tetris_foto(rows, cols, blocks):\n foto = [[' ' for _\
43
+ \ in range(cols)] for _ in range(rows)]\n for block in blocks:\n \
44
+ \ row, col = block\n foto[row][col] = 'X'\n return foto"
gradify.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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):
11
+ func = ldict.pop(k)
12
+ break
13
+
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):
21
+
22
+ postprocessing = argmap.get("postprocessing", None)
23
+ if postprocessing:
24
+ arg = eval(postprocessing)(arg)
25
+
26
+ kw_label = argmap["label"]
27
+ func_kwargs[kw_label] = arg
28
+
29
+ return func(**func_kwargs)
30
+ except Exception as e:
31
+ import gradio as gr
32
+ raise gr.Error(f"Error: {e}")
33
+
34
+ return gradify_func
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio==3.32
2
+ liteobj==0.0.7