DeepAI is a prominently popular platform for artificial intelligence. They provide research, guides, news, and several AI APIs.
You can learn more about their APIs from this link: https://deepai.org/apis
The range and depth of the APIs offered by DeepAI are quite astounding. They include APIs which allow for image colorization, facial recognition, nudity detection, sentiment, and emotion detection, text summarization, pose detection, text/caption generation, OCR, text to image, signature verification, toonify (to turn images into cartoon-like drawings), content moderation, anonymization and MANY more – the complete list is pretty staggering! Chances are DeepAI has something to satisfy your needs for adding and using artificial intelligence to integrate it with IDE Software for Windows, desktop, and mobile apps.
We’re going to focus on one API in particular – the Super Resolution API.
Table of Contents
What is Super Resolution API?
In this article, we are going to implement the “Super Resolution API” using Delphi. This API uses machine learning to clean, sharp and upscale photos with out losing the original content. It can correct blurry images to some accepted level. This is not a simple mathematical algorithm to upscale image, but a machine learning which identify the content and make it better without losing original content. So it’s always better than an image processing application in your PC.
How to get DeepAI API key?
It’s easy to get the API key. You don’t need an Credit card. You will get $5 USD API credits free at registration which equivalent to 10,000 API requests. After that you can pay by $0.50 USD per 1000 requests. You can signup with google account or a regular signup. Then go to Dashboard and you can find the API key. You can use that key for any API.
How to send a request to Super Resolution API from Delphi?
There are two types of requests depending on,
- Send image as URL
- Send image as file
Parameters are the same for both requests.
- api-key: API key as header parameter
- image: Image to process
Code to send the API request using REST components are like this:
[crayon-67434319e5dd6666335822/]You can send images in most of image file types, but the response always will be a JPG file.
How to process the response from the Super Resolution API?
If the request is success, you will get a response in JSON like this:
[crayon-67434319e5ddf423336542/]ID is the unique id of your processed resource. “output_url” is the URL of your processed image. We can parse this JSON in Delphi like this and get the image as TPicture:
[crayon-67434319e5de2037327021/]It can take a while to process the image and send the response. So it’s recommended to use a thread to prevent from blocking the GUI.
You can download this demo application to see how it works. Just grab the API key form DeepAI, upload an image and start processing.
You can download the example code here: https://github.com/checkdigits/SuperResolutionAPI_example