Arunaabh commited on
Commit
361b426
·
verified ·
1 Parent(s): ddb2269

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from diffusers import StableDiffusionPipeline
3
+ import torch
4
+
5
+ # Load the DALL-E model and tokenizer
6
+ model_id = "runwayml/stable-diffusion-v1-5"
7
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
8
+
9
+ # Streamlit app
10
+ st.title("Image generation demo")
11
+
12
+ prompt = st.text_input("Enter a text prompt:", "a cat in the rain")
13
+
14
+ if st.button("Generate Image"):
15
+ # Generate image from the prompt
16
+ image = pipe(prompt).images[0]
17
+
18
+ # Display the image
19
+ st.image(image, caption="Generated Image", channels="RGB")