Spaces:
Running
Running
import streamlit as st | |
from diffusers import DiffusionPipeline | |
import time | |
# Load the DiffusionPipeline model | |
pipeline = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo") | |
# Function to generate and display the image | |
def generate_and_display_image(prompt): | |
# Generate an image based on the prompt | |
image = pipeline(prompt) | |
# Display the generated image | |
st.image(image, caption='Generated Image', use_column_width=True) | |
# Main app code | |
st.title('Real-time Image Generation App') | |
# User input for the prompt with a placeholder | |
prompt = st.text_input('Enter your prompt', value='', help='Enter your prompt here...') | |
# Initialize the image display | |
image_placeholder = st.empty() | |
# Continuously generate and display the image based on the prompt | |
while True: | |
generate_and_display_image(prompt) | |
# Sleep for a short duration to avoid excessive CPU usage | |
time.sleep(1) |