API return image from output directory? #14901
Replies: 2 comments 3 replies
-
Files can be accessed with the By default, the API doesn't save images. Instead, it returns the images as base64. They can be saved locally like so. import requests
import base64
payload = {
"prompt": "cat",
"steps": 20,
}
response = requests.post(url='http://127.0.0.1:7860/sdapi/v1/txt2img', json=payload)
r = response.json()
with open('output.png', 'wb') as f:
f.write(base64.b64decode(r['images'][0])) or read with pillow import requests
import base64
import io
from PIL import Image
payload = {
"prompt": "cat",
"steps": 20,
}
response = requests.post(url='http://127.0.0.1:7860/sdapi/v1/txt2img', json=payload)
r = response.json()
with io.BytesIO(base64.b64decode(r['images'][0])) as f:
image = Image.open(f) To save them on the server, add |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When using the API, is there a way to access the actual image generated in the output directory of Auto1111?
Beta Was this translation helpful? Give feedback.
All reactions