Rolando Andrade
Back to Content

IMG Processing AI Features

Use the IMG Processing API for AI: generate images with Stable Diffusion, classify them with ResNet 50, ask LLaVA questions about a picture, remove backgrounds.

· 3 min read
IMG Processing AI Features

In this tutorial, one cat goes through every AI feature of IMG Processing. We create the cat with AI, ask the AI what it is, write a caption for it and remove its background.

In the last two posts about IMG Processing, I showed you how to use the API with the HTTP endpoints and with the Node.js SDK. Today, let’s look at the AI features and how to use them.

One cat, four AI endpoints
One cat, four AI endpoints

Create an account first

The first step is to create an account.

IMG Processing IMG Processing - Image Processing API. A picture is worth a thousand words. Integrate powerful image processing capabilities into your applications in minutes img-processing.com

As soon as you sign up for the IMG Processing API, you get a test API key. An API key is a secret code that lets you make requests to the API.

Generate an image

Now that we have an API key, the first AI feature is image generation. It uses Stable Diffusion, a model that creates images from text. It performs well, and it competes in quality and price with almost every solution on the internet, like DALL-E 3 and Midjourney.

Cat image created using the IMG Processing imagine endpoint
Cat image created using the IMG Processing imagine endpoint

The endpoint to generate images is /v1/images/imagine. It receives a name, a prompt and an inverse prompt. The prompt describes what you want. The inverse prompt describes what you do not want. Try it with your favorite tool or directly on the playground:

Imagine Image - IMG Processing Creates a new image using AI docs.img-processing.com

We can check the new image with the download endpoint or in the dashboard:

As you can see, it generated a cat image of 1024x1024 pixels.

Ask what is in the image

To add labels to an image, or to find out what it shows, use the endpoint /v1/images/{imageId}/classify. It uses ResNet-50, an image recognition model. It sorts an image into one of 1000 labels with high accuracy.

Image Classification - IMG Processing Classifies the image giving a list of labels and their probabilities docs.img-processing.com

We gave it the cat we generated with AI. It identified the cat as a Tabby with a score of 62%, which is correct. The downside of this model is its limit of 1000 labels. The world has many more things than that.

For more complex images, you may prefer a newer model like Uform-Gen or LLaVA. With these models, you can ask questions about an image and get answers. For example, we can ask the AI what the image shows with the endpoint /v1/images/{imageId}/visualize.

Visualize Image - IMG Processing Answer a prompt based on the content of an image. docs.img-processing.com

We asked the AI In a single word. What is featured in this image?, and it answered correctly with cat. From here, it is up to your imagination. You can use it in any way you like. For example, let’s use it to write a caption:

Awesome, isn’t it?

Remove the background

Background removal is one of the main features of IMG Processing. It is one of the best on the internet in quality and price. It costs 50 times less than tools like RemoveBG, and the results are awesome. Let’s see it:

Remove Image Background - IMG Processing Remove the background from an image. docs.img-processing.com

As you can see, it returned a PNG image. Let’s download it:

Nice, the download worked. Here is the result:

That is it. We removed the background of the image in an easy, fast and cheap way.

What comes next

These are all the AI features available right now. I have plans for more:

  1. A background blur effect, using the separate layers I already get from background removal.
  2. Better OCR, which reads text in images. The visualize endpoint works okay, but it hallucinates, which means it sometimes makes things up.
  3. More models for classification, image generation and background removal.
  4. Image variations, and more.

For now, thanks for reading, and I hope you enjoy this tutorial!


If you enjoy the content, please don’t hesitate to subscribe and leave a comment! I would love to connect with you and hear your thoughts on the topics I cover.

Interested in working together? Check out my services and pricing to see how we can collaborate on your next project. Let's Build