Update app.py
Browse files
app.py
CHANGED
@@ -7,26 +7,20 @@ from io import BytesIO
|
|
7 |
# Set up the OpenAI API key from Hugging Face Spaces secrets
|
8 |
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
9 |
|
10 |
-
st.title("
|
11 |
|
12 |
# User inputs for image generation
|
13 |
-
|
14 |
-
|
15 |
-
additional_elements = st.text_input("Additional Elements", placeholder="Any specific elements to include in the image (e.g., Christmas tree, snowflakes)")
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
format_size_mapping = {
|
22 |
-
"16:9 (Standard HD - 1920x1080)": "1024x576", # Reduced size for 1080p
|
23 |
-
"1:1 (Square - 1080x1080)": "1024x1024",
|
24 |
-
"4:5 (Portrait - 1080x1350)": "1024x768", # Reduced size for portrait
|
25 |
-
}
|
26 |
|
27 |
if st.button('Generate Image'):
|
28 |
# Construct the prompt
|
29 |
-
prompt = f"
|
30 |
|
31 |
# Call the DALL-E API
|
32 |
try:
|
@@ -34,7 +28,7 @@ if st.button('Generate Image'):
|
|
34 |
model="dall-e-3", # Specify DALL-E 3 model
|
35 |
prompt=prompt,
|
36 |
n=1,
|
37 |
-
size=
|
38 |
quality="standard" # Set image quality to standard for lower cost
|
39 |
)
|
40 |
|
@@ -46,7 +40,7 @@ if st.button('Generate Image'):
|
|
46 |
image = Image.open(BytesIO(image_response.content))
|
47 |
|
48 |
# Display the image
|
49 |
-
st.image(image, caption='Generated
|
50 |
|
51 |
except Exception as e:
|
52 |
st.error(f"An error occurred: {e}")
|
|
|
7 |
# Set up the OpenAI API key from Hugging Face Spaces secrets
|
8 |
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
9 |
|
10 |
+
st.title("TikTok Video Backdrop and Image Generator for Small Businesses")
|
11 |
|
12 |
# User inputs for image generation
|
13 |
+
st.subheader("Define Your Business")
|
14 |
+
business_type = st.text_input("Your Business Type", placeholder="e.g., Cafe, Florist, Yoga Studio")
|
|
|
15 |
|
16 |
+
st.subheader("Video Backdrop Details")
|
17 |
+
video_theme = st.text_input("Video Theme", placeholder="Enter a theme for your TikTok video (e.g., cozy cafe, floral arrangement, yoga session)")
|
18 |
+
color_scheme = st.text_input("Color Scheme", placeholder="Preferred color scheme (e.g., pastel, vibrant, earth tones)")
|
19 |
+
additional_elements = st.text_input("Additional Elements", placeholder="Any specific elements to include in the backdrop (e.g., coffee cups, flowers, yoga mats)")
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
if st.button('Generate Image'):
|
22 |
# Construct the prompt
|
23 |
+
prompt = f"Create a vertical TikTok video backdrop image for a {business_type}. Theme: '{video_theme}', color scheme: '{color_scheme}', including elements: '{additional_elements}'."
|
24 |
|
25 |
# Call the DALL-E API
|
26 |
try:
|
|
|
28 |
model="dall-e-3", # Specify DALL-E 3 model
|
29 |
prompt=prompt,
|
30 |
n=1,
|
31 |
+
size="1024x1792", # Set image dimensions to vertical
|
32 |
quality="standard" # Set image quality to standard for lower cost
|
33 |
)
|
34 |
|
|
|
40 |
image = Image.open(BytesIO(image_response.content))
|
41 |
|
42 |
# Display the image
|
43 |
+
st.image(image, caption='Generated Business Video Backdrop Image')
|
44 |
|
45 |
except Exception as e:
|
46 |
st.error(f"An error occurred: {e}")
|