OLIVE2403 commited on
Commit
d90a0e0
Β·
verified Β·
1 Parent(s): c19c007

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -71
app.py CHANGED
@@ -1,82 +1,79 @@
1
- # app.py
2
-
3
  from transformers import pipeline
4
- import gradio as gr
5
-
6
- # Load FLAN-T5-LARGE pipeline
7
- generator = pipeline("text-generation", model="gpt2-large")
8
-
9
- def generate_brand_identity(startup_idea):
10
- # Brand Names
11
- prompt_name = f"Give three short, creative, and unique brand name ideas for a startup that is {startup_idea}. Avoid repetition and ensure they are realistic for a business."
12
- brand_names = generator(prompt_name, max_length=60, num_return_sequences=1)[0]["generated_text"]
13
-
14
- # Tagline
15
- tagline_prompt = f"Generate a catchy and original tagline for a startup focused on {startup_idea}. Keep it under 10 words."
16
- tagline = generator(tagline_prompt, max_length=30, num_return_sequences=1)[0]['generated_text']
17
 
18
- # Brand Personality
19
- personality_prompt = f"Describe the brand personality of a startup doing {startup_idea} in one powerful sentence. Use descriptive adjectives, not vague words."
20
- personality = generator(personality_prompt, max_length=40, num_return_sequences=1)[0]['generated_text']
21
 
22
- # Brand Colours
23
- colours_prompt = f"Suggest a primary and secondary brand colour with HEX codes for a startup about {startup_idea}. Format: Color Name - HEX"
24
- colours = generator(colours_prompt, max_length=40, num_return_sequences=1)[0]['generated_text']
 
25
 
26
- # Target Audience
27
- audience_prompt = f"Describe the ideal target audience (age, profession, need) for a startup doing {startup_idea}."
28
- audience = generator(audience_prompt, max_length=50, num_return_sequences=1)[0]['generated_text']
29
 
30
- # Slogan
31
- slogan_prompt = f"Suggest a memorable and short slogan (max 7 words) for a startup about {startup_idea}. Make it inspirational or witty."
32
- slogan = generator(slogan_prompt, max_length=20, num_return_sequences=1)[0]['generated_text']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
- return (
35
- brand_names.strip(),
36
- tagline.strip(),
37
- personality.strip(),
38
- colours.strip(),
39
- audience.strip(),
40
- slogan.strip()
41
- )
42
 
43
- # Gradio interface with improved text clarity and appearance
44
- css = """
45
- h1 {
46
- text-align: center;
47
- color: #4A90E2;
48
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
49
- }
50
 
51
- textarea {
52
- background-color: #e6f0fa !important;
53
- color: #003366 !important;
54
- font-size: 16px !important;
55
- }
56
 
57
- footer {
58
- text-align: center;
59
- padding: 10px;
60
- color: #888;
61
- }
62
- """
 
63
 
64
- iface = gr.Interface(
65
- fn=generate_brand_identity,
66
- inputs=gr.Textbox(lines=2, placeholder="Enter your startup idea here..."),
67
- outputs=[
68
- gr.Textbox(label="Brand Name Suggestions"),
69
- gr.Textbox(label="Tagline"),
70
- gr.Textbox(label="Brand Personality Description"),
71
- gr.Textbox(label="Suggested Brand Colours"),
72
- gr.Textbox(label="Target Audience"),
73
- gr.Textbox(label="Slogan Options")
74
- ],
75
- title="🌟 Brand Identity Generator",
76
- description="Generate practical and creative brand names, taglines, brand personality descriptions, colour palettes, target audiences, and slogans for your startup idea using FLAN-T5-LARGE.",
77
- css=css,
78
- theme="soft"
79
- )
80
 
81
- if __name__ == "__main__":
82
- iface.launch()
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
 
2
  from transformers import pipeline
3
+ import torch
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
+ # Set Streamlit page configuration
6
+ st.set_page_config(page_title="Brand Identity Generator", layout="wide")
 
7
 
8
+ # Load FLAN-T5 model pipeline
9
+ @st.cache_resource
10
+ def load_model():
11
+ return pipeline("text2text-generation", model="google/flan-t5-large")
12
 
13
+ generator = load_model()
 
 
14
 
15
+ # Custom Styling (simulate CSS)
16
+ st.markdown(
17
+ """
18
+ <style>
19
+ body {
20
+ background-color: #f4f8fc;
21
+ font-family: 'Segoe UI', sans-serif;
22
+ color: #003366;
23
+ }
24
+ .stTextInput > div > div > input {
25
+ background-color: #e6f0fa;
26
+ color: #003366;
27
+ font-size: 16px;
28
+ }
29
+ </style>
30
+ """,
31
+ unsafe_allow_html=True
32
+ )
33
 
34
+ # Page Title and Description
35
+ st.markdown(
36
+ "<h1 style='text-align: center; color: #4A90E2;'>🌟 Brand Identity Generator</h1>",
37
+ unsafe_allow_html=True
38
+ )
 
 
 
39
 
40
+ st.markdown(
41
+ """
42
+ Generate **brand names**, **taglines**, **personality descriptions**, **colour palettes**, **target audiences**, and **slogans**
43
+ for your startup idea using the powerful **FLAN-T5-LARGE** model.
44
+ """
45
+ )
 
46
 
47
+ # Form Input for Startup Idea
48
+ with st.form("input_form"):
49
+ st.subheader("πŸ“Œ Describe Your Startup")
50
+ startup_idea = st.text_input("Startup Idea", placeholder="e.g. an eco-friendly fish delivery platform for urban areas")
51
+ submitted = st.form_submit_button("Generate")
52
 
53
+ # On form submission
54
+ if submitted:
55
+ if not startup_idea.strip():
56
+ st.warning("Please enter a valid startup idea.")
57
+ else:
58
+ st.markdown("---")
59
+ st.subheader("πŸ” Generated Brand Identity")
60
 
61
+ prompts = {
62
+ "Brand Name Suggestions": f"Suggest 5 original, non-generic brand names for a startup based on this idea: {startup_idea}. Make sure they are short, unique, and not repetitive.",
63
+ "Tagline": f"Write a compelling and creative tagline for this startup. Avoid repeating the brand name. Idea: {startup_idea}",
64
+ "Brand Personality Description": f"Describe in one sentence the personality of a brand that is built around the following idea: {startup_idea}. Make it lively and creative.",
65
+ "Suggested Brand Colours": f"Suggest two primary and two secondary brand colours (with hex codes) that reflect the startup idea: {startup_idea}.",
66
+ "Target Audience": f"Describe in 1–2 lines the ideal target audience for this startup idea: {startup_idea}.",
67
+ "Slogan Options": f"Suggest three short and catchy slogans that capture the spirit of this startup: {startup_idea}. Avoid repeating phrases."
68
+ }
 
 
 
 
 
 
 
 
69
 
70
+ # Generate and display each section
71
+ for section, prompt in prompts.items():
72
+ try:
73
+ with st.spinner(f"Generating {section}..."):
74
+ result = generator(prompt, max_length=80, num_return_sequences=1)[0]["generated_text"]
75
+ st.markdown(f"### {section}")
76
+ st.success(result)
77
+ except Exception as e:
78
+ st.markdown(f"### {section}")
79
+ st.error("Error generating content. Please check your connection or try again later.")