Real Esrgan - Face Enhancer

real-esrgan

Real Esrgan improves facial features and details in images, delivering crisp and realistic results.

T4 16GB
Fast Inference
REST API

Model Information

Response Time~16 sec
StatusActive
Version
0.0.1
Updated8 days ago

Prerequisites

  • Create an API Key from the Eachlabs Console
  • Install the required dependencies for your chosen language (e.g., requests for Python)

API Integration Steps

1. Create a Prediction

Send a POST request to create a new prediction. This will return a prediction ID that you'll use to check the result. The request should include your model inputs and API key.

import requests
import time
API_KEY = "YOUR_API_KEY" # Replace with your API key
HEADERS = {
"X-API-Key": API_KEY,
"Content-Type": "application/json"
}
def create_prediction():
response = requests.post(
"https://api.eachlabs.ai/v1/prediction/",
headers=HEADERS,
json={
"model": "real-esrgan",
"version": "0.0.1",
"input": {
"image": "your_file.image/jpeg",
"scale": "4",
"face_enhance": false
}
}
)
prediction = response.json()
if prediction["status"] != "success":
raise Exception(f"Prediction failed: {prediction}")
return prediction["predictionID"]

2. Get Prediction Result

Poll the prediction endpoint with the prediction ID until the result is ready. The API uses long-polling, so you'll need to repeatedly check until you receive a success status.

def get_prediction(prediction_id):
while True:
result = requests.get(
f"https://api.eachlabs.ai/v1/prediction/{prediction_id}",
headers=HEADERS
).json()
if result["status"] == "success":
return result
elif result["status"] == "error":
raise Exception(f"Prediction failed: {result}")
time.sleep(1) # Wait before polling again

3. Complete Example

Here's a complete example that puts it all together, including error handling and result processing. This shows how to create a prediction and wait for the result in a production environment.

try:
# Create prediction
prediction_id = create_prediction()
print(f"Prediction created: {prediction_id}")
# Get result
result = get_prediction(prediction_id)
print(f"Output URL: {result['output']}")
print(f"Processing time: {result['metrics']['predict_time']}s")
except Exception as e:
print(f"Error: {e}")

Additional Information

  • The API uses a two-step process: create prediction and poll for results
  • Response time: ~16 seconds
  • Rate limit: 60 requests/minute
  • Concurrent requests: 10 maximum
  • Use long-polling to check prediction status until completion

Overview

GFPGAN (Generative Facial Prior) is a powerful AI model designed to restore faces in images, particularly for repairing old, damaged, or low-quality photographs. Leveraging cutting-edge deep learning technology, GFPGAN reconstructs facial details with high accuracy while maintaining natural aesthetics.

Technical Specifications

  • Model Architecture:
    • Built on GAN architecture with pre-trained facial prior integration.
    • Refined loss functions to balance restoration and fidelity.
  • Input Requirements:
    • Resolution: Recommended input is up to 512x512 for optimal performance.
  • Output Features:
    • Restored images maintain original context and backgrounds.
    • Faces are enhanced with reconstructed features.

Key Considerations

Over-Restoration:

  • In some cases, the restored face might deviate slightly from the original.

Context Preservation:

  • Non-facial regions are minimally processed. Ensure the background meets the desired quality before input.

Data Preprocessing: Ensure that input images are properly aligned and cropped to focus on facial regions for optimal restoration results.

Tips & Tricks

Pre-Processing:

  • Crop images to focus on faces for better results.

Upscaling:

  • Combine GFPGAN with super-resolution tools like Real-ESRGAN for higher-quality results.
  • Parameter Settings:
    • Scale: Use a scale factor (e.g., 2 or 4) to control the upsampling level during restoration.
    • Version: Select the appropriate model version based on your quality requirements and system capabilities.

Capabilities

Face Restoration:

  • Repairs old, blurry, or degraded photographs with precision.

Detail Enhancement:

  • Reconstructs eyes, lips, and skin textures while preserving natural aesthetics.

Real-Time Performance:

  • Processes images quickly, even for complex restorations.

Integration:

  • Easily integrates with workflows for photo editing, animation, and digital art.

What can I use for?

Photo Restoration:

  • Revive old family photos or historical archives with clear, enhanced faces.

Content Creation:

  • Enhance facial features in digital art, animations, or social media posts.

AI-Assisted Editing:

  • Use GFPGAN as part of a broader image editing pipeline.

Things to be aware of

Restore Historical Photos:

  • Repair damaged or faded portraits with remarkable clarity.

Upscale Low-Quality Images:

  • Combine with tools like Real-ESRGAN for full-resolution restoration.

Test on Artistic Styles:

  • Experiment with restoring faces in paintings or digital artwork.

Batch Process Family Albums:

  • Restore multiple images simultaneously to save time.

Custom Model Training:

  • Fine-tune GFPGAN for specific restoration tasks or artistic styles.

Limitations

Non-Facial Regions:

  • Backgrounds and non-facial details are not significantly enhanced.

Extreme Damage:

  • Severely damaged faces may require additional manual editing.

Artistic Output:

  • In some cases, the restored faces might look slightly stylized or synthetic.


Output Format: PNG

Related AI Models

flux-depth-pro

Flux Depth Pro

flux-depth-pro

Image to Image
recraft-creative-upscale

Recraft Creative Upscale

recraft-creative-upscale

Image to Image
depth-anything

Depth Anything

depth-anything

Image to Image
recraft-clarity-upscale

Recraft Clarity Upcale

recraft-clarity-upscale

Image to Image