| import gradio as gr |
| from diffusers import StableDiffusionPipeline |
| import torch |
|
|
| MODEL_ID = "1c1/Hh" # Space’e yüklediğin modelin ID’si veya SD1.5 base |
|
|
| |
| pipe = StableDiffusionPipeline.from_pretrained( |
| MODEL_ID, |
| torch_dtype=torch.float16, |
| ).to("cuda") |
|
|
| |
| history = [] |
|
|
| def chat_and_generate(message, mode, size, turbo): |
| global history |
| # Bot cevabı |
| reply = f"Tamam! '{message}' için görsel üretebilirim." |
| history.append(("Kullanıcı: " + message, "Bot: " + reply)) |
| |
| # Görsel üretim |
| w, h = map(int, size.split("x")) |
| steps = 16 if turbo else 30 |
|
|
| prompt = message |
| if mode == "Anime": |
| prompt += ", anime style, sharp lines, vibrant colors" |
| else: |
| prompt += ", ultra realistic, 8k, detailed textures" |
|
|
| image = pipe(prompt, num_inference_steps=steps, width=w, height=h).images[0] |
| return history, image |
|
|
| |
| sizes = ["512x512", "768x768", "1024x1024", "1536x1536", "4096x4096", "7680x4320"] |
|
|
| with gr.Blocks(title="ZImageAI – VisionPy") as demo: |
| gr.Markdown("<h1 style='text-align:center'>🚀 ZImageAI – VisionPy Ultra HD</h1>") |
| |
| with gr.Row(): |
| msg = gr.Textbox(label="Mesaj / Prompt", placeholder="örn: bir dağ manzarası, güneşli hava") |
| mode = gr.Radio(["Anime", "Gerçekçi"], value="Gerçekçi", label="Mod") |
| size = gr.Dropdown(sizes, value="1024x1024", label="Görsel Boyutu") |
| turbo = gr.Checkbox(label="⚡ 11s Turbo Mod", value=False) |
|
|
| chatbox = gr.Chatbot(label="Sohbet / Görsel") |
| btn = gr.Button("Gönder ve Üret") |
|
|
| btn.click(chat_and_generate, inputs=[msg, mode, size, turbo], outputs=[chatbox, chatbox]) |
|
|
| demo.launch() |