Upscale API
The Upscale API provides functionality to increase the size of a given image by 2x or 4x. When upscaling to 2K, it applies stable diffusion-based creative upscale logic. However, for generating 4K images, it utilizes GAN-based upscale logic.
Authentication
header
X-Photio-Key : {PHOTIO_API_KEY}
Do you not have an API key yet?
To call the API, you first need to obtain a Photio API key. To get your API key, go to the API Dashboard. After registering your card, you can use the issued API key.
Request Body
Variable | Type | Require | Default | Description |
---|---|---|---|---|
image | string | ✓ | - | This can be either a image in base64 format or an image URL. Input image for upscale. |
upscale_by | int | 2 | How much do you want to make image bigger x2 or x4. | |
prompt | string | "" | By executing stable diffusion-based high-resolution fix, adding a brief description to the image can lead to higher-quality output. | |
negative_prompt | string | "worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch" | Enter in English any objects or scenarios you do not want to appear in the image. If nothing is entered, a default negative prompt will be used, which includes: "worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch." | |
quality | string | "LOW" | Choose from three levels of quality: "LOW", "MIDDLE", "HIGH". The default is "LOW". Setting the quality to "HIGH" will increase the detail quality of the generated image but will also take more time. A "LOW" quality setting results in relatively lower detail quality but faster generation speed. | |
denoising_strength | float | 0.2 | This scale represents the similarity score between the input image and the output image, ranging from 0.0 to 1.0. As the score approaches 0, the similarity between the input and output images decreases. Conversely, as it approaches 1.0, the similarity to the previous image increases, though it may appear as if the resolution hasn't increased. |
- Shell
- Python
- Java
- JS
curl --request POST
--url https://api.photio.io/v1/inference/upscale
--header 'X-Photio-Key: {X-Photio-Key}'
--header 'Content-Type: application/json'
--data '{ "image": "https://d2yiwnckkg6ukk.cloudfront.net/example/perfume_on_the_beach_output.png"}'
import requests
import json
data = {
"image": "https://d2yiwnckkg6ukk.cloudfront.net/example/perfume_on_the_beach_output.png"
}
body_data = json.dumps(data)
# Set the necessary headers
headers = {
'X-Photio-Key': '{X-Photio-Key}',
'Content-Type': 'application/json'
}
response = requests.post('https://api.photio.io/v1/inference/upscale', headers=headers, data=body_data)
class Generate {
public void remix() {
URL url = new URL("https://api.photio.io/v1/inference/upscale");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("X-Photio-Key", "${PHOTIO_API_KEY}");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
JSONObject data = new JSONObject();
data.put("image", "https://d2yiwnckkg6ukk.cloudfront.net/example/perfume_on_the_beach_output.png");
String bodyData = data.toString();
try (OutputStream os = conn.getOutputStream()) {
byte[] input = bodyData.getBytes("utf-8");
os.write(input, 0, input.length);
}
int responseCode = conn.getResponseCode();
System.out.println("Response Code : " + responseCode);
conn.disconnect();
}
}
const data = {
image: "https://d2yiwnckkg6ukk.cloudfront.net/example/perfume_on_the_beach_output.png",
};
const bodyData = JSON.stringify(data);
// Set the necessary headers
const headers = {
'X-Photio-Key': '{X-Photio-Key}',
'Content-Type': 'application/json'
};
fetch('https://api.photio.io/v1/inference/upscale', {
method: 'POST',
headers: headers,
body: bodyData
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Response
Variable | Type | Description |
---|---|---|
status_code | int | In the response, you can find a status value to check the status of the request. A normal response is indicated by 200, authentication issues by 401, and API status problems by a 500 error. |
body | string | The result image data is output as a Base64-encoded string. |
Response Example
{
"status_code": Int,
"body": Base64 String
}
- Our maximum output pixel size is limited by 4K!