File size: 1,023 Bytes
8923aba 68efc19 031ae3b f726406 a1538f9 7ab00ee 68efc19 7ab00ee a1538f9 7ab00ee a1538f9 68efc19 a1538f9 7ab00ee 68efc19 9f261f3 68efc19 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
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) |