Upload folder using huggingface_hub
Browse files- Dockerfile +13 -3
- __pycache__/__init__.cpython-310.pyc +0 -0
- __pycache__/gradify.cpython-310.pyc +0 -0
- demo.yaml +38 -15
- gradify.py +35 -0
- requirements.txt +2 -2
Dockerfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
FROM python:3.
|
2 |
|
3 |
WORKDIR /code
|
4 |
|
@@ -6,8 +6,18 @@ COPY ./requirements.txt /code/requirements.txt
|
|
6 |
|
7 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
8 |
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
|
|
|
|
|
|
|
|
|
12 |
|
13 |
CMD ["lite", "demo.yaml", "launch", "--server_name", "0.0.0.0", "--server_port", "7860"]
|
|
|
1 |
+
FROM python:3.10
|
2 |
|
3 |
WORKDIR /code
|
4 |
|
|
|
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 (941 Bytes). View file
|
|
demo.yaml
CHANGED
@@ -1,34 +1,57 @@
|
|
1 |
lite_metadata:
|
2 |
-
gradio_version: 3.
|
3 |
class_string: gradio.interface.Interface
|
4 |
kwargs:
|
5 |
-
title: Gradio Webapp
|
6 |
-
description: Given
|
7 |
-
|
8 |
article: null
|
9 |
thumbnail: null
|
10 |
theme: gradio/seafoam
|
11 |
css: null
|
12 |
-
allow_flagging:
|
13 |
inputs:
|
14 |
class_string: liteobj.listify
|
15 |
args:
|
16 |
-
- class_string: gradio.components.
|
17 |
kwargs:
|
18 |
-
label:
|
|
|
|
|
|
|
|
|
|
|
19 |
outputs:
|
20 |
class_string: liteobj.listify
|
21 |
args:
|
22 |
- class_string: gradio.components.Number
|
23 |
kwargs:
|
24 |
label: output
|
25 |
-
precision: 0
|
26 |
fn:
|
27 |
-
class_string:
|
28 |
kwargs:
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
lite_metadata:
|
2 |
+
gradio_version: 3.32.0
|
3 |
class_string: gradio.interface.Interface
|
4 |
kwargs:
|
5 |
+
title: Gradio Webapp
|
6 |
+
description: Given two sorted arrays nums1 and nums2 of size m and n respectively,
|
7 |
+
return the median of the two sorted arrays
|
8 |
article: null
|
9 |
thumbnail: null
|
10 |
theme: gradio/seafoam
|
11 |
css: null
|
12 |
+
allow_flagging: never
|
13 |
inputs:
|
14 |
class_string: liteobj.listify
|
15 |
args:
|
16 |
+
- class_string: gradio.components.Dataframe
|
17 |
kwargs:
|
18 |
+
label: nums1
|
19 |
+
type: array
|
20 |
+
- class_string: gradio.components.Dataframe
|
21 |
+
kwargs:
|
22 |
+
label: nums2
|
23 |
+
type: array
|
24 |
outputs:
|
25 |
class_string: liteobj.listify
|
26 |
args:
|
27 |
- class_string: gradio.components.Number
|
28 |
kwargs:
|
29 |
label: output
|
|
|
30 |
fn:
|
31 |
+
class_string: gradify.gradify_closure
|
32 |
kwargs:
|
33 |
+
argmaps:
|
34 |
+
class_string: liteobj.listify
|
35 |
+
args:
|
36 |
+
- label: nums1
|
37 |
+
postprocessing: 'lambda array: list(map(int, array[0]))'
|
38 |
+
- label: nums2
|
39 |
+
postprocessing: 'lambda array: list(map(int, array[0]))'
|
40 |
+
func_kwargs: {}
|
41 |
+
ldict:
|
42 |
+
class_string: gradify.exec_to_dict
|
43 |
+
kwargs:
|
44 |
+
source: "def func(nums1, nums2):\n m, n = len(nums1), len(nums2)\n \
|
45 |
+
\ if m > n:\n nums1, nums2, m, n = nums2, nums1, n, m\n i_min,\
|
46 |
+
\ i_max, half_len = 0, m, (m + n + 1) // 2\n while i_min <= i_max:\n\
|
47 |
+
\ i = (i_min + i_max) // 2\n j = half_len - i\n if\
|
48 |
+
\ i < m and nums2[j - 1] > nums1[i]:\n i_min = i + 1\n \
|
49 |
+
\ elif i > 0 and nums1[i - 1] > nums2[j]:\n i_max = i -\
|
50 |
+
\ 1\n else:\n if i == 0:\n max_of_left\
|
51 |
+
\ = nums2[j - 1]\n elif j == 0:\n max_of_left\
|
52 |
+
\ = nums1[i - 1]\n else:\n max_of_left = max(nums1[i\
|
53 |
+
\ - 1], nums2[j - 1])\n if (m + n) % 2 == 1:\n \
|
54 |
+
\ return max_of_left\n if i == m:\n min_of_right\
|
55 |
+
\ = nums2[j]\n elif j == n:\n min_of_right =\
|
56 |
+
\ nums1[i]\n else:\n min_of_right = min(nums1[i],\
|
57 |
+
\ nums2[j])\n return (max_of_left + min_of_right) / 2.0\n"
|
gradify.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
func = None
|
2 |
+
|
3 |
+
def gradify_closure(ldict, argmaps, func_kwargs={}):
|
4 |
+
|
5 |
+
globals().update(ldict)
|
6 |
+
func_kwargs = dict(func_kwargs)
|
7 |
+
|
8 |
+
def gradify_func(*args):
|
9 |
+
|
10 |
+
try:
|
11 |
+
for (arg, argmap) in zip(args, argmaps):
|
12 |
+
|
13 |
+
postprocessing = argmap.get("postprocessing", None)
|
14 |
+
if postprocessing:
|
15 |
+
arg = eval(postprocessing)(arg)
|
16 |
+
|
17 |
+
kw_label = argmap["label"]
|
18 |
+
func_kwargs[kw_label] = arg
|
19 |
+
|
20 |
+
return func(**func_kwargs)
|
21 |
+
except Exception as e:
|
22 |
+
import gradio as gr
|
23 |
+
raise gr.Error(f"Error: {e}")
|
24 |
+
|
25 |
+
return gradify_func
|
26 |
+
|
27 |
+
def exec_to_dict(source, target=None):
|
28 |
+
|
29 |
+
ldict = {}
|
30 |
+
exec(source, globals(), ldict)
|
31 |
+
|
32 |
+
if target:
|
33 |
+
return ldict.get(target, None)
|
34 |
+
|
35 |
+
return ldict
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
gradio==3.
|
2 |
-
liteobj==0.0.
|
|
|
1 |
+
gradio==3.32
|
2 |
+
liteobj==0.0.4
|