Spaces:
Paused
Paused
| FROM nvidia/cuda:11.7.1-cudnn8-devel-ubuntu22.04 | |
| ENV DEBIAN_FRONTEND noninteractive | |
| # Install Python 3.9 and required packages | |
| RUN apt-get update && \ | |
| apt-get install -y python3.9 python3.9-dev python3-pip && \ | |
| apt-get clean && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Set Python 3.9 as the default | |
| RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 | |
| # Install pip for Python 3.9 | |
| RUN wget https://bootstrap.pypa.io/get-pip.py && \ | |
| python3.9 get-pip.py && \ | |
| rm get-pip.py | |
| # Set up a new user named "user" with user ID 1000 | |
| RUN useradd -m -u 1000 user | |
| # Switch to the "user" user | |
| USER user | |
| # Set home to the user's home directory | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Set the working directory to the user's home directory | |
| WORKDIR $HOME/app | |
| # Clone your repository or add your code to the container | |
| RUN git clone -b dev https://github.com/camenduru/DiffBIR $HOME/app | |
| # Install PyTorch and torchvision with a specific CUDA toolkit version | |
| RUN pip3 install torch==1.12.1+cu113 torchvision==0.13.1+cu113 -f https://download.pytorch.org/whl/torch_stable.html | |
| # Install Python dependencies | |
| RUN pip3 install -q einops pytorch_lightning gradio omegaconf xformers==0.0.20 transformers lpips opencv-python | |
| # Install open_clip from GitHub | |
| RUN pip3 install -q git+https://github.com/mlfoundations/open_clip@v2.20.0 | |
| # Use sudo to install aria2 with elevated privileges | |
| USER root | |
| RUN apt-get update && apt-get install -y sudo wget libgl1-mesa-glx && \ | |
| wget https://github.com/aria2/aria2/releases/download/release-1.36.0/aria2-1.36.0.tar.gz && \ | |
| tar -xzvf aria2-1.36.0.tar.gz && \ | |
| cd aria2-1.36.0 && \ | |
| ./configure && \ | |
| make && \ | |
| make install && \ | |
| cd .. && \ | |
| rm -rf aria2-1.36.0 && \ | |
| rm aria2-1.36.0.tar.gz | |
| # Switch back to the "user" user | |
| USER user | |
| # Download checkpoint files using aria2 | |
| RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lxq007/DiffBIR/resolve/main/general_full_v1.ckpt -d $HOME/app/models -o general_full_v1.ckpt | |
| RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lxq007/DiffBIR/resolve/main/general_swinir_v1.ckpt -d $HOME/app/models -o general_swinir_v1.ckpt | |
| # Expose any necessary ports (if your application requires it) | |
| # EXPOSE 80 | |
| RUN find $HOME/app | |
| # Define the command to run your application | |
| CMD ["python", "gradio_diffbir.py", "--ckpt", "/home/user/app/models/general_full_v1.ckpt", "--config", "/home/user/app/configs/model/cldm.yaml", "--reload_swinir", "--swinir_ckpt", "/home/user/app/models/general_swinir_v1.ckpt"] |