Shangkhonil commited on
Commit
e044083
·
verified ·
1 Parent(s): b5af713

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -2,25 +2,22 @@ import gradio as gr
2
  from diffusers import DiffusionPipeline
3
  import torch
4
 
5
- # Load the Shap-E pipeline (adjust the model path if needed)
6
  pipeline = DiffusionPipeline.from_pretrained("openai/shap-e", torch_dtype=torch.float16)
7
  pipeline = pipeline.to("cuda" if torch.cuda.is_available() else "cpu")
8
 
9
  def generate_image(prompt):
10
- # Generate an image based on the prompt using the pipeline
11
  output = pipeline(prompt)
12
  return output.images[0]
13
 
14
- # Gradio interface setup
15
- title = "Shap-E Model Demo"
16
- description = "Generate images from text prompts using the Shap-E diffusion model."
17
-
18
  interface = gr.Interface(
19
  fn=generate_image,
20
  inputs=gr.Textbox(label="Prompt"),
21
  outputs=gr.Image(label="Generated Image"),
22
- title=title,
23
- description=description,
24
  )
25
 
26
  if __name__ == "__main__":
 
2
  from diffusers import DiffusionPipeline
3
  import torch
4
 
5
+ # Load the pipeline
6
  pipeline = DiffusionPipeline.from_pretrained("openai/shap-e", torch_dtype=torch.float16)
7
  pipeline = pipeline.to("cuda" if torch.cuda.is_available() else "cpu")
8
 
9
  def generate_image(prompt):
10
+ # Generate image using the prompt
11
  output = pipeline(prompt)
12
  return output.images[0]
13
 
14
+ # Set up Gradio interface
 
 
 
15
  interface = gr.Interface(
16
  fn=generate_image,
17
  inputs=gr.Textbox(label="Prompt"),
18
  outputs=gr.Image(label="Generated Image"),
19
+ title="Shap-E Image Generation",
20
+ description="Generate images from text prompts using the Shap-E diffusion model."
21
  )
22
 
23
  if __name__ == "__main__":