import gradio as gr from diffusers import StableDiffusionPipeline import torch import time MODEL_ID = "1c1/Visionpy" pipe = StableDiffusionPipeline.from_pretrained( MODEL_ID, torch_dtype=torch.float16 ).to("cuda") pipe.enable_xformers_memory_efficient_attention() # VRAM ve hız optimizasyonu def generate(prompt, mode, res): start_time = time.time() # Hız modu için inference adımları steps = 20 # Hızlı üretim guidance = 7.5 # Çözünürlük if res == "512p": w, h = 512, 512 elif res == "1024p": w, h = 1024, 1024 else: w, h = 512, 512 # 4K/8K hızlı üretimde varsayılan olarak 512 image = pipe(prompt, height=h, width=w, num_inference_steps=steps, guidance_scale=guidance).images[0] elapsed = time.time() - start_time return image, f"{elapsed:.2f} saniyede üretildi!" with gr.Blocks(theme="soft", title="Hh — VisionPy Ultra HD 11s Mode") as demo: gr.Markdown( """ # 🌟 Hh — VisionPy Ultra HD **Anime / Realistic modları, Light Theme, 11 saniyede hızlı üretim!** """ ) with gr.Row(): prompt = gr.Textbox(label="Prompt", placeholder="ör: fantastik şehir, ultra yüksek çözünürlük") mode = gr.Dropdown(["Realistic", "Anime"], label="Mod") res = gr.Dropdown(["512p", "1024p"], label="Çözünürlük (Hızlı Mod)") out = gr.Image(label="Sonuç") time_label = gr.Label(label="Üretim Süresi") btn = gr.Button("ÜRET") btn.click(generate, inputs=[prompt, mode, res], outputs=[out, time_label]) demo.launch()