A simple web application built with Flask that allows users to upload and enhance their images using the Real-ESRGAN neural network for high-quality upscaling.
Users can register, log in, and view their enhanced images in a personal gallery. The backend uses PyTorch, SQLAlchemy, and OpenCV, with image enhancement powered by Real-ESRGAN.
Follow these steps to run the Real-ESRGAN Flask app inside a Docker container with GPU support.
Before running, make sure you have:
- 🐳 Docker installed
Install Docker - 💪 NVIDIA GPU drivers installed on your system
- 🔧 NVIDIA Container Toolkit (for GPU access in Docker)
Installation guide: NVIDIA Container Toolkit Docs
To verify that Docker sees your GPU, run: docker run --rm --gpus all nvidia/cuda:12.1.0-base-ubuntu22.04 nvidia-smi If you see your GPU info (driver version, memory, etc.) — you’re good to go!
Download the Real-ESRGAN model file and place it in the models/ folder: https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth
In the project root directory, create a .env file containing your secret key: SECRET_KEY=some-random-secret-key
This key is used by Flask for session encryption — make sure it stays private.
Run the following command in the root of the project: docker-compose up -d --build
Once running, open: http://localhost:5000
- 🐳 Fully containerized with Docker Compose
- 🧍 User authentication (register, login, logout)
- 🖼️ Image upload and automatic verification (JPEG and PNG only)
- ⚙️ Image enhancement using Real-ESRGAN (x4 upscaling)
- 💾 SQLite database integration via SQLAlchemy ORM
- 🗂️ Separation of uploaded and enhanced image storage
- 🔒 Password hashing with Flask-Bcrypt
- 🧩 Template-based frontend (HTML + Flask templates)
| Layer | Technology |
|---|---|
| Backend | Flask (Python) |
| Deep Learning | Real-ESRGAN (RRDBNet) |
| Database | SQLite + SQLAlchemy |
| Frontend | Flask Templates (HTML, Jinja2) |
| Auth | Flask-Login |
| Image Processing | OpenCV, Pillow |
| Environment | Python 3.9+ |
-
User registration/login Users can create an account and securely log in using hashed passwords.
-
Image upload Uploaded files are verified with Pillow (
PIL.Image.verify()) to prevent invalid or corrupted inputs. -
Image enhancement Real-ESRGAN processes the image via the
RealESRGANer.enhance()method, performing x4 super-resolution. -
Result storage Both original and enhanced images are saved in separate folders and linked to the user in the SQLite database.
-
Gallery view Logged-in users can see all their previously enhanced images on the home page.
