Spaces:
Sleeping
Sleeping
File size: 548 Bytes
88ac6d1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import torch
from diffusers import StableDiffusionPipeline
import streamlit as st
model_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cpu")
st.title("Generate an image of an astronaut riding a horse on Mars")
if st.button('Generate Image'):
prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt).images[0]
st.image(image, caption='Generated image', use_column_width=True)
image.save("astronaut_rides_horse.png") |