Create app.py
Browse files
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")
|