Can this be run programmatically? #106
crypto-kungfu
started this conversation in
General
Replies: 1 comment
-
HI @crypto-kungfu, unfortunately we don't offer API, but if you really need it you can fork the repo and make it happen! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This example lets me create text2img via api but would anyone know how i could run infinitezoom via the same approach?
import json
import base64
import requests
def submit_post(url: str, data: dict):
"""
Submit a POST request to the given URL with the given data.
"""
return requests.post(url, data=json.dumps(data))
def save_encoded_image(b64_image: str, output_path: str):
"""
Save the given image to the given output path.
"""
with open(output_path, "wb") as image_file:
image_file.write(base64.b64decode(b64_image))
if name == 'main':
txt2img_url = 'http://127.0.0.1:7861/sdapi/v1/txt2img'
data = {'prompt': 'a dog wearing a hat'}
response = submit_post(txt2img_url, data)
save_encoded_image(response.json()['images'][0], 'dog.png')
Beta Was this translation helpful? Give feedback.
All reactions