Spaces:
Runtime error
Runtime error
File size: 1,070 Bytes
d0cab4e 4d86a42 d0cab4e 4d86a42 d0cab4e 4d86a42 d0cab4e 4d86a42 c4da90b 4d86a42 d0cab4e 4d86a42 d0cab4e 4d86a42 |
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 |
import streamlit as st
import requests
API_ENDPOINT = "https://api.openai.com/v1/images/generations"
st.title("Pixel Art Generator")
st.write("Введите текст для генерации пиксельного искусства:")
text_input = st.text_input("")
if st.button("Создать пиксельный арт"):
prompt = "pixel art " + text_input
data = {
"model": "image-alpha-001",
"prompt": prompt,
"num_images": 1,
"size": "256x256",
"response_format": "url"
}
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer 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"
}
response = requests.post(url=API_ENDPOINT, json=data, headers=headers)
if response.ok:
st.write("Ваш пиксельный арт:")
st.image(response.json()["data"][0]["url"], use_column_width=True)
st.write("Powered By DALL•E 2")
else:
st.write("Ошибка при создании пиксельного искусства")
|