Sandeshsandy commited on
Commit
a30de1a
·
verified ·
1 Parent(s): 77c3f2d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -1,23 +1,20 @@
1
- # app.py
2
  import gradio as gr
3
  from transformers import pipeline
4
 
5
- # Initialize the model (example with a text-to-image model)
6
  generator = pipeline("image-generation", model="CompVis/stable-diffusion-v1-4")
7
 
8
- # Function to generate an image from a prompt
9
  def generate_image(prompt):
10
- # The pipeline will return a list with the image as the first element
11
  return generator(prompt)[0]["image"]
12
 
13
- # Set up the Gradio interface
14
  interface = gr.Interface(
15
- fn=generate_image, # function to be called
16
- inputs="text", # input type: text box for user input (prompt)
17
- outputs="image", # output type: image display
18
- live=True # allows real-time generation (optional)
19
  )
20
 
21
  # Launch the interface
22
- if __name__ == "__main__":
23
- interface.launch()
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Initialize your model here
5
  generator = pipeline("image-generation", model="CompVis/stable-diffusion-v1-4")
6
 
7
+ # Function to generate image from text prompt
8
  def generate_image(prompt):
 
9
  return generator(prompt)[0]["image"]
10
 
11
+ # Define Gradio Interface
12
  interface = gr.Interface(
13
+ fn=generate_image,
14
+ inputs="text", # User will input text prompt
15
+ outputs="image", # The output will be an image
16
+ live=True
17
  )
18
 
19
  # Launch the interface
20
+ interface.launch()