From c8a7d7ccdb1e724a9bc271f279d2add185a6f44a Mon Sep 17 00:00:00 2001 From: adriabama06 Date: Sat, 28 Sep 2024 20:01:03 +0200 Subject: [PATCH 1/4] Add Docker support --- .dockerignore | 2 ++ Dockerfile | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..a497fc492 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +# Make sure user won't build real-esrgan image with the output folder +outputs/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..8e03ed63f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM python:3.8.20-bookworm + +# Fix: ImportError: libGL.so.1: cannot open shared object file: No such file or directory +RUN apt-get update -y && apt-get -y install ffmpeg libsm6 libxext6 + +# Copy files from source to the container +COPY . /Real-ESRGAN + +# Set root at Real-ESRGAN +WORKDIR /Real-ESRGAN + +# Create the outputs folder +RUN mkdir -p outputs + +# Install pip ffmpeg +RUN pip install ffmpeg-python + +# Install PyTorch +RUN pip install torch==1.7.0+cu110 torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html + +# Install torchvision +RUN pip install https://download.pytorch.org/whl/cu110/torchvision-0.8.0-cp38-cp38-linux_x86_64.whl + +# Install basicsr +RUN pip install basicsr + +# Install facexlib +RUN pip install facexlib + +# Install gfpgan +RUN pip install gfpgan + +# Install all remain packages +RUN pip install -r requirements.txt + +# Setup develop +RUN python setup.py develop + +# Clean up all cached files +RUN pip cache purge && apt-get clean autoclean && apt-get autoremove --yes && rm -rf /var/lib/{apt,dpkg,cache,log}/ + +ENTRYPOINT [ "python" ] From 091f9637e3f3299c2677ce4e940ce5cea76e4bad Mon Sep 17 00:00:00 2001 From: adriabama06 Date: Sat, 28 Sep 2024 20:08:26 +0200 Subject: [PATCH 2/4] Add installation guide for Docker --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index f2fa0c1ae..57f2f0bf2 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,42 @@ Other recommended projects:
--- +### Installation with Docker + +*Note*: Only tested with Nvidia graphic card +- https://docs.docker.com/get-started/get-docker/ + +1. Clone repo + + ```bash + git clone https://github.com/xinntao/Real-ESRGAN.git + cd Real-ESRGAN + ``` + +1. Build Dockerfile + + ```bash + docker build -f Dockerfile . -t real-esrgan + ``` + +1. Run Real-ESRGAN inside Docker + + *Note:* On Windows change `-v ./inputs:/Real-ESRGAN/inputs -v ./outputs:/Real-ESRGAN/outputs -v ./weights:/Real-ESRGAN/weights` to `-v .\inputs:/Real-ESRGAN/inputs -v .\outputs:/Real-ESRGAN/outputs -v .\weights:/Real-ESRGAN/weights` + ```bash + docker run -it --gpus all -v ./inputs:/Real-ESRGAN/inputs -v ./outputs:/Real-ESRGAN/outputs -v ./weights:/Real-ESRGAN/weights --rm real-esrgan inference_realesrgan.py --help + ``` + ### Example + Inference a image + ```bash + docker run -it --gpus all -v ./inputs:/Real-ESRGAN/inputs -v ./outputs:/Real-ESRGAN/outputs -v ./weights:/Real-ESRGAN/weights --rm real-esrgan inference_realesrgan.py -i inputs/ADE_val_00000114.jpg -o outputs/ --ext png -n realesr-general-x4v3 + ``` + Inference a video + ```bash + docker run -it --gpus all -v ./inputs:/Real-ESRGAN/inputs -v ./outputs:/Real-ESRGAN/outputs -v ./weights:/Real-ESRGAN/weights --rm real-esrgan inference_realesrgan_video.py -i inputs/video/onepiece_demo.mp4 -o outputs/ -n realesr-animevideov3 + ``` + +--- + ## ⚡ Quick Inference There are usually three ways to inference Real-ESRGAN. From 04930b0a13b637af588ccdeba965e67647d0b83b Mon Sep 17 00:00:00 2001 From: adriabama06 Date: Sat, 28 Sep 2024 20:08:36 +0200 Subject: [PATCH 3/4] Remove torchaudio --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8e03ed63f..5bc3a0c68 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ RUN mkdir -p outputs RUN pip install ffmpeg-python # Install PyTorch -RUN pip install torch==1.7.0+cu110 torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html +RUN pip install torch==1.7.0+cu110 -f https://download.pytorch.org/whl/torch_stable.html # Install torchvision RUN pip install https://download.pytorch.org/whl/cu110/torchvision-0.8.0-cp38-cp38-linux_x86_64.whl From 375c340ef649493ec8d4caa8fb7f82d5e3a6fa26 Mon Sep 17 00:00:00 2001 From: adriabama06 Date: Sat, 28 Sep 2024 20:20:20 +0200 Subject: [PATCH 4/4] ignore more files to make a lighter container --- .dockerignore | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index a497fc492..78bdbb7a1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,8 @@ -# Make sure user won't build real-esrgan image with the output folder outputs/ +weights/ +inputs/ +experiments/ +assets/ +.github/ +.vscode/ +options/