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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import random
|
| 4 |
+
import itertools
|
| 5 |
+
import emoji
|
| 6 |
+
|
| 7 |
+
# Set page config
|
| 8 |
+
st.set_page_config(
|
| 9 |
+
page_title="๐ฐ Prompt Universe Generator",
|
| 10 |
+
layout="wide",
|
| 11 |
+
initial_sidebar_state="expanded"
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
# Custom CSS
|
| 15 |
+
st.markdown("""
|
| 16 |
+
<style>
|
| 17 |
+
.stButton > button {
|
| 18 |
+
background-color: #4CAF50;
|
| 19 |
+
color: white;
|
| 20 |
+
font-size: 16px;
|
| 21 |
+
padding: 15px 30px;
|
| 22 |
+
border-radius: 10px;
|
| 23 |
+
border: none;
|
| 24 |
+
}
|
| 25 |
+
.slot-machine {
|
| 26 |
+
background-color: #f0f2f6;
|
| 27 |
+
padding: 20px;
|
| 28 |
+
border-radius: 10px;
|
| 29 |
+
margin: 10px 0;
|
| 30 |
+
}
|
| 31 |
+
.category-header {
|
| 32 |
+
font-size: 24px;
|
| 33 |
+
font-weight: bold;
|
| 34 |
+
margin: 20px 0;
|
| 35 |
+
}
|
| 36 |
+
</style>
|
| 37 |
+
""", unsafe_allow_html=True)
|
| 38 |
+
|
| 39 |
+
# Define our expanded categories with emoji themes
|
| 40 |
+
PROMPT_CATEGORIES = {
|
| 41 |
+
"โจ Magical Realms": {
|
| 42 |
+
"prompts": [
|
| 43 |
+
"ethereal crystalline monarch | 8k hyperdetailed cinematic | bioluminescent highlights",
|
| 44 |
+
"neo-victorian cyberpunk teahouse | volumetric fog | copper accents",
|
| 45 |
+
"fractalized coral reef dreamscape | pearl iridescence | fluid dynamics",
|
| 46 |
+
"astral wolf constellation | cosmic dust | northern lights palette",
|
| 47 |
+
"art nouveau forest spirit | golden hour | dewdrop details",
|
| 48 |
+
"quantum mechanical butterfly | holographic wings | infrared spectrum",
|
| 49 |
+
"volcanic glass sculpture | obsidian reflections | ember glow",
|
| 50 |
+
"time-worn steampunk clocktower | brass patina | morning mist",
|
| 51 |
+
"deep sea biopunk garden | phosphorescent jellies | aquatic currents",
|
| 52 |
+
"frost giant's library | ice crystal formations | aurora ambient lighting"
|
| 53 |
+
],
|
| 54 |
+
"emoji": "๐"
|
| 55 |
+
},
|
| 56 |
+
|
| 57 |
+
"๐จ Color Harmonies": {
|
| 58 |
+
"prompts": [
|
| 59 |
+
"Crimson and Onyx | dark cathedral architecture | obsidian reflections",
|
| 60 |
+
"Emerald and Antique Gold | overgrown temple ruins | dappled sunlight",
|
| 61 |
+
"Royal Purple and Solar Gold | cosmic throne room | nebula wisps",
|
| 62 |
+
"Sapphire and Silver | frozen palace | moonlight refractions",
|
| 63 |
+
"Amber and Midnight Blue | twilight desert palace | star trails",
|
| 64 |
+
"Jade and Bronze | ancient forest sanctuary | morning mist",
|
| 65 |
+
"Ruby and Platinum | dragon's treasure vault | gemstone reflections",
|
| 66 |
+
"Amethyst and Pearl | ethereal spirit realm | iridescent fog",
|
| 67 |
+
"Copper and Teal | oceanic steampunk | patina patterns",
|
| 68 |
+
"Ivory and Blood Red | samurai dojo | cherry blossom storm"
|
| 69 |
+
],
|
| 70 |
+
"emoji": "๐ญ"
|
| 71 |
+
},
|
| 72 |
+
|
| 73 |
+
"๐ผ๏ธ Artistic Masters": {
|
| 74 |
+
"prompts": [
|
| 75 |
+
"Bosch's Garden of Delights | mechanical hybrid creatures | crystalline pools",
|
| 76 |
+
"Zaha Hadid | flowing parametric curves | chrome and glass",
|
| 77 |
+
"Klimt's Golden Phase | art nouveau patterns | metallic leaf textures",
|
| 78 |
+
"Frank Gehry | deconstructed titanium surfaces | sunset reflections",
|
| 79 |
+
"Dali's Melting World | liquid clocks | desert mirage effects",
|
| 80 |
+
"Jeff Koons | balloon animal metallic | perfect reflection mapping",
|
| 81 |
+
"Gaudi's Organic Forms | mosaic textures | Mediterranean light",
|
| 82 |
+
"Alphonse Mucha | art nouveau female figures | flowing hair details",
|
| 83 |
+
"Frank Lloyd Wright | prairie style geometry | stained glass lighting",
|
| 84 |
+
"HR Giger | biomechanical corridors | dark chrome details"
|
| 85 |
+
],
|
| 86 |
+
"emoji": "๐จโ๐จ"
|
| 87 |
+
},
|
| 88 |
+
|
| 89 |
+
"๐ Quantum Vehicles": {
|
| 90 |
+
"prompts": [
|
| 91 |
+
"Quantum Glass Semi-House | aerodynamic living quarters | transparent structural planes",
|
| 92 |
+
"Levitating Truck Platform | crystalline habitat modules | floating staircase connectivity",
|
| 93 |
+
"Metamaterial Highway Manor | prismatic solar walls | flowing energy conduits",
|
| 94 |
+
"Transparent Titanium Hauler | modular living pods | geometric strength patterns",
|
| 95 |
+
"Photonic Crystal Cabin | light-filtering smart glass | suspended garden terrace",
|
| 96 |
+
"Nano-reinforced Road Palace | panoramic plexiglass shell | flowing interior levels",
|
| 97 |
+
"Quantum-Strengthened Caravan | transparent load-bearing walls | floating deck design",
|
| 98 |
+
"Biomimetic Transport Home | adaptive opacity glass | organic support structures",
|
| 99 |
+
"Holographic Highway Home | diamond-matrix viewport | suspended living spaces",
|
| 100 |
+
"Molecular-Perfect Transport | clear carbon construction | anti-gravity aesthetics"
|
| 101 |
+
],
|
| 102 |
+
"emoji": "๐ฎ"
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
def generate_random_combination():
|
| 107 |
+
"""Generate a random combination from each category"""
|
| 108 |
+
combination = []
|
| 109 |
+
for category in PROMPT_CATEGORIES.values():
|
| 110 |
+
combination.append(random.choice(category["prompts"]))
|
| 111 |
+
return combination
|
| 112 |
+
|
| 113 |
+
def create_prompt_dataframe():
|
| 114 |
+
"""Create a DataFrame with all possible combinations"""
|
| 115 |
+
all_combinations = list(itertools.product(*[cat["prompts"] for cat in PROMPT_CATEGORIES.values()]))
|
| 116 |
+
df = pd.DataFrame(all_combinations, columns=list(PROMPT_CATEGORIES.keys()))
|
| 117 |
+
return df
|
| 118 |
+
|
| 119 |
+
# Initialize session state
|
| 120 |
+
if 'generated_prompts' not in st.session_state:
|
| 121 |
+
st.session_state.generated_prompts = []
|
| 122 |
+
|
| 123 |
+
# Title and description
|
| 124 |
+
st.title("๐ฐ Prompt Universe Generator")
|
| 125 |
+
st.markdown("### Where Imagination Meets Infinite Possibilities!")
|
| 126 |
+
|
| 127 |
+
# Sidebar controls
|
| 128 |
+
st.sidebar.header("๐ฎ Control Panel")
|
| 129 |
+
selected_categories = st.sidebar.multiselect(
|
| 130 |
+
"Choose Categories to Include",
|
| 131 |
+
list(PROMPT_CATEGORIES.keys()),
|
| 132 |
+
default=list(PROMPT_CATEGORIES.keys())
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
# Create main tabs
|
| 136 |
+
tab1, tab2, tab3 = st.tabs(["๐ฒ Prompt Slot Machine", "๐ Prompt Workshop", "๐ Prompt Explorer"])
|
| 137 |
+
|
| 138 |
+
with tab1:
|
| 139 |
+
if st.button("๐ฐ Spin the Wheels of Creation!", key="slot_machine"):
|
| 140 |
+
combination = []
|
| 141 |
+
for category in selected_categories:
|
| 142 |
+
prompt = random.choice(PROMPT_CATEGORIES[category]["prompts"])
|
| 143 |
+
combination.append(prompt)
|
| 144 |
+
st.session_state.generated_prompts.append(combination)
|
| 145 |
+
|
| 146 |
+
# Display in a grid
|
| 147 |
+
cols = st.columns(len(selected_categories))
|
| 148 |
+
for i, (category, prompt) in enumerate(zip(selected_categories, combination)):
|
| 149 |
+
with cols[i]:
|
| 150 |
+
st.markdown(f"### {category}")
|
| 151 |
+
st.markdown(f"**{prompt}**")
|
| 152 |
+
|
| 153 |
+
# Final combined prompt
|
| 154 |
+
st.markdown("### ๐จ Combined Prompt:")
|
| 155 |
+
final_prompt = " || ".join(combination)
|
| 156 |
+
st.code(final_prompt, language="markdown")
|
| 157 |
+
|
| 158 |
+
with tab2:
|
| 159 |
+
st.markdown("### ๐ ๏ธ Custom Prompt Workshop")
|
| 160 |
+
|
| 161 |
+
# Create an editable dataframe of recent generations
|
| 162 |
+
if st.session_state.generated_prompts:
|
| 163 |
+
df = pd.DataFrame(st.session_state.generated_prompts, columns=selected_categories)
|
| 164 |
+
edited_df = st.data_editor(
|
| 165 |
+
df,
|
| 166 |
+
num_rows="dynamic",
|
| 167 |
+
use_container_width=True,
|
| 168 |
+
key="prompt_editor"
|
| 169 |
+
)
|
| 170 |
+
|
| 171 |
+
if st.button("๐ซ Generate from Selection"):
|
| 172 |
+
selected_prompt = " || ".join(edited_df.iloc[0].values)
|
| 173 |
+
st.code(selected_prompt, language="markdown")
|
| 174 |
+
|
| 175 |
+
with tab3:
|
| 176 |
+
st.markdown("### ๐ฎ Explore All Possibilities")
|
| 177 |
+
|
| 178 |
+
# Category viewer
|
| 179 |
+
category = st.selectbox("Choose a Category to Explore", list(PROMPT_CATEGORIES.keys()))
|
| 180 |
+
|
| 181 |
+
if category:
|
| 182 |
+
st.markdown(f"### {PROMPT_CATEGORIES[category]['emoji']} {category} Prompts")
|
| 183 |
+
for prompt in PROMPT_CATEGORIES[category]["prompts"]:
|
| 184 |
+
st.markdown(f"- {prompt}")
|
| 185 |
+
|
| 186 |
+
# Random sampler
|
| 187 |
+
if st.button("๐ฒ Sample Random Combination"):
|
| 188 |
+
random_prompts = generate_random_combination()
|
| 189 |
+
st.code(" || ".join(random_prompts), language="markdown")
|
| 190 |
+
|
| 191 |
+
# Footer with tips
|
| 192 |
+
st.markdown("---")
|
| 193 |
+
st.markdown("### ๐ Pro Tips")
|
| 194 |
+
st.markdown("""
|
| 195 |
+
* Combine prompts from different categories for unique results
|
| 196 |
+
* Use the workshop to fine-tune your combinations
|
| 197 |
+
* Save your favorite prompts by copying them
|
| 198 |
+
* Experiment with different category combinations
|
| 199 |
+
* Add quality specifiers like '8k upscale' to any prompt
|
| 200 |
+
""")
|
| 201 |
+
|
| 202 |
+
# Credits
|
| 203 |
+
st.sidebar.markdown("---")
|
| 204 |
+
st.sidebar.markdown("### ๐จ Prompt Categories")
|
| 205 |
+
for category, data in PROMPT_CATEGORIES.items():
|
| 206 |
+
st.sidebar.markdown(f"{data['emoji']} {category}")
|