jingyangcarl commited on
Commit
f6013d4
Β·
1 Parent(s): fe5848d
Files changed (5) hide show
  1. Dockerfile +53 -0
  2. README.md +3 -3
  3. app.py +17 -0
  4. environment.yml +7 -0
  5. run.sh +9 -0
Dockerfile ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM continuumio/anaconda3:main
2
+
3
+ WORKDIR /code
4
+ COPY ./environment.yml /code/environment.yml
5
+
6
+ # Create the environment using the environment.yml file
7
+ RUN conda env create -f /code/environment.yml
8
+
9
+ # install pip packages to the gradio environment
10
+ # when adjusting the dockerfile on huggingface:
11
+ # - if the dockerfile is successfully compileds, a new space need to be initialized and push the changes accordingly
12
+ # - otherwise, you can commit to the failed build dockerfile for debugging
13
+ RUN conda run -n gradio pip install --upgrade pip
14
+ # RUN conda run -n gradio pip install diffusers["torch"] transformers accelerate xformers
15
+ # RUN conda run -n gradio pip install gradio
16
+ # RUN conda run -n gradio pip install controlnet-aux
17
+ # RUN conda install -n gradio pytorch3d -c pytorch3d -c conda-forge
18
+ # RUN conda install -n gradio -c conda-forge open-clip-torch pytorch-lightning
19
+ # RUN conda run -n gradio pip install trimesh xatlas scikit-learn opencv-python omegaconf
20
+
21
+ # Set the environment variable to use the gradio environment by default
22
+ # RUN echo "source activate gradio" > ~/.bashrc
23
+ # ENV PATH /opt/conda/envs/gradio/bin:$PATH
24
+
25
+ # Set up a new user named "user" with user ID 1000
26
+ RUN useradd -m -u 1000 user
27
+ # Switch to the "user" user
28
+ USER user
29
+
30
+ RUN conda create -n gradio-user python=3.11
31
+ RUN conda run -n gradio-user pip install --upgrade pip
32
+ RUN conda run -n gradio-user pip install diffusers["torch"] transformers accelerate xformers
33
+ RUN conda run -n gradio-user pip install gradio
34
+ RUN conda run -n gradio-user pip install controlnet-aux
35
+ RUN conda install -n gradio-user pytorch3d -c pytorch3d -c conda-forge
36
+ RUN conda install -n gradio-user -c conda-forge open-clip-torch pytorch-lightning
37
+ RUN conda run -n gradio-user pip install trimesh xatlas scikit-learn opencv-python omegaconf
38
+
39
+ # Set home to the user's home directory
40
+ ENV HOME=/home/user \
41
+ PYTHONPATH=$HOME/app \
42
+ PYTHONUNBUFFERED=1 \
43
+ GRADIO_ALLOW_FLAGGING=never \
44
+ GRADIO_SERVER_NAME=0.0.0.0 \
45
+ GRADIO_THEME=huggingface \
46
+ SYSTEM=spaces
47
+ # Set the working directory to the user's home directory
48
+ WORKDIR $HOME/app
49
+
50
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
51
+ COPY --chown=user . $HOME/app
52
+
53
+ CMD ["./run.sh"]
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
- title: Docker Test20
3
- emoji: πŸ“Š
4
  colorFrom: pink
5
- colorTo: indigo
6
  sdk: docker
7
  pinned: false
8
  ---
 
1
  ---
2
+ title: Docker Test6
3
+ emoji: πŸ‘€
4
  colorFrom: pink
5
+ colorTo: pink
6
  sdk: docker
7
  pinned: false
8
  ---
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+
4
+
5
+ def update(name):
6
+ return f"Welcome to Gradio, {name}!"
7
+
8
+
9
+ with gr.Blocks() as demo:
10
+ gr.Markdown("Start typing below and then click **Run** to see the output.")
11
+ with gr.Row():
12
+ inp = gr.Textbox(placeholder="What is your name?")
13
+ out = gr.Textbox()
14
+ btn = gr.Button("Run")
15
+ btn.click(fn=update, inputs=inp, outputs=out)
16
+
17
+ demo.launch()
environment.yml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ name: gradio
2
+ channels:
3
+ - conda-forge
4
+ - defaults
5
+ dependencies:
6
+ - python=3.11
7
+ - gradio
run.sh ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ CONDA_ENV=$(head -1 /code/environment.yml | cut -d" " -f2)
4
+ eval "$(conda shell.bash hook)"
5
+ conda activate gradio-user
6
+
7
+ # Start app.py
8
+ echo "Starting app.py..."
9
+ python app.py