27 lines
827 B
Python
27 lines
827 B
Python
from gradio_client import Client
|
|
|
|
# Пользователь - сессия
|
|
img_ses = {}
|
|
|
|
def draw(prompt, id):
|
|
global img_ses
|
|
if str(id) not in img_ses:
|
|
client = Client("https://playgroundai-playground-v2-5.hf.space/--replicas/0czym/")
|
|
img_ses[str(id)] = client
|
|
else:
|
|
client = img_ses[str(id)]
|
|
|
|
result = client.predict(
|
|
prompt, # Что рисуем
|
|
"", # 'Negative prompt'
|
|
False, # 'Use negative prompt'
|
|
0, # Сид
|
|
512, # float (numeric value between 256 and 1536) in 'Width' Slider component
|
|
512, # float (numeric value between 256 and 1536) in 'Height' Slider component
|
|
3, # float (numeric value between 0.1 and 20) in 'Guidance Scale' Slider component
|
|
True, # bool in 'Randomize seed' Checkbox component
|
|
api_name="/run")
|
|
|
|
# Путь к изображению
|
|
return result[0][0]["image"]
|