import gradio as gr import torch from diffusers import DiffusionPipeline def generate_image(prompt): try: # Model yükleme pipe = DiffusionPipeline.from_pretrained( "runwayml/stable-diffusion-v1-5", torch_dtype=torch.float32, use_safetensors=True ).to('cpu') # Görsel oluşturma image = pipe(prompt).images[0] return image except Exception as e: return f"Hata oluştu: {str(e)}" # Gradio arayüzü with gr.Blocks() as demo: gr.Markdown("# Görsel Oluşturucu") with gr.Row(): text_input = gr.Textbox( label="Prompt'unuzu girin", placeholder="Örnek: zehra bir portre" ) image_output = gr.Image(label="Oluşturulan Görsel") generate_btn = gr.Button("Görsel Oluştur") generate_btn.click( fn=generate_image, inputs=[text_input], outputs=[image_output] ) if __name__ == "__main__": demo.launch(show_error=True)