Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +23 -0
- __pycache__/__init__.cpython-310.pyc +0 -0
- __pycache__/gradify.cpython-310.pyc +0 -0
- demo.yaml +47 -0
- gradify.py +38 -0
- 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__/__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,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 findMedianSortedArrays(nums1, nums2):\n nums1.extend(nums2)\n\
|
45 |
+
\ nums1.sort()\n n = len(nums1)\n if n % 2 == 0:\n return\
|
46 |
+
\ (nums1[n // 2] + nums1[n // 2 - 1]) / 2\n else:\n return nums1[n\
|
47 |
+
\ // 2]\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
|