Kia09 commited on
Commit
214706e
·
verified ·
1 Parent(s): eeb07d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -2,9 +2,10 @@ import gradio as gr
2
  from diffusers import StableDiffusionPipeline
3
  import torch
4
 
 
5
  model_id = "CompVis/stable-diffusion-v1-4"
6
- pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
7
- pipe = pipe.to("cuda")
8
 
9
  def generate_image(prompt):
10
  image = pipe(prompt).images[0]
@@ -12,12 +13,10 @@ def generate_image(prompt):
12
 
13
  iface = gr.Interface(
14
  fn=generate_image,
15
- inputs=gr.Textbox(label="prompt", placeholder="Enter your prompt here..."),
16
  outputs=gr.Image(type="pil", label="Generated Image"),
17
- title="Speech2Image Generator (Fast API Powered)",
18
  theme="default",
19
  )
20
 
21
  iface.launch()
22
-
23
-
 
2
  from diffusers import StableDiffusionPipeline
3
  import torch
4
 
5
+ # Use a compatible model ID
6
  model_id = "CompVis/stable-diffusion-v1-4"
7
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32) # Use float32 if float16 causes issues
8
+ pipe = pipe.to("cuda") # Ensure your environment supports CUDA; if not, remove this line
9
 
10
  def generate_image(prompt):
11
  image = pipe(prompt).images[0]
 
13
 
14
  iface = gr.Interface(
15
  fn=generate_image,
16
+ inputs=gr.Textbox(label="Prompt", placeholder="Enter your prompt here..."),
17
  outputs=gr.Image(type="pil", label="Generated Image"),
18
+ title="Speech2Image Generator (FastAPI Powered)",
19
  theme="default",
20
  )
21
 
22
  iface.launch()