Supercharge Your Image Resolution with Real-ESRGAN: A Complete Guide
Tags: tutorial, beginners, ai, machinelearning
Published: 2023-05-27 13:01:14

Have you ever felt the frustration of a brilliant image destroyed by low resolution? A photo from an old phone, a screenshot gone wrong, or a valuable archival image, the promise of high-quality marred by [pixellation](https://notes.aimodels.fyi/comparing-gfpgan-and-codeformer-a-deep-dive-into-ai-face-restoration/)? Well, you're in luck. Enter Real-ESRGAN, an AI model that offers high-quality image enhancement, even for those incredibly low-res photos you thought were beyond rescue.

This guide will walk you through the magic of the Real-ESRGAN model, explain its inputs and outputs, and teach you how to use it step-by-step to solve your image resolution nightmares. And hey, it's not just another model - Real-ESRGAN is ranked number 10 in popularity on [AIModels.fyi](http://AIModels.fyi), making it one of the go-to choices for image enhancement. And, as a cherry on top, we'll show you how to use [AIModels.fyi](http://AIModels.fyi) to find similar models and decide which one best suits your creative endeavours. So, buckle up and let's dive in!

## About the Real-ESRGAN

The Real-ESRGAN model, created by the skilled [NightmareAI](https://aimodels.fyi/creators/nightmareai), is a marvel in the world of image-to-image conversion. It's specifically designed to upscale images while maintaining (or even enhancing) their quality. ESRGAN stands for Enhanced Super-Resolution Generative Adversarial Network. In simple terms, it uses artificial intelligence to generate a high-resolution image from a low-resolution input, a process known as 'super-resolution'. You can find more details about the model on its [details page](https://www.aimodels.fyi/models/replicate/355).

What sets Real-ESRGAN apart is its option for face correction and adjustable upscale. So, if you have a pixelated selfie or a blurry family photo, Real-ESRGAN can not only enhance the overall image but can also apply specific enhancements to faces. This capability makes it perfect for revitalizing old photos, enhancing social media images, and more. With a cost of just $0.00605 per run and an average run time of only 11 seconds, Real-ESRGAN provides an affordable and efficient solution for image enhancement.

**Related:** [**Breathe New Life into Old Photos with AI: A Beginner’s Guide to GFPGAN**](https://notes.aimodels.fyi/breathe-new-life-into-old-photos-with-ai-a-beginners-guide-to-gfpgan/)

## How Real-ESRGAN Works - A Technical Overview

Let's delve a bit deeper into the nuts and bolts of Real-ESRGAN. The details here are sourced from the [original research paper](https://arxiv.org/pdf/2107.10833.pdf), in case you're interested in a more comprehensive read.

At its core, Real-ESRGAN aims to solve a problem in the domain of blind super-resolution, which is the process of enhancing low-resolution images that have been subjected to unknown and complex degradations. Simply put, its goal is to improve the quality of blurry or pixelated images.

One of the defining aspects of Real-ESRGAN is its training process. Unlike other models, it is trained with synthetic data, which is data that has been artificially created to mimic real-world scenarios. This doesn't mean the data is of lesser quality; it just means it's been created rather than collected from real-world images.

To simulate complex real-world degradations, Real-ESRGAN incorporates a high-order degradation modeling process. This allows the model to better account for the variety of ways an image might be degraded in a real-world setting.

Moreover, the model is designed to account for common artifacts that can occur during the image synthesis process, such as ringing and overshoot. These are disruptions that can affect the quality of the resulting image.

On top of these features, Real-ESRGAN uses a U-Net discriminator with spectral normalization. The discriminator's role is to distinguish between the model's outputs and real images. By using a U-Net architecture, the discriminator's ability is enhanced and the training dynamics are stabilized.

Through numerous comparisons, Real-ESRGAN has proven to perform exceptionally well on various real datasets, outperforming prior models in the domain of image enhancement.

Lastly, Real-ESRGAN can efficiently synthesize training pairs on the fly, adding an extra layer of efficiency to the whole process.

In summary, Real-ESRGAN works by leveraging advanced techniques and architectures to convert low-resolution images into high-quality ones. It's a potent blend of mathematics and computational power that brings this transformation to life.

## Understanding the Inputs and Outputs of Real-ESRGAN

Before we start enhancing our images, it's important to understand how to communicate with Real-ESRGAN, and that's through its inputs and outputs.

### Inputs

Real-ESRGAN accepts two types of inputs:

1. **Image file**: This is the image you want to enhance. Simply put, it's your low-resolution input image.
    
2. **Scale number**: This is the factor by which you want to scale your image. The default value is 4, but you can adjust it as per your needs.
    
3. **Face Enhance**: A boolean value (true/false). When set to true, the model applies specific enhancements to faces in the image.
    

### Outputs

The output of Real-ESRGAN is quite simple. It returns a string that represents a URI where you can find your enhanced image.

Now that we're familiar with how to talk to Real-ESRGAN let's move to the fun part - using it to enhance our images!

## A Step-by-Step Guide to Using Real-ESRGAN

It's time to witness the magic of AI-powered image enhancement. You can interact directly with the model's "demo" on Replicate via their UI

if you're not feeling like dealing with code right now. You can use [this link](https://replicate.com/nightmareai/real-esrgan/examples) to play with the model's parameters and get some quick feedback.

### Step 1: Install the Node.js client

First, we need to install the Replicate client for Node.js by running the following command:  
`npm install replicate`

### Step 2: Authenticate using your API token

Next, copy your API token and authenticate by setting it as an environment variable:  
`export REPLICATE_API_TOKEN=[token]`

### Step 3: Run the model

With everything set up, we're ready to run the model. Here's a simple example of how you can do it:

```javascript
import Replicate from "replicate";

const replicate = new Replicate({
  auth: process.env.REPLICATE_API_TOKEN,
});

const output = await replicate.run(
  "nightmareai/real-esrgan:42fed1c4974146d4d2414e2be2c5277c7fcf05fcc3a73abf41610695738c1d7b",
  {
    input: {
      image: "..." // replace with your image
    }
  }
);
```

### Setting a Webhook

If you want to get notified when your prediction is ready, you can specify a webhook URL. Here's how to do it:

```javascript
const prediction = await replicate.predictions.create({
  version: "42fed1c4974146d4d2414e2be2c5277c7fcf05fcc3a73abf41610695738c1d7b",
  input: {
    image: "..." // replace with your image
  },
  webhook: "https://example.com/your-webhook",
  webhook_events_filter: ["completed"]
});
```

## Taking it Further - Finding Other Image-to-Image Models with [AIModels.fyi](http://AIModels.fyi)

[AIModels.fyi](http://AIModels.fyi) is a goldmine for discovering AI models that cater to a wide range of needs. From image generation to image-to-image conversion, it offers a searchable, filterable, tagged database of all the models on Replicate. If you're interested in finding similar models to Real-ESRGAN, here's how to go about it:

### Step 1: Visit [AIModels.fyi](http://AIModels.fyi)

Head over to [AIModels.fyi](http://AIModels.fyi) to begin your search for similar models.

### Step 2: Use the Search Bar

Use the search bar at the top of the page to search for models with specific keywords, such as "super resolution" or "image enhancement". This will show you a list of models related to your search query.

### Step 3: Filter the Results

On the left side of the search results page, you'll find several filters that can help you narrow down the list of models. You can filter and sort by models by type (Image-to-Image, Text-to-Image, etc.), cost, popularity, or even specific creators.

![](https://notes.aimodels.fyi/content/images/2023/05/screenshotr_2023-5-27T8-51-34.png align="left")

*Finding additional Image-to-Image upscalers on* [*AIModels.fyi*](http://AIModels.fyi)

## Conclusion

In this guide, we dove deep into the workings of the Real-ESRGAN model, learned how to use it to enhance our images, and even explored how to find similar models using [AIModels.fyi](http://AIModels.fyi). We also discovered how to leverage the search and filter features in [AIModels.fyi](http://AIModels.fyi) to find models that best suit our needs, broadening our horizons in the world of AI-powered image enhancement.

I hope this guide has inspired you to explore the creative possibilities of AI and bring your imagination to life. Don't forget to subscribe for more tutorials, updates on new and improved AI models, and a wealth of inspiration for your

next creative project. You can stay updated on my latest musings on AI over on my [Twitter](https://twitter.com/mikeyoung44), and don't forget to check out more guides and resources at [notes.aimodels.fyi](http://notes.aimodels.fyi). Happy image enhancing, and here's to your journey into the world of AI with [AIModels.fyi](http://AIModels.fyi)!

<iframe src="https://aimodels.substack.com/embed" width="100%" height="auto" style="box-sizing:border-box;border:0px;display:block;overflow:hidden;width:720px;grid-column:main-start / main-end;margin-bottom:0px;margin-top:calc(1.6em*var(--content-spacing-multiplier, 1));color:rgb(21, 23, 26);font-family:Inter, -apple-system, "system-ui", "Segoe UI", Helvetica, Arial, sans-serif;font-size:18px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0px;text-transform:none;white-space:normal;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial"></iframe>

*Subscribe or follow me on* [*Twitter*](https://twitter.com/mikeyoung44) *for more content like this!*