diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..78bdbb7a1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +outputs/ +weights/ +inputs/ +experiments/ +assets/ +.github/ +.vscode/ +options/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..5bc3a0c68 --- /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 -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" ] 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.