Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import random | |
| import itertools | |
| import emoji | |
| # Set page config | |
| st.set_page_config( | |
| page_title="๐ฐ Prompt Universe Generator", | |
| layout="wide", | |
| initial_sidebar_state="expanded" | |
| ) | |
| # Custom CSS | |
| st.markdown(""" | |
| <style> | |
| .stButton > button { | |
| background-color: #4CAF50; | |
| color: white; | |
| font-size: 16px; | |
| padding: 15px 30px; | |
| border-radius: 10px; | |
| border: none; | |
| } | |
| .slot-machine { | |
| background-color: #f0f2f6; | |
| padding: 20px; | |
| border-radius: 10px; | |
| margin: 10px 0; | |
| } | |
| .category-header { | |
| font-size: 24px; | |
| font-weight: bold; | |
| margin: 20px 0; | |
| } | |
| </style> | |
| """, unsafe_allow_html=True) | |
| # Define our expanded categories with emoji themes | |
| PROMPT_CATEGORIES = { | |
| "โจ Magical Realms": { | |
| "prompts": [ | |
| "ethereal crystalline monarch | 8k hyperdetailed cinematic | bioluminescent highlights", | |
| "neo-victorian cyberpunk teahouse | volumetric fog | copper accents", | |
| "fractalized coral reef dreamscape | pearl iridescence | fluid dynamics", | |
| "astral wolf constellation | cosmic dust | northern lights palette", | |
| "art nouveau forest spirit | golden hour | dewdrop details", | |
| "quantum mechanical butterfly | holographic wings | infrared spectrum", | |
| "volcanic glass sculpture | obsidian reflections | ember glow", | |
| "time-worn steampunk clocktower | brass patina | morning mist", | |
| "deep sea biopunk garden | phosphorescent jellies | aquatic currents", | |
| "frost giant's library | ice crystal formations | aurora ambient lighting" | |
| ], | |
| "emoji": "๐" | |
| }, | |
| "๐จ Color Harmonies": { | |
| "prompts": [ | |
| "Crimson and Onyx | dark cathedral architecture | obsidian reflections", | |
| "Emerald and Antique Gold | overgrown temple ruins | dappled sunlight", | |
| "Royal Purple and Solar Gold | cosmic throne room | nebula wisps", | |
| "Sapphire and Silver | frozen palace | moonlight refractions", | |
| "Amber and Midnight Blue | twilight desert palace | star trails", | |
| "Jade and Bronze | ancient forest sanctuary | morning mist", | |
| "Ruby and Platinum | dragon's treasure vault | gemstone reflections", | |
| "Amethyst and Pearl | ethereal spirit realm | iridescent fog", | |
| "Copper and Teal | oceanic steampunk | patina patterns", | |
| "Ivory and Blood Red | samurai dojo | cherry blossom storm" | |
| ], | |
| "emoji": "๐ญ" | |
| }, | |
| "๐ผ๏ธ Artistic Masters": { | |
| "prompts": [ | |
| "Bosch's Garden of Delights | mechanical hybrid creatures | crystalline pools", | |
| "Zaha Hadid | flowing parametric curves | chrome and glass", | |
| "Klimt's Golden Phase | art nouveau patterns | metallic leaf textures", | |
| "Frank Gehry | deconstructed titanium surfaces | sunset reflections", | |
| "Dali's Melting World | liquid clocks | desert mirage effects", | |
| "Jeff Koons | balloon animal metallic | perfect reflection mapping", | |
| "Gaudi's Organic Forms | mosaic textures | Mediterranean light", | |
| "Alphonse Mucha | art nouveau female figures | flowing hair details", | |
| "Frank Lloyd Wright | prairie style geometry | stained glass lighting", | |
| "HR Giger | biomechanical corridors | dark chrome details" | |
| ], | |
| "emoji": "๐จโ๐จ" | |
| }, | |
| "๐ Quantum Vehicles": { | |
| "prompts": [ | |
| "Quantum Glass Semi-House | aerodynamic living quarters | transparent structural planes", | |
| "Levitating Truck Platform | crystalline habitat modules | floating staircase connectivity", | |
| "Metamaterial Highway Manor | prismatic solar walls | flowing energy conduits", | |
| "Transparent Titanium Hauler | modular living pods | geometric strength patterns", | |
| "Photonic Crystal Cabin | light-filtering smart glass | suspended garden terrace", | |
| "Nano-reinforced Road Palace | panoramic plexiglass shell | flowing interior levels", | |
| "Quantum-Strengthened Caravan | transparent load-bearing walls | floating deck design", | |
| "Biomimetic Transport Home | adaptive opacity glass | organic support structures", | |
| "Holographic Highway Home | diamond-matrix viewport | suspended living spaces", | |
| "Molecular-Perfect Transport | clear carbon construction | anti-gravity aesthetics" | |
| ], | |
| "emoji": "๐ฎ" | |
| } | |
| } | |
| def generate_random_combination(): | |
| """Generate a random combination from each category""" | |
| combination = [] | |
| for category in PROMPT_CATEGORIES.values(): | |
| combination.append(random.choice(category["prompts"])) | |
| return combination | |
| def create_prompt_dataframe(): | |
| """Create a DataFrame with all possible combinations""" | |
| all_combinations = list(itertools.product(*[cat["prompts"] for cat in PROMPT_CATEGORIES.values()])) | |
| df = pd.DataFrame(all_combinations, columns=list(PROMPT_CATEGORIES.keys())) | |
| return df | |
| # Initialize session state | |
| if 'generated_prompts' not in st.session_state: | |
| st.session_state.generated_prompts = [] | |
| # Title and description | |
| st.title("๐ฐ Prompt Universe Generator") | |
| st.markdown("### Where Imagination Meets Infinite Possibilities!") | |
| # Sidebar controls | |
| st.sidebar.header("๐ฎ Control Panel") | |
| selected_categories = st.sidebar.multiselect( | |
| "Choose Categories to Include", | |
| list(PROMPT_CATEGORIES.keys()), | |
| default=list(PROMPT_CATEGORIES.keys()) | |
| ) | |
| # Create main tabs | |
| tab1, tab2, tab3 = st.tabs(["๐ฒ Prompt Slot Machine", "๐ Prompt Workshop", "๐ Prompt Explorer"]) | |
| with tab1: | |
| if st.button("๐ฐ Spin the Wheels of Creation!", key="slot_machine"): | |
| combination = [] | |
| for category in selected_categories: | |
| prompt = random.choice(PROMPT_CATEGORIES[category]["prompts"]) | |
| combination.append(prompt) | |
| st.session_state.generated_prompts.append(combination) | |
| # Display in a grid | |
| cols = st.columns(len(selected_categories)) | |
| for i, (category, prompt) in enumerate(zip(selected_categories, combination)): | |
| with cols[i]: | |
| st.markdown(f"### {category}") | |
| st.markdown(f"**{prompt}**") | |
| # Final combined prompt | |
| st.markdown("### ๐จ Combined Prompt:") | |
| final_prompt = " || ".join(combination) | |
| st.code(final_prompt, language="markdown") | |
| with tab2: | |
| st.markdown("### ๐ ๏ธ Custom Prompt Workshop") | |
| # Create an editable dataframe of recent generations | |
| if st.session_state.generated_prompts: | |
| df = pd.DataFrame(st.session_state.generated_prompts, columns=selected_categories) | |
| edited_df = st.data_editor( | |
| df, | |
| num_rows="dynamic", | |
| use_container_width=True, | |
| key="prompt_editor" | |
| ) | |
| if st.button("๐ซ Generate from Selection"): | |
| selected_prompt = " || ".join(edited_df.iloc[0].values) | |
| st.code(selected_prompt, language="markdown") | |
| with tab3: | |
| st.markdown("### ๐ฎ Explore All Possibilities") | |
| # Category viewer | |
| category = st.selectbox("Choose a Category to Explore", list(PROMPT_CATEGORIES.keys())) | |
| if category: | |
| st.markdown(f"### {PROMPT_CATEGORIES[category]['emoji']} {category} Prompts") | |
| for prompt in PROMPT_CATEGORIES[category]["prompts"]: | |
| st.markdown(f"- {prompt}") | |
| # Random sampler | |
| if st.button("๐ฒ Sample Random Combination"): | |
| random_prompts = generate_random_combination() | |
| st.code(" || ".join(random_prompts), language="markdown") | |
| # Footer with tips | |
| st.markdown("---") | |
| st.markdown("### ๐ Pro Tips") | |
| st.markdown(""" | |
| * Combine prompts from different categories for unique results | |
| * Use the workshop to fine-tune your combinations | |
| * Save your favorite prompts by copying them | |
| * Experiment with different category combinations | |
| * Add quality specifiers like '8k upscale' to any prompt | |
| """) | |
| # Credits | |
| st.sidebar.markdown("---") | |
| st.sidebar.markdown("### ๐จ Prompt Categories") | |
| for category, data in PROMPT_CATEGORIES.items(): | |
| st.sidebar.markdown(f"{data['emoji']} {category}") |