codermert commited on
Commit
68efc19
·
verified ·
1 Parent(s): f92d39c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -14
app.py CHANGED
@@ -1,29 +1,38 @@
1
  import gradio as gr
2
  import torch
3
- from diffusers import StableDiffusionPipeline
4
 
5
  def generate_image(prompt):
6
  try:
7
  # Model yükleme
8
- model_id = "runwayml/stable-diffusion-v1-5"
9
- pipe = StableDiffusionPipeline.from_pretrained(
10
- model_id,
11
- torch_dtype=torch.float32
12
  ).to('cpu')
13
 
14
  # Görsel oluşturma
15
  image = pipe(prompt).images[0]
16
  return image
17
  except Exception as e:
18
- return str(e)
19
 
20
  # Gradio arayüzü
21
- demo = gr.Interface(
22
- fn=generate_image,
23
- inputs=gr.Textbox(label="Prompt'unuzu girin"),
24
- outputs=gr.Image(label="Oluşturulan Görsel"),
25
- title="Görsel Oluşturucu",
26
- description="Bir prompt girin ve görsel oluşturun"
27
- )
 
 
 
 
 
 
 
 
28
 
29
- demo.launch(debug=True, share=False)
 
 
1
  import gradio as gr
2
  import torch
3
+ from diffusers import DiffusionPipeline
4
 
5
  def generate_image(prompt):
6
  try:
7
  # Model yükleme
8
+ pipe = DiffusionPipeline.from_pretrained(
9
+ "runwayml/stable-diffusion-v1-5",
10
+ torch_dtype=torch.float32,
11
+ use_safetensors=True
12
  ).to('cpu')
13
 
14
  # Görsel oluşturma
15
  image = pipe(prompt).images[0]
16
  return image
17
  except Exception as e:
18
+ return f"Hata oluştu: {str(e)}"
19
 
20
  # Gradio arayüzü
21
+ with gr.Blocks() as demo:
22
+ gr.Markdown("# Görsel Oluşturucu")
23
+ with gr.Row():
24
+ text_input = gr.Textbox(
25
+ label="Prompt'unuzu girin",
26
+ placeholder="Örnek: zehra bir portre"
27
+ )
28
+ image_output = gr.Image(label="Oluşturulan Görsel")
29
+
30
+ generate_btn = gr.Button("Görsel Oluştur")
31
+ generate_btn.click(
32
+ fn=generate_image,
33
+ inputs=[text_input],
34
+ outputs=[image_output]
35
+ )
36
 
37
+ if __name__ == "__main__":
38
+ demo.launch(show_error=True)