bizvideoschool commited on
Commit
de43a1d
·
verified ·
1 Parent(s): e53733f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -16
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("Holiday Video Backdrop Image Generator")
11
 
12
  # User inputs for image generation
13
- image_theme = st.text_input("Image Theme", placeholder="Enter a theme for your holiday video backdrop (e.g., festive living room, snowy landscape)")
14
- color_scheme = st.text_input("Color Scheme", placeholder="Preferred color scheme (e.g., red and green, white and blue)")
15
- additional_elements = st.text_input("Additional Elements", placeholder="Any specific elements to include in the image (e.g., Christmas tree, snowflakes)")
16
 
17
- # Dropdown for selecting image dimensions
18
- video_format = st.selectbox("Video Format", ["16:9 (Standard HD - 1920x1080)", "1:1 (Square - 1080x1080)", "4:5 (Portrait - 1080x1350)"])
19
-
20
- # Mapping formats to DALL-E API size parameters
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"A holiday-themed backdrop image depicting: '{image_theme}', color scheme: '{color_scheme}', including elements: '{additional_elements}'."
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=format_size_mapping[video_format], # Set reduced image dimensions based on selected video format
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 Holiday Backdrop Image')
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}")