Replies: 7 comments 4 replies
-
me too |
Beta Was this translation helpful? Give feedback.
-
Окей, долго работал над этим, ловите: import os
import requests
import io
import base64
import random
import json
from PIL import Image, PngImagePlugin
api = 'http://127.0.0.1:7860'
try:
os.makedirs('diffimages')
except:
pass
def img2img(api, text, steps, image_path):
api_url = f"{api}/sdapi/v1/img2img"
with open(image_path, 'rb') as file:
image_data = file.read()
encoded_image = base64.b64encode(image_data).decode('utf-8')
payload = {
"init_images": [encoded_image],
'prompt' : text,
"steps": steps,
}
response = requests.post(api_url, json=payload)
name = 'GENimg2img_'
for i in range(random.randint(15, 25)):
name += random.choice('QAZXfrSWEDCVFRTqazxswgbnhyujmkiolpGBNHYUJedcvtMKIOLP')
print(name)
if response.status_code == 200:
response_data = response.json()
encoded_result = response_data["images"][0]
result_data = base64.b64decode(encoded_result)
output_path = f"diffimages/{name}.jpg"
with open(output_path, 'wb') as file:
file.write(result_data)
return name
else:
print("Ошибка при выполнении запроса:", response.text)
return None |
Beta Was this translation helpful? Give feedback.
-
hi @sayyoume did you ever find out? |
Beta Was this translation helpful? Give feedback.
-
you will have to create a mask and its image and then send it to img2img |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
the API is technically just this is the code in webUI that does the processing when you're using it via the webUI stable-diffusion-webui/modules/img2img.py Lines 154 to 176 in cb5b335 with API you have to do it yourself and |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
http://127.0.0.1:7860/sdapi/v1/img2img api
I would like to know which parameters are used to identify inpaint /sketch /inpaint inpaint / inpain upload
Beta Was this translation helpful? Give feedback.
All reactions