Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker support #850

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
outputs/
weights/
inputs/
experiments/
assets/
.github/
.vscode/
options/
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,42 @@ Other recommended projects:<br>

---

### 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.
Expand Down