Spaces:
Paused
Paused
| import torch | |
| from diffusers import StableDiffusionPipeline | |
| import gradio as gr | |
| # -------------------------- | |
| # MODEL YÜKLEME | |
| # -------------------------- | |
| # Module *hiçbir yere bağlı değildir* | |
| # Kendi Space dosyan: /model.safetensors | |
| pipe = StableDiffusionPipeline.from_single_file( | |
| "model.safetensors", | |
| torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32, | |
| safety_checker=None | |
| ) | |
| if torch.cuda.is_available(): | |
| pipe = pipe.to("cuda") | |
| # -------------------------- | |
| # GÖRSEL ÜRETİM FONKSİYONU | |
| # -------------------------- | |
| def generate(prompt, width, height, steps): | |
| image = pipe( | |
| prompt, | |
| num_inference_steps=steps, | |
| width=width, | |
| height=height | |
| ).images[0] | |
| return image | |
| # -------------------------- | |
| # GRADIO ARAYÜZÜ | |
| # -------------------------- | |
| with gr.Blocks(theme="soft") as demo: | |
| gr.Markdown("# 🎨 Kendi Modelinden Görsel Üreten Bot\nTamamen Bağımsız • Bağlantısız") | |
| prompt = gr.Textbox(label="Prompt", placeholder="ör: futuristic city, ultra detailed") | |
| width = gr.Slider(256, 2048, value=512, step=8, label="Genişlik") | |
| height = gr.Slider(256, 2048, value=512, step=8, label="Yükseklik") | |
| steps = gr.Slider(10, 80, value=30, step=1, label="Steps") | |
| btn = gr.Button("Görsel Üret") | |
| output = gr.Image(label="Üretilen Görsel") | |
| btn.click(generate, inputs=[prompt, width, height, steps], outputs=output) | |
| demo.launch() |