Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,82 +1,79 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
from transformers import pipeline
|
| 4 |
-
import
|
| 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 |
-
|
| 19 |
-
|
| 20 |
-
personality = generator(personality_prompt, max_length=40, num_return_sequences=1)[0]['generated_text']
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
| 25 |
|
| 26 |
-
|
| 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 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
audience.strip(),
|
| 40 |
-
slogan.strip()
|
| 41 |
-
)
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
}
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
""
|
|
|
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 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 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.")
|