[GH-ISSUE #16] how is use api ? #9

Open
opened 2026-10-30 21:03:08 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @rookiexjl on GitHub (Sep 8, 2023).
Original GitHub issue: https://github.com/ahgsql/StyleSelectorXL/issues/16

Originally created by @rookiexjl on GitHub (Sep 8, 2023). Original GitHub issue: https://github.com/ahgsql/StyleSelectorXL/issues/16
Author
Owner

@liangcaihua commented on GitHub (Nov 5, 2023):

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

<!-- gh-comment-id:1793791356 --> @liangcaihua commented on GitHub (Nov 5, 2023): 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
Author
Owner

@rookiexjl commented on GitHub (Nov 5, 2023):

什么事

<!-- gh-comment-id:1793791439 --> @rookiexjl commented on GitHub (Nov 5, 2023): 什么事
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ahgsql/StyleSelectorXL#9
No description provided.