Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how is use api ? #16

Open
rookiexjl opened this issue Sep 8, 2023 · 2 comments
Open

how is use api ? #16

rookiexjl opened this issue Sep 8, 2023 · 2 comments

Comments

@rookiexjl
Copy link

No description provided.

@liangcaihua
Copy link

import json
import requests
import io
import base64
from PIL import Image

url = 'http://127.0.0.1:7860/sdapi/v1/txt2img'
payload = {
'prompt': 'chariot,white_background,science_fiction,wide_shot',
'negative_prompt': '',
'styles': [
'增强'
],
'seed': -1,
'batch_size': 1,
'n_iter': 4,
'steps': 26,
'cfg_scale': 7,
'width': 1024,
'height': 1024,
'do_not_save_samples': 'true',
'do_not_save_grid': 'true',
'eta': 0,
'denoising_strength': 0,
'comments': {},
'send_images': 'true',
'save_images': 'true',
}

print(url)
response = requests.post(url=url, json=payload)
r = response.json()
image = Image.open(io.BytesIO(base64.b64decode(r['images'][0])))

image

@rookiexjl
Copy link
Author

rookiexjl commented Nov 5, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants