Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
|
4 |
+
# API ссылка
|
5 |
+
url = "https://api.realisticvision.com/v5/render"
|
6 |
+
|
7 |
+
# Функция для отправки запроса
|
8 |
+
def render(prompt, negative_prompt, output_format, output_size, style, lighting, background, camera_position, camera_angle):
|
9 |
+
data = {
|
10 |
+
"prompt": prompt,
|
11 |
+
"negative_prompt": negative_prompt,
|
12 |
+
"output_format": output_format,
|
13 |
+
"output_size": output_size,
|
14 |
+
"style": style,
|
15 |
+
"lighting": lighting,
|
16 |
+
"background": background,
|
17 |
+
"camera_position": camera_position,
|
18 |
+
"camera_angle": camera_angle,
|
19 |
+
}
|
20 |
+
response = requests.post(url, json=data)
|
21 |
+
if response.status_code == 200:
|
22 |
+
return response.content
|
23 |
+
else:
|
24 |
+
return None
|
25 |
+
|
26 |
+
# UI
|
27 |
+
gr.Interface(render,
|
28 |
+
inputs={"prompt": gr.Textbox(placeholder="Введите описание изображения"),
|
29 |
+
"negative_prompt": gr.Textbox(placeholder="Введите отрицательный образ"),
|
30 |
+
"output_format": gr.Dropdown(["png", "jpg", "webp", "gif"]),
|
31 |
+
"output_size": gr.Dropdown(["256x256", "512x512", "1024x1024", "2048x2048"]),
|
32 |
+
"style": gr.Dropdown(["photorealistic", "cartoon", "anime", "sketch", "painting"]),
|
33 |
+
"lighting": gr.Dropdown(["natural", "studio", "night", "random"]),
|
34 |
+
"background": gr.Dropdown(["white", "black", "random"]),
|
35 |
+
"camera_position": gr.Dropdown(["front", "top", "side"]),
|
36 |
+
"camera_angle": gr.Dropdown(["0", "45", "90"])},
|
37 |
+
outputs=gr.Output(type="image")).launch()
|