Spaces:
Configuration error
Configuration error
Update ai_design_generator/app.py
Browse files
ai_design_generator/app.py
CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
|
|
2 |
import requests
|
3 |
from PIL import Image
|
4 |
from io import BytesIO
|
|
|
5 |
|
6 |
st.set_page_config(page_title="AI Design Generator", layout="centered")
|
7 |
st.title("🎨 AI Poster/Packaging Design Generator")
|
@@ -12,9 +13,7 @@ prompt = st.text_input("Prompt", "modern minimalist packaging with red and white
|
|
12 |
if st.button("Generate Design"):
|
13 |
with st.spinner("Generating..."):
|
14 |
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2"
|
15 |
-
|
16 |
-
headers = {"Authorization": f"Bearer {os.environ['HF_TOKEN']}"}
|
17 |
-
|
18 |
|
19 |
payload = {"inputs": prompt}
|
20 |
response = requests.post(API_URL, headers=headers, json=payload)
|
@@ -24,3 +23,4 @@ if st.button("Generate Design"):
|
|
24 |
st.image(image, caption="Generated Design")
|
25 |
else:
|
26 |
st.error("Failed to generate image. Try again later.")
|
|
|
|
2 |
import requests
|
3 |
from PIL import Image
|
4 |
from io import BytesIO
|
5 |
+
import os
|
6 |
|
7 |
st.set_page_config(page_title="AI Design Generator", layout="centered")
|
8 |
st.title("🎨 AI Poster/Packaging Design Generator")
|
|
|
13 |
if st.button("Generate Design"):
|
14 |
with st.spinner("Generating..."):
|
15 |
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2"
|
16 |
+
headers = {"Authorization": f"Bearer {os.environ['HF_TOKEN']}"}
|
|
|
|
|
17 |
|
18 |
payload = {"inputs": prompt}
|
19 |
response = requests.post(API_URL, headers=headers, json=payload)
|
|
|
23 |
st.image(image, caption="Generated Design")
|
24 |
else:
|
25 |
st.error("Failed to generate image. Try again later.")
|
26 |
+
|