Spaces:
Sleeping
Sleeping
Commit
·
6b2d3c7
1
Parent(s):
b184f0f
update
Browse files- Dockerfile +28 -0
- app.py +16 -0
- run.sh +34 -0
Dockerfile
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM continuumio/anaconda3:main
|
2 |
+
|
3 |
+
# WORKDIR /code
|
4 |
+
|
5 |
+
# Create the environment using the environment.yml file
|
6 |
+
RUN conda create -n gradio python=3.11 -y
|
7 |
+
|
8 |
+
# Set up a new user named "user" with user ID 1000
|
9 |
+
RUN useradd -m -u 1000 user
|
10 |
+
# Switch to the "user" user
|
11 |
+
USER user
|
12 |
+
# Set home to the user's home directory
|
13 |
+
ENV HOME=/home/user \
|
14 |
+
PYTHONPATH=$HOME/app \
|
15 |
+
PYTHONUNBUFFERED=1 \
|
16 |
+
GRADIO_ALLOW_FLAGGING=never \
|
17 |
+
GRADIO_NUM_PORTS=1 \
|
18 |
+
GRADIO_SERVER_NAME=0.0.0.0 \
|
19 |
+
GRADIO_THEME=huggingface \
|
20 |
+
SYSTEM=spaces
|
21 |
+
|
22 |
+
# Set the working directory to the user's home directory
|
23 |
+
WORKDIR $HOME/app
|
24 |
+
|
25 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
26 |
+
COPY --chown=user . $HOME/app
|
27 |
+
|
28 |
+
CMD ["./run.sh"]
|
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
|
4 |
+
def update(name):
|
5 |
+
return f"Welcome to Gradio, {name}!"
|
6 |
+
|
7 |
+
|
8 |
+
with gr.Blocks() as demo:
|
9 |
+
gr.Markdown("Start typing below and then click **Run** to see the output.")
|
10 |
+
with gr.Row():
|
11 |
+
inp = gr.Textbox(placeholder="What is your name?")
|
12 |
+
out = gr.Textbox()
|
13 |
+
btn = gr.Button("Run")
|
14 |
+
btn.click(fn=update, inputs=inp, outputs=out)
|
15 |
+
|
16 |
+
demo.launch()
|
run.sh
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
set -e # stop on error
|
3 |
+
|
4 |
+
eval "$(conda shell.bash hook)"
|
5 |
+
|
6 |
+
ENV_NAME="matgen-plus"
|
7 |
+
PYTHON_VER="3.11"
|
8 |
+
|
9 |
+
# Create env and install packages only if it doesn't exist
|
10 |
+
if ! conda env list | grep -q "^${ENV_NAME}\s"; then
|
11 |
+
echo "Creating conda environment: $ENV_NAME"
|
12 |
+
conda create -y -n "$ENV_NAME" python="$PYTHON_VER"
|
13 |
+
conda activate "$ENV_NAME"
|
14 |
+
|
15 |
+
echo "Installing packages in $ENV_NAME..."
|
16 |
+
|
17 |
+
# pip installs
|
18 |
+
pip install diffusers["torch"] transformers accelerate xformers
|
19 |
+
pip install gradio controlnet-aux
|
20 |
+
pip install trimesh xatlas scikit-learn opencv-python omegaconf
|
21 |
+
|
22 |
+
# conda installs
|
23 |
+
# conda install -y pytorch3d -c pytorch -c conda-forge
|
24 |
+
# conda install -y -c conda-forge open-clip-torch pytorch-lightning
|
25 |
+
|
26 |
+
python app.py
|
27 |
+
|
28 |
+
else
|
29 |
+
echo "Conda environment '$ENV_NAME' already exists."
|
30 |
+
conda activate "$ENV_NAME"
|
31 |
+
fi
|
32 |
+
|
33 |
+
# Run the app
|
34 |
+
# python app.py
|