Nikhil0987 commited on
Commit
88ac6d1
1 Parent(s): 4b5592c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from diffusers import StableDiffusionPipeline
3
+ import streamlit as st
4
+
5
+ model_id = "runwayml/stable-diffusion-v1-5"
6
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
7
+ pipe = pipe.to("cpu")
8
+
9
+ st.title("Generate an image of an astronaut riding a horse on Mars")
10
+
11
+ if st.button('Generate Image'):
12
+ prompt = "a photo of an astronaut riding a horse on mars"
13
+ image = pipe(prompt).images[0]
14
+ st.image(image, caption='Generated image', use_column_width=True)
15
+ image.save("astronaut_rides_horse.png")