charlestrusgh's picture
Update app.py
042199b verified
import gradio as gr
import random
# Predefined outfit components
OUTFIT_COMPONENTS = {
"tops": [
"Lace-trimmed crop top",
"Silk blouse with bow tie",
"Off-shoulder sweater",
"Ruffled poet shirt",
"Sheer mesh top",
"Velvet corset top",
"Satain camisole",
"Chiffon tunic",
"Fishnet top under sheer cover-up",
"Crop top with heart cutout",
"Transparent blouse with floral embroidery"
],
"bottoms": [
"High-waisted pleated skirt",
"Velvet mini skirt",
"Lace-up leather pants",
"Flowy maxi skirt",
"Pleated tennis skirt",
"High-waisted wide-leg trousers",
"Lace shorts with ribbon ties",
"Tiered ruffle skirt",
"Fishnet stockings under mini",
"Ripped skinny jeans",
"Silk wide-leg pants"
],
"accesories": [
"Choker with pendant",
"Lace gloves",
"Hair ribbons",
"Knee-high socks with lace trim",
"Charm bracelet set",
"Cat ears headband",
"Lace choker with heart lock",
"Pearl necklace",
"Fishnet arm sleeves",
"Velvet choker with cross",
"Sheer thigh-highs",
"Delicate anklet",
"Flower hair clip"
],
"footwear": [
"Mary Jane heels",
"Platform boots",
"Ballet flats with ribbons",
"Stokings with lace tops",
"Ankle boots with bows"
]
}
def generate_femboy_outfit(style_preference, color_palete):
"""Generate a beautiful femboy outfit based on user preferences"""
# Validate inputs
if not style_preference.strip():
return "Please enter your style preferences to generate an outfit."
# Generate random outfit
top = random.choice(OUTFIT_COMPONENTS["tops"])
bottom = random.choice(OUTFIT_COMPONENTS["bottoms"])
accecories = random.sample(OUTFIT_COMPONENTS["accesories"], k=3)
footwear = random.choice(OUTFIT_COMPONENTS["footwear"])
# Create outfit description
outfit = f"""
🌸 **Your Femboy Outfit Creation** 🌸
**Style Theme:** {style_preference}
**Color Palette:** {color_palete}
**Outfit Components:**
β€’ **Top:** {top}
β€’ **Bottom:** {bottom}
β€’ **Footwear:** {footwear}
β€’ **Accessories:** {', '.join(accecories)}
**Outfit Story:**
This enchanting ensemble combines delicate femininity with confident expression. The {color_palete} palette creates a harmonious balance that celebrates soft beauty while maintaining personal style.
πŸ’« **Outfit Vibe:** {random.choice(['Sweet Lolita', 'Elegant Goth', 'Soft Fairycore', 'Kawaii Streetwear'])}
**Styling Tips:**
β€’ Pair with soft, natural makeup
β€’ Add subtle floral perfume
β€’ Style hair with soft waves or braids
"""
return outfit
def save_outfit(outfit_text):
"""Save the generated outfit to a file"""
if not outfit_text or "Please enter" in outfit_text:
return "No outfit to save. Please generate an outfit first."
try:
with open("generated_outfits.txt", "a", encoding="utf-8") as f:
f.write(f"\n{'='*50}\n")
f.write(outfit_text)
f.write(f"\n{'='*50}\n")
return "✨ Outfit saved to 'generated_outfits.txt'!"
except Exception as e:
return f"❌ Error saving outfit: {str(e)}"
# Create custom theme for feminine aesthetics
feminine_theme = gr.themes.Soft(
primary_hue="pink",
secondary_hue="purple",
neutral_hue="slate",
font=gr.themes.GoogleFont("Playfair Display"),
text_size="lg",
spacing_size="lg",
radius_size="md"
).set(
button_primary_background_fill="*primary_500",
button_primary_background_fill_hover="*primary_600",
button_primary_text_color="white",
block_title_text_weight="600",
block_label_text_weight="500"
)
with gr.Blocks() as demo:
gr.Markdown(
"""
# 🌸 Femboy Outfit Generator 🌸
*Create beautiful, feminine outfits that celebrate soft aesthetics and personal expression*
✨ *Built with [anycoder](https://huggingface.co/spaces/akhaliq/anycoder) ✨
""",
elem_classes=["header-section"]
)
with gr.Row():
with gr.Column(scale=1):
gr.Markdown("### πŸŽ€ Your Style Preferences")
style_preference = gr.Textbox(
label="Describe your desired style",
placeholder="e.g., soft fairycore, elegant goth, kawaii streetwear...",
lines=2,
placeholder="Share your aesthetic vision...",
elem_classes=["input-section"]
)
color_palete = gr.Dropdown(
choices=["Pastel Pinks", "Lavender Dreams", "Moonlight Silvers", "Rose Gold Elegance", "Velvet Romance"],
info="Be as detailed as you like! The more specific, the more personalized your outfit will be."
)
with gr.Row():
generate_btn = gr.Button(
"✨ Generate Magical Outfit",
variant="primary",
elem_classes=["generate-button"]
)
with gr.Column(scale=1):
gr.Markdown("### 🎨 Color Inspiration")
palette_examples = gr.Gallery(
label="Color Palette Inspirations",
columns=3,
height=200,
object_fit="cover",
elem_classes=["palette-section"]
)
with gr.Row():
outfit_output = gr.Markdown(
label="🌟 Your Generatd Outfit",
value="**Your magical outfit awaits...** ✨",
elem_classes=["output-section"]
)
with gr.Row():
with gr.Column():
save_btn = gr.Button("πŸ’Ύ Save This Outfit")
save_status = gr.Markdown("")
# Event listeners
generate_btn.click(
fn=generate_femboy_outfit,
inputs=[style_preference, color_palete],
outputs=[outfit_output],
api_visibility="public"
)
save_btn.click(
fn=save_outfit,
inputs=[outfit_output],
outputs=[save_status],
api_visibility="public"
)
if __name__ == "__main__":
demo.launch(
theme=feminine_theme,
css="""
.header-section {
text-align: center;
background: linear-gradient(135deg, #f9c5d1, #d5c6e0, #b8bedd"])
.gradio-container {
background: linear-gradient(135deg, #fef6ff, #f5f0ff, #e8e6ff"])
}
.generate-button {
background: linear-gradient(45deg, #ff85a2, #a28bff, #85a3ff"])
.input-section {
background: rgba(255, 255, 255, 0.8]);
backdrop-filter: blur(10px);
border-radius: 20px;
padding: 20px;
box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37]);
border: 2px solid rgba(255, 255, 255, 0.5]);
}
""",
footer_links=[{"label": "✨ Built with anycoder", "url": "https://huggingface.co/spaces/akhaliq/anycoder"}]
)