Spaces:
Runtime error
Runtime error
File size: 976 Bytes
11c2bbb 38c7f3d 4875959 11c2bbb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import streamlit as st
import openai
openai.api_key ="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"
st.title("DALL-E 2 API Image Generation Demo with OpenAI SDK")
st.write("Enter a prompt to generate an image")
prompt = st.text_area("Prompt", "An eco-friendly computer from the 90s in the style of vaporwave")
num_images = st.slider("Number of images to generate", min_value=1, max_value=10, value=1)
image_size = st.selectbox(
"Select an image size",
["256x256", "512x512", "1024x1024"]
)
def generate_images(prompt, num_images, image_size):
response = openai.Image.create(
prompt=prompt,
n=num_images,
size=image_size,
)
return response["data"]
if st.button("Generate Images"):
with st.spinner("Generating images..."):
image_data = generate_images(prompt, num_images, image_size)
for idx, image in enumerate(image_data):
st.image(image['url'], caption=f"Image {idx+1}", width=400)
|