Image Upscaling

[POST] https://api.nichetensor.com/api/v1/upscale

image
  • Header
NAME
TYPE
REQUIRED
API_KEY
string
✔️
  • Body
NAME
TYPE
REQUIRED
DESCRIPTION
Available Choices
prompt
string
✔️
The prompt that describes the image
model_name
string
✔️
The name of the model to use for image generation.
SUPIR
seed
integer
The seed value for the random number generator. Use 0 for a random seed. Default: 0
conditional_image
string
✔️
Base64 encoded image to be upscaled
  • Example Request in Python
  • from PIL import Image
    import io
    import base64
    import time, requests
    
    def base64_to_pil_image(base64_image):
            image = base64.b64decode(base64_image)
            image = io.BytesIO(image)
            image = Image.open(image)
            return image
    
    def pil_image_to_base64(image: Image.Image, format="JPEG") -> str:
        if format not in ["JPEG", "PNG"]:
            format = "JPEG"
        image_stream = io.BytesIO()
        image.save(image_stream, format=format)
        base64_image = base64.b64encode(image_stream.getvalue()).decode("utf-8")
        return base64_image
    
    endpoint = "https://api.nichetensor.com/api/v1/upscale"
    headers = {
        "API_KEY": "your-api-key",
    }
    image_url = "https://parrotprint.com/media/wordpress/7630543941b44634748ddea65e5a417c.webp"
    image = Image.open(requests.get(image_url, stream=True).raw)
    
    base64_image = pil_image_to_base64(image)
    data = {
        "prompt": "a aesthetic face of a girl",
        "model_name": "SUPIR",
        "conditional_image": base64_image,
        "seed": 0,
        
    }
    
    
    response = requests.post(endpoint, json=data, headers=headers)
    response.raise_for_status()
    response = response.json()
    base64_image = response["image"]
    image = base64_to_pil_image(base64_image)
    image.save("output.png")