Upscale

Increase image resolution without compromising facial features

You will need an API token to send HTTP requests. See Authentication for instructions.

Quick start

Firstly, you'll need to upload the image you want to process. These parameters must be supplied as multipart form data:

ParameterExampleDescription
file@file.pngThe image file as form data.

Please note that we only support the following formats: WEBP, JPEG and PNG. Note down these fields from the response:

Response
{
  "id_image": "67762577...",   // IMAGE_ID
  "id_project": "67762577...", // PROJECT_ID
}

To upscale an image, you just have to call the provided endpoint. This will start asynchronous processes that will be handled in the next step.

This is an example of request containing all required fields to upscale the uploaded image to 4 times its original size:

Request
{
  "id_image": "67762577...",   // IMAGE_ID
  "id_project": "67762577...", // PROJECT_ID
  "scale_factor": "4",
  "output_format": "PNG",
  "mode": "s_upscaler",
  "face_enhancer": true
}
Response
{
  "eta": 60.00,
  "height": 512,
  "width": 512,
  "height_o": 2048.0,
  "width_o": 2048.0,
  "required_credits": 0.25
}

For more examples and options for the upscaling process, see Upscaling an image.

You can optionally make the API calculate time and credit estimates without starting a process. For that, see Estimating time and credits.


Notification objects returned by this endpoint will inform you of the end of a process on our servers. We recommend sending a request every 3 seconds at most, to not incur in rate limiting.

Request
{
  "name_list": ["superid"]
}

After the process is complete, you might see a similar response:

Response
{
  "notifications_list": [
    {
      "data": {
        "id_image": "67762577...",   // IMAGE_ID
        "id_project": "67762577...", // PROJECT_ID
        "link": {
          "l": "https://...",        
        },
      },
      "name": "superid",
    },
  ]
}

Where l points to the upscaling result image.

We recommend checking id_image and id_project when handling notifications, to ensure the correct link is used in case of parallel running processes.

Uploading a target image

Be careful!

All target images are deleted automatically after 24 hours of being uploaded. This action cannot be undone.

You can upload any image that satisfies all following constraints:

  • it must be encoded in one the following formats: WEBP, JPEG or PNG.
  • it must be larger than 64 by 64 pixels
  • the output image must be smaller than 8192 by 8192 pixels
import requests
from pprint import pprint

api_url = "https://api.piktid.com/api"
access_token = "your_access_token"
target_path = "path_to_image"


with open(target_path, "rb") as target:
    response = requests.post(
        api_url + "/superid/upload",
        headers={"Authorization": "Bearer " + access_token},
        files={
            "file": target,
        },
    ).json()

    pprint(response)

Upscaling an image

There are currently two operating modes for SuperID:

  • Super mode: optimized for maximum quality and detail.
  • Fast mode: designed for quick processing with slightly reduced precision.

To start an upscaling process, all that's needed is a call to the desired endpoint:

import requests
from pprint import pprint

api_url = "https://api.piktid.com/api"
access_token = "your_access_token"

image_id = "67762577...",   # IMAGE_ID
project_id = "67762577...", # PROJECT_ID

# Default params for upscaler (s_upscaler) mode, can be omitted from request
params = {
    "prompt": "",
    "creativity": 7,
    "fractality": 3,
    "fidelity": 5,
    "denoise": 1,
}

response = requests.post(
    api_url + "/superid/v2",
    headers={"Authorization": "Bearer " + access_token},
    json={
        "superid_type": "s_upscaler",
        "id_project": project_id,
        "id_image": image_id,
        "scale_factor": "4",
        "output_format": "PNG",
        "face_enhancer": True,
    } | params,
).json()

pprint(response)

The response will contain an estimation of the time and credits needed for the process that has just been started.

Response
{
  : 60.00,
  : 512,
  : 512,
  : 2048.0,
  : 2048.0,
  : 0.25
}

Enhancing and upscaling

Using the upscaler in "enhance" mode will let our model be more creative with the input image, sacrificing fidelity with more richness in details.

import requests
from pprint import pprint

api_url = "https://api.piktid.com/api"
access_token = "your_access_token"

image_id = "67762577...",   # IMAGE_ID
project_id = "67762577...", # PROJECT_ID

# Default params for enhancer (s_enhancer) mode, can be omitted from request
params = {
    "prompt": "",
    "creativity": 9,
    "fractality": 5,
    "fidelity": 3,
    "denoise": 1,
}

response = requests.post(
    api_url + "/superid/v2",
    headers={"Authorization": "Bearer " + access_token},
    json={
        "superid_type": "s_enhancer",
        "id_project": project_id,
        "id_image": image_id,
        "scale_factor": "4",
        "output_format": "PNG",
        "face_enhancer": False,
    } | params,
).json()

pprint(response)

The response will contain an estimation of the time and credits needed for the process that has just been started.

Response
{
  : 60.00,
  : 512,
  : 512,
  : 2048.0,
  : 2048.0,
  : 0.25
}

Waiting for results

Be careful!

Notifications are automatically deleted after exactly 10 minutes (600 seconds) from their creation.

Results are shared to clients via "notifications". Clients are expected to poll for notifications and handle them in the allowed time limit before they are automatically dismissed by the API.

import time
import requests
from pprint import pprint

api_url = "https://api.piktid.com/api"
access_token = "your_access_token"

project_id = "67762577..."


def process_notifications(response, project_id):
    for notification in response.get("notifications_list", []):
        if notification["name"] != "superid":
            return None, None

        if notification["data"]["id_project"] != project_id:
            return None, None

        return notification["data"], notification["id"]

    return None, None


def delete_notification(notification_id):
    requests.delete(
        api_url + "/notification/delete_json",
        headers={"Authorization": "Bearer " + access_token},
        json={"id": notification_id},
    )


# Loops for 20 minutes, even though upscaling images generally
# takes less time.
for _ in range(1200):
    response = requests.post(
        api_url + "/notification_by_name_json",
        headers={"Authorization": "Bearer " + access_token},
        json={"name_list": "superid,error"},
    ).json()

    data, notification_id = process_notifications(response, image_id)
    if data is not None:
        # Delete the notification to avoid reading it again
        delete_notification(notification_id)

        print(f"Project with ID {data['id_project']} finished upscaling!")
        pprint(data["link"])
        break

    time.sleep(1)

Estimating time and credits

You can always ask our API to estimate both credits and time required in advance, without having to start an upscaling process.

import requests
from pprint import pp as print

api_url = "https://api.piktid.com/api"
access_token = "your_access_token"

id_image = "67762577...",   # IMAGE_ID
id_project = "67762577...", # PROJECT_ID


response = requests.post(
    api_url + "/superid_get_info",
    headers={"Authorization": "Bearer " + access_token},
    json={
        "id_project": id_project,
        "id_image": id_image,
        "scale_factor": "4",
        "output_format": "PNG",
        "options": "{\"face_enhancer\": true}"
    },
).json()
print(response)

The response will contain an estimation of the time and credits needed for the process that has just been started.

Response
{
  : 60.00,
  : 512,
  : 512,
  : 2048.0,
  : 2048.0,
  : 0.25
}

Resuming a past project

You can retrieve the original image used in a past project whenever you wish, by using the provided endpoint:

import requests
from pprint import pprint

api_url = "https://api.piktid.com/api"
access_token = "your_access_token"

id_project = "67762577...", # PROJECT_ID


response = requests.post(
    api_url + "/retrieve_superid_project",
    headers={"Authorization": "Bearer " + access_token},
    json={
        "id_project": id_project
    },
).json()
pprint(response)