Download Python from 1c1/ZImageAI: direct link, hf CLI and curl.
- Browser
- Download file 1.72 kB
-
https://huggingface.co/spaces/1c1/ZImageAI/resolve/main/Python
- Command line
-
hf download hf://spaces/1c1/ZImageAI/Python
-
curl -L -o Python https://huggingface.co/spaces/1c1/ZImageAI/resolve/main/Python
1.72 kB
| 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 | |
| # Pipeline yükleme | |
| pipe = StableDiffusionPipeline.from_pretrained( | |
| MODEL_ID, | |
| torch_dtype=torch.float16, | |
| ).to("cuda") | |
| # Sohbet geçmişi | |
| 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 | |
| # Arayüz | |
| 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() |