Image Enhancer
High-resolution image enhancement powered by AI.
Before / After Example
Description
This application provides a simple web interface to enhance images using an AI upscaling model. Upload your low-resolution images and get high-resolution results.
Features
- Web UI for easy image uploading and enhancement.
- API endpoint for programmatic access (
/enhance
). - Selectable upscaling models and scale factors.
- Optional face enhancement.
- Input and output images are saved in
api_inputs
andapi_outputs
respectively.
Installation
Clone the repository:
git clone https://huggingface.co/sayed99/Image-Enhancer cd Image-Enhancer
Create Conda Environment: Set up the necessary environment using the provided
environment.yml
file:conda env create -f environment.yml conda activate esrgan-env
(Note: The environment name is defined within the
environment.yml
file)Download Model Weights: The required model weights (
.pth
files) need to be placed in theReal-ESRGAN/weights/
directory. Common models include:RealESRGAN_x4plus.pth
RealESRGAN_x2plus.pth
You can usually find these linked from the original Real-ESRGAN repository or other model sources.
Usage
Run the application using the provided script:
python run.py
This will:
- Start the backend API server (usually on
http://localhost:8000
). - Start the Streamlit web interface (usually on
http://localhost:8501
). - Open the web interface in your default browser.
Navigate to the web interface, upload an image, select your desired options (model, scale, face enhancement), and click "Enhance Image".
API Usage
You can also interact with the API directly.
Enhance Endpoint: POST /enhance/
Form Data:
file
: The image file to upload.model_name
(optional, default:RealESRGAN_x4plus
): Model to use (e.g.,RealESRGAN_x4plus
,RealESRGAN_x2plus
).outscale
(optional, default:4.0
): The desired output scale factor (e.g.,2.0
,4.0
).face_enhance
(optional, default:false
): Boolean flag to enable face enhancement.fp32
(optional, default:false
): Boolean flag to use FP32 precision.
Example using curl
:
curl -X POST "http://localhost:8000/enhance/" \
-F "file=@/path/to/your/image.jpg" \
-F "model_name=RealESRGAN_x4plus" \
-F "outscale=4.0" \
-o enhanced_image.jpg
Notes
- Ensure the API server is running before using the Streamlit app or sending direct API requests.
- The application uses significant resources (RAM, potentially GPU if configured).
- Input images are saved in the
api_inputs
directory. - Output images are saved in subdirectories within the
api_outputs
directory, named by a unique request ID.
Powered by Real-ESRGAN