| | import gradio as gr |
| | import torch |
| | from diffusers import DiffusionPipeline |
| |
|
| | def generate_image(prompt): |
| | try: |
| | |
| | pipe = DiffusionPipeline.from_pretrained( |
| | "runwayml/stable-diffusion-v1-5", |
| | torch_dtype=torch.float32, |
| | use_safetensors=True |
| | ).to('cpu') |
| | |
| | |
| | image = pipe(prompt).images[0] |
| | return image |
| | except Exception as e: |
| | return f"Hata oluştu: {str(e)}" |
| |
|
| | |
| | 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) |