Pratap2002 commited on
Commit
a8148ad
·
verified ·
1 Parent(s): 92f8d26

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +66 -59
app.py CHANGED
@@ -122,31 +122,6 @@ def increase_image_quality(image, scale_factor):
122
 
123
  def generate_poster():
124
  #st.header("Generate Social Media Post")
125
- post_type = st.selectbox("Select Post Type", ["Instagram advertisement post", "Facebook advertisement post", "Twitter advertisement post", "Other"])
126
- aspect_ratio = st.selectbox("Select Image Aspect Ratio", ["1:1", "16:9", "4:5", "9:16"])
127
-
128
- # Add dimension selection based on aspect ratio
129
- if aspect_ratio == "1:1":
130
- dimensions = st.selectbox("Select Image Dimensions", ["1080x1080", "1200x1200", "1500x1500"])
131
- elif aspect_ratio == "16:9":
132
- dimensions = st.selectbox("Select Image Dimensions", ["1920x1080", "1280x720", "2560x1440"])
133
- elif aspect_ratio == "4:5":
134
- dimensions = st.selectbox("Select Image Dimensions", ["1080x1350", "1200x1500", "1600x2000"])
135
- elif aspect_ratio == "9:16":
136
- dimensions = st.selectbox("Select Image Dimensions", ["1080x1920", "1350x2400", "1600x2844"])
137
-
138
- # Extract width and height from the selected dimensions
139
- width, height = map(int, dimensions.split('x'))
140
-
141
- design_style = st.selectbox("Select Design Style", [
142
- "Minimalistic", "Bold/Graphic", "Elegant", "Playful/Fun",
143
- "Corporate/Professional", "Retro/Vintage", "Modern/Contemporary", "Illustrative/Artistic"
144
- ])
145
-
146
- # Add color selection with predefined options
147
- color_options = ["None", "Black", "White", "Red", "Blue", "Green", "Yellow", "Purple"]
148
- selected_color = st.selectbox("Choose a dominant color for the image", color_options)
149
-
150
  description = st.text_area("Enter prompt for Advertisement:")
151
  if st.button("Use Advertisement Generator", key="ad_generator_button"):
152
  st.session_state.show_ad_generator = True
@@ -154,25 +129,57 @@ def generate_poster():
154
  if st.session_state.get('show_ad_generator', False):
155
  with st.expander("Advertisement Generator :arrow_right:", expanded=True):
156
  advertisement_generator()
157
- header = st.text_input("Enter Header for Advertisement:")
158
- sub_header = st.text_input("Enter Sub-header for Advertisement:")
159
- # Allow multiple user prompts
160
- user_prompts = []
161
- num_prompts = st.number_input("Number of Text Descriptions", min_value=1, max_value=80, value=1)
162
- for i in range(num_prompts):
163
- user_prompt = st.text_area(f"Enter Descriptions to display in the image (Descriptions {i+1}):")
164
- user_prompts.append(user_prompt)
165
-
166
- logo = st.file_uploader("Upload Logo (optional)", type=['png', 'jpg', 'jpeg'])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
 
168
- # Add logo position selection
169
- logo_position = st.selectbox("Select Logo Position", [
170
- "None", "Top Left", "Top Middle", "Top Right",
171
- "Left Middle", "Right Middle",
172
- "Bottom Left", "Bottom Middle", "Bottom Right"
173
- ])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
 
175
- num_images = st.number_input("Number of Images", min_value=4, max_value=8, value=4)
176
 
177
  if st.button("Generate Images"):
178
  base_prompt = f"Create a minimalistic and realistic poster image with the following text as the header: '{header}'. Use '{sub_header}' as the sub-header. Use this design style and go with this {design_style.lower()} style for the post. Include the following text as the description for the advertisement: {description}. The image should have an aspect ratio of {aspect_ratio} and dimensions of {width}x{height}. Use {selected_color.lower()} as the dominant color in the image. Ensure the image is in 4k high resolution. And do not include any extra text in the image only instruction text included.And try to fill the vacant part with releveng images. Make the design clean and elegant, focusing on simplicity and realism."
@@ -533,7 +540,7 @@ def remove_background(image):
533
  # Main Streamlit App
534
  def main():
535
  # Add logo to the middle of the sidebar
536
- logo = Image.open("logo.jpg") # Replace with your logo path
537
  col1, col2, col3 = st.sidebar.columns([1, 2, 1])
538
  with col2:
539
  st.image(logo, width=150)
@@ -550,37 +557,37 @@ def main():
550
  st.title(title)
551
  st.write(description)
552
 
553
- st.sidebar.markdown("### Poster Generation")
554
- if st.sidebar.button("Go to Poster Generation"):
555
  st.session_state.page = "poster_generation"
556
- st.sidebar.markdown("Create eye-catching posters for various platforms.")
557
 
558
- st.sidebar.markdown("### Image to Image Generation")
559
- if st.sidebar.button("Go to Image to Image Generation"):
560
  st.session_state.page = "text_to_image"
561
- st.sidebar.markdown("Transform your ideas into stunning visuals.")
562
 
563
- st.sidebar.markdown("### Image Editing")
564
- if st.sidebar.button("Go to Image Editing"):
565
  st.session_state.page = "image_editing"
566
- st.sidebar.markdown("Enhance and modify your images with powerful tools.")
567
 
568
- st.sidebar.markdown("### Advertisement Generator")
569
- if st.sidebar.button("Go to Advertisement Generator"):
570
  st.session_state.page = "advertisement_generator"
571
- st.sidebar.markdown("Create compelling advertisements with AI assistance.")
572
 
573
  if st.session_state.page == "text_to_image":
574
- display_logo_and_description("Marketing Reimagined With AI", "Transform your ideas into stunning visuals.")
575
  text_to_image_generation()
576
  elif st.session_state.page == "image_editing":
577
- display_logo_and_description("Marketing Reimagined With AI", "Enhance and modify your images with powerful tools.")
578
  image_editing()
579
  elif st.session_state.page == "poster_generation":
580
- display_logo_and_description("Marketing Reimagined With AI", "Create eye-catching posters for various platforms.")
581
  generate_poster()
582
  elif st.session_state.page == "advertisement_generator":
583
- display_logo_and_description("Marketing Reimagined With AI", "Create compelling advertisements with AI assistance.")
584
  advertisement_generator()
585
 
586
  def text_to_image_generation():
 
122
 
123
  def generate_poster():
124
  #st.header("Generate Social Media Post")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  description = st.text_area("Enter prompt for Advertisement:")
126
  if st.button("Use Advertisement Generator", key="ad_generator_button"):
127
  st.session_state.show_ad_generator = True
 
129
  if st.session_state.get('show_ad_generator', False):
130
  with st.expander("Advertisement Generator :arrow_right:", expanded=True):
131
  advertisement_generator()
132
+
133
+ st.header("Graphic Type")
134
+ col1, col2 = st.columns(2)
135
+ with col1:
136
+ post_type = st.selectbox("Select Post Type", ["Instagram advertisement post", "Facebook advertisement post", "Twitter advertisement post", "Other"])
137
+ aspect_ratio = st.selectbox("Select Image Aspect Ratio", ["1:1", "16:9", "4:5", "9:16"])
138
+ with col2:
139
+ # Add dimension selection based on aspect ratio
140
+ if aspect_ratio == "1:1":
141
+ dimensions = st.selectbox("Select Image Dimensions", ["1080x1080", "1200x1200", "1500x1500"])
142
+ elif aspect_ratio == "16:9":
143
+ dimensions = st.selectbox("Select Image Dimensions", ["1920x1080", "1280x720", "2560x1440"])
144
+ elif aspect_ratio == "4:5":
145
+ dimensions = st.selectbox("Select Image Dimensions", ["1080x1350", "1200x1500", "1600x2000"])
146
+ elif aspect_ratio == "9:16":
147
+ dimensions = st.selectbox("Select Image Dimensions", ["1080x1920", "1350x2400", "1600x2844"])
148
+
149
+ design_style = st.selectbox("Select Design Style", [
150
+ "Minimalistic", "Bold/Graphic", "Elegant", "Playful/Fun",
151
+ "Corporate/Professional", "Retro/Vintage", "Modern/Contemporary", "Illustrative/Artistic"
152
+ ])
153
+
154
+ # Extract width and height from the selected dimensions
155
+ width, height = map(int, dimensions.split('x'))
156
+
157
+ st.header("Content")
158
 
159
+ with st.expander("Content Details", expanded=False):
160
+ # Add color selection with predefined options
161
+ color_options = ["None", "Black", "White", "Red", "Blue", "Green", "Yellow", "Purple"]
162
+ selected_color = st.selectbox("Choose a dominant color for the image", color_options)
163
+
164
+ header = st.text_input("Enter Header for Advertisement:")
165
+ sub_header = st.text_input("Enter Sub-header for Advertisement:")
166
+ # Allow multiple user prompts
167
+ user_prompts = []
168
+ num_prompts = st.number_input("Number of Text Descriptions", min_value=1, max_value=80, value=1)
169
+ for i in range(num_prompts):
170
+ user_prompt = st.text_area(f"Enter Descriptions to display in the image (Descriptions {i+1}):")
171
+ user_prompts.append(user_prompt)
172
+
173
+ logo = st.file_uploader("Upload Logo (optional)", type=['png', 'jpg', 'jpeg'])
174
+
175
+ # Add logo position selection
176
+ logo_position = st.selectbox("Select Logo Position", [
177
+ "None", "Top Left", "Top Middle", "Top Right",
178
+ "Left Middle", "Right Middle",
179
+ "Bottom Left", "Bottom Middle", "Bottom Right"
180
+ ])
181
 
182
+ num_images = st.number_input("Number of Images", min_value=4, max_value=100, value=4)
183
 
184
  if st.button("Generate Images"):
185
  base_prompt = f"Create a minimalistic and realistic poster image with the following text as the header: '{header}'. Use '{sub_header}' as the sub-header. Use this design style and go with this {design_style.lower()} style for the post. Include the following text as the description for the advertisement: {description}. The image should have an aspect ratio of {aspect_ratio} and dimensions of {width}x{height}. Use {selected_color.lower()} as the dominant color in the image. Ensure the image is in 4k high resolution. And do not include any extra text in the image only instruction text included.And try to fill the vacant part with releveng images. Make the design clean and elegant, focusing on simplicity and realism."
 
540
  # Main Streamlit App
541
  def main():
542
  # Add logo to the middle of the sidebar
543
+ logo = Image.open("Mark8 AI.png") # Replace with your logo path
544
  col1, col2, col3 = st.sidebar.columns([1, 2, 1])
545
  with col2:
546
  st.image(logo, width=150)
 
557
  st.title(title)
558
  st.write(description)
559
 
560
+ #st.sidebar.markdown("### Poster Generation")
561
+ if st.sidebar.button("Poster Generation"):
562
  st.session_state.page = "poster_generation"
563
+ #st.sidebar.markdown("Create eye-catching posters for various platforms.")
564
 
565
+ # st.sidebar.markdown("### Image to Image Generation")
566
+ if st.sidebar.button("Image to Image Generation"):
567
  st.session_state.page = "text_to_image"
568
+ #st.sidebar.markdown("Transform your ideas into stunning visuals.")
569
 
570
+ #st.sidebar.markdown("### Image Editing")
571
+ if st.sidebar.button("Image Editing"):
572
  st.session_state.page = "image_editing"
573
+ #st.sidebar.markdown("Enhance and modify your images with powerful tools.")
574
 
575
+ #st.sidebar.markdown("### Advertisement Generator")
576
+ if st.sidebar.button("Advertisement Generator"):
577
  st.session_state.page = "advertisement_generator"
578
+ #st.sidebar.markdown("Create compelling advertisements with AI assistance.")
579
 
580
  if st.session_state.page == "text_to_image":
581
+ display_logo_and_description("Graphic Generator", "Transform your ideas into stunning visuals.")
582
  text_to_image_generation()
583
  elif st.session_state.page == "image_editing":
584
+ display_logo_and_description("Graphic Generator", "Enhance and modify your images with powerful tools.")
585
  image_editing()
586
  elif st.session_state.page == "poster_generation":
587
+ display_logo_and_description("Graphic Generator", "Create eye-catching posters for various platforms.")
588
  generate_poster()
589
  elif st.session_state.page == "advertisement_generator":
590
+ display_logo_and_description("Graphic Generator", "Create compelling advertisements with AI assistance.")
591
  advertisement_generator()
592
 
593
  def text_to_image_generation():