Skip to content
Discussion options

You must be logged in to vote

It uses the models on the server (the ones on the Extras tab). Use the name, not the filename. See /sdapi/v1/upscalers.

import requests
import base64

url = "http://127.0.0.1:7860"

with open("input.png", "rb") as f:
    img = base64.b64encode(f.read()).decode('utf-8')

payload = {
    "resize_mode": 0,
    "upscaling_resize": 2,
    "upscaler_1": "ESRGAN_4x",
    "image": img
}

response = requests.post(url=f'{url}/sdapi/v1/extra-single-image', json=payload)
r = response.json()

with open("output.png", 'wb') as f:
    f.write(base64.b64decode(r['image']))

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@Faishun
Comment options

Answer selected by Faishun
Comment options

You must be logged in to vote
1 reply
@Faishun
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants