Scorpsuki commited on
Commit
07711bc
·
verified ·
1 Parent(s): 00bcd06

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -18
app.py CHANGED
@@ -1,27 +1,14 @@
1
- # app.py файлын жасаңыз
2
  import gradio as gr
3
  from diffusers import StableDiffusionPipeline
4
  import torch
5
 
6
  model_id = "runwayml/stable-diffusion-v1-5"
7
- pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
8
- pipe = pipe.to("cuda")
9
 
10
- def generate_image(prompt):
11
- image = pipe(
12
- prompt,
13
- num_inference_steps=30,
14
- guidance_scale=7.5
15
- ).images[0]
16
  return image
17
 
18
- # Gradio интерфейсі
19
- iface = gr.Interface(
20
- fn=generate_image,
21
- inputs=gr.Textbox(label="Сурет сипаттамасы", lines=2),
22
- outputs=gr.Image(label="Нәтиже"),
23
- title="Stable Diffusion генераторы",
24
- description="Мәтіндік сипаттама бойынша кескін жасаңыз"
25
- )
26
-
27
  iface.launch()
 
 
1
  import gradio as gr
2
  from diffusers import StableDiffusionPipeline
3
  import torch
4
 
5
  model_id = "runwayml/stable-diffusion-v1-5"
6
+ pipe = StableDiffusionPipeline.from_pretrained(model_id)
7
+ pipe = pipe.to("cuda" if torch.cuda.is_available() else "cpu")
8
 
9
+ def generate(prompt):
10
+ image = pipe(prompt).images[0]
 
 
 
 
11
  return image
12
 
13
+ iface = gr.Interface(fn=generate, inputs="text", outputs="image")
 
 
 
 
 
 
 
 
14
  iface.launch()