File size: 1,294 Bytes
db31e7b ea41116 46bcbcb dcb8ac8 ea41116 46bcbcb ea41116 a935a7a dcb8ac8 ea41116 dcb8ac8 46bcbcb a935a7a ea41116 dcb8ac8 ea41116 dcb8ac8 a935a7a dcb8ac8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | import gradio as gr
from gradio_client import Client
# Подключение к генератору
client = Client("mrfakename/z-image-turbo")
def auto_generate(idea):
if not idea or not idea.strip():
return "", None, "❌ Напишите идею"
prompt = f"{idea.strip()}, cinematic composition, highly detailed, photorealistic, realistic lighting, sharp focus, high quality"
try:
result = client.predict(prompt=prompt, api_name="/predict")
return prompt, result, "✅ Изображение готово!"
except Exception as e:
return prompt, None, f"❌ Ошибка: {str(e)}"
with gr.Blocks() as app:
gr.Markdown("# 🤖 MODARA_AI")
idea = gr.Textbox(
label="💡 Что создать?",
placeholder="Например: BMW M5 CS едет ночью по Дубаю"
)
auto_btn = gr.Button("⚡ АВТО", variant="primary")
status = gr.Textbox(label="📊 Статус", interactive=False)
improved = gr.Textbox(label="✨ Улучшенный промпт", interactive=False)
result = gr.Image(label="🖼️ Результат")
auto_btn.click(
auto_generate,
inputs=idea,
outputs=[improved, result, status]
)
app.launch() |