Nawinkumar15 commited on
Commit
3f16b9e
verified
1 Parent(s): 98ec749

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -1,12 +1,15 @@
1
  import gradio as gr
2
- from transformers import pipeline
 
3
 
4
- # Load the text-to-image model (like Stable Diffusion or DALL路E)
5
- generator = pipeline("text-to-image", model="CompVis/stable-diffusion-v-1-4-original")
 
 
6
 
7
  def generate_image(description):
8
  # Generate an image based on the description
9
- image = generator(description)[0]["image"]
10
  return image
11
 
12
  # Set up the Gradio interface
 
1
  import gradio as gr
2
+ from diffusers import StableDiffusionPipeline
3
+ import torch
4
 
5
+ # Load Stable Diffusion pipeline (make sure to use the right model name)
6
+ model_name = "CompVis/stable-diffusion-v-1-4-original"
7
+ pipe = StableDiffusionPipeline.from_pretrained(model_name, torch_dtype=torch.float16)
8
+ pipe.to("cuda") # Move the model to GPU (if available)
9
 
10
  def generate_image(description):
11
  # Generate an image based on the description
12
+ image = pipe(description).images[0]
13
  return image
14
 
15
  # Set up the Gradio interface