TroglodyteDerivations's picture
Upload 10 files
a0f4fa5 verified
import gradio as gr
import os
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
from datetime import datetime
# App configuration
TITLE = "πŸŽ€ Hello Kitty Powerball Holiday Extravaganza πŸ•Ž"
DESCRIPTION = """
Discover the hilarious fusion of Hello Kitty, Christmas, Hanukkah, and Powerball jackpot dreams!
Featuring AI-generated images and festive lottery humor. $1 BILLION Powerball this Saturday, Dec 13th 2025!
"""
# Sample images (you'll need to update these paths to your actual images)
IMAGE_PATHS = {
"Mail Carrier": "batch_031_20251211_201120.png",
"Doctor": "batch_032_20251211_201120.png",
"Librarian": "batch_080_20251211_201120.png"
}
# Interesting Facts
FACTS = [
"🎯 The prompts combine 3 holiday traditions: Christmas, Hanukkah, and Powerball lottery",
"⏱️ Image generation times varied from 501 seconds to over 18,000 seconds (5+ hours!)",
"πŸ“Š Each image contains 5 white ball numbers and 1 red Powerball number",
"🎨 100 unique Hello Kitty professions were generated for this project",
"πŸ•Ž Menorahs appear in every image alongside Christmas trees",
"πŸ’° The $1 billion Powerball jackpot has odds of 1 in 292.2 million",
"πŸŽ„ Hello Kitty wears different holiday outfits in each profession",
"πŸ“š Prompt #80 features a 'bookshelf Christmas tree' - a creative twist!",
"πŸ₯ Medical-themed ornaments in the doctor image include pill-shaped decorations",
"πŸ“¦ The mail carrier delivers 'gift Christmas trees' - presents within presents!"
]
# Hello Kitty Powerball Jokes
JOKES = [
"Why did Hello Kitty buy a Powerball ticket? She wanted to turn her bow into diamonds!",
"What does Hello Kitty say when she wins the Powerball? 'Me-wow! I'm furry rich!'",
"Why did Hello Kitty combine Christmas and Hanukkah? She believes in holiday hedge-funding!",
"How does Hello Kitty light the menorah? With her purr-sonal torch!",
"What's Hello Kitty's favorite Powerball number? 8 (it looks like a bow from the side!)",
"Why is Hello Kitty a librarian in one image? She knows how to check out winning numbers!",
"What does Hello Kitty do with her Powerball winnings? Buys endless strawberry cakes!",
"Why did Hello Kitty become a mail carrier? To deliver her own winning ticket!",
"How does Hello Kitty celebrate both holidays? With a Chrismukkah miracle!",
"What's Hello Kitty's strategy? One ticket for each of her 100 professions!"
]
# Biblical/Passage jokes (holiday theme)
BIBLICAL_JOKES = [
"πŸŽ„ And lo, the angel said unto them: 'Fear not, for behold, I bring you tidings of great jackpot, which shall be to all people.'",
"πŸ•Ž 'Not by might, nor by power, but by my Spirit... and maybe a lucky Powerball ticket,' saith Hello Kitty.",
"πŸ“– Proverbs 16:33: 'The lot is cast into the lap, but its every decision is from the LORD... unless it's a $1B Powerball.'",
"🎁 'For where your treasure is, there your heart will be also... preferably in a high-interest savings account.' - Hello Kitty 6:9",
"πŸ•―οΈ 'The light of the menorah shall burn for eight days... about how long you'll stare at winning numbers in disbelief.'"
]
# $1 Billion Powerball Specific Jokes
BILLION_JOKES = [
"πŸ’Έ What's the first thing Hello Kitty buys with $1B? A lifetime supply of bows in every color!",
"🏦 How many Hello Kitty plushies can $1B buy? Approximately 50 million!",
"🎫 Why buy one ticket when you can buy 100? Hello Kitty believes in portfolio diversification!",
"πŸ“ˆ At $1B, Hello Kitty could give every American $3 and still have $700 million left!",
"πŸ›’ With $1B, Hello Kitty could buy 250 private islands... each with its own Christmas tree-morah!"
]
def load_image(image_name):
"""Load and display an image"""
try:
img_path = IMAGE_PATHS.get(image_name)
if img_path and os.path.exists(img_path):
return Image.open(img_path)
else:
# Create a placeholder if image not found
return create_placeholder_image(image_name)
except:
return create_placeholder_image(image_name)
def create_placeholder_image(name):
"""Create a placeholder image if file not found"""
fig, ax = plt.subplots(figsize=(5, 5))
ax.text(0.5, 0.5, f"{name}\n(Image Preview)\n\nπŸ“ Please ensure image files are in:\n{build_file_structure()}",
ha='center', va='center', fontsize=12, wrap=True)
ax.set_facecolor('#FFE6F2')
ax.axis('off')
fig.tight_layout()
# Convert matplotlib figure to PIL Image
fig.canvas.draw()
img_array = np.frombuffer(fig.canvas.tostring_rgb(), dtype=np.uint8)
img_array = img_array.reshape(fig.canvas.get_width_height()[::-1] + (3,))
plt.close(fig)
return Image.fromarray(img_array)
def build_file_structure():
"""Show expected file structure"""
return """Project Folder/
β”œβ”€β”€ app.py
β”œβ”€β”€ batch_031_20251211_201120.png
β”œβ”€β”€ batch_032_20251211_201120.png
└── batch_080_20251211_201120.png"""
def get_random_joke():
"""Return a random joke from different categories"""
import random
all_jokes = JOKES + BIBLICAL_JOKES + BILLION_JOKES
return random.choice(all_jokes)
def get_powerball_countdown():
"""Calculate time until Saturday's drawing"""
target_date = datetime(2025, 12, 13, 22, 59) # Saturday, Dec 13, 2025, 10:59 PM EST
now = datetime.now()
if now > target_date:
return "πŸŽ‰ The $1B Powerball drawing has happened! Check if you won!"
time_diff = target_date - now
days = time_diff.days
hours, remainder = divmod(time_diff.seconds, 3600)
minutes, _ = divmod(remainder, 60)
return f"⏳ {days} days, {hours} hours, {minutes} minutes until the $1 BILLION Powerball drawing!"
def create_gallery():
"""Create a gallery component with all images"""
gallery_images = []
for name, path in IMAGE_PATHS.items():
try:
if os.path.exists(path):
gallery_images.append((load_image(name), name))
except:
continue
return gallery_images
# Build the Gradio interface
with gr.Blocks(title=TITLE) as demo:
gr.Markdown(f"# {TITLE}")
gr.Markdown(DESCRIPTION)
# Countdown to Powerball
with gr.Row():
countdown = gr.Markdown(get_powerball_countdown())
# Image Display Section
with gr.Tab("🎨 Featured Images"):
gr.Markdown("### AI-Generated Hello Kitty Holiday Powerball Art")
with gr.Row():
with gr.Column():
image_dropdown = gr.Dropdown(
choices=list(IMAGE_PATHS.keys()),
value="Librarian",
label="Select Hello Kitty Profession"
)
image_display = gr.Image(label="Generated Image", type="pil")
with gr.Column():
gr.Markdown("### Image Details")
image_details = gr.Dataframe(
headers=["Image", "Prompt Theme", "Generation Time"],
value=[
["Mail Carrier", "Delivering gift trees & menorah packages", "13,325.8s"],
["Doctor", "Medical Christmas tree & thermometer menorah", "18,321.4s"],
["Librarian", "Bookshelf tree & glasses menorah", "501.1s"]
]
)
gr.Markdown("### Quick Fact")
fact_display = gr.Markdown(f"**Did you know?** {FACTS[0]}")
# Jokes & Humor Section
with gr.Tab("πŸ˜‚ Holiday Jokes"):
gr.Markdown("### Ho Ho Ho-larious Powerball Humor")
with gr.Row():
with gr.Column():
gr.Markdown("#### πŸŽ€ Hello Kitty Jokes")
for i, joke in enumerate(JOKES[:5]):
gr.Markdown(f"{i+1}. {joke}")
with gr.Column():
gr.Markdown("#### πŸ“– Biblical Jackpot Jokes")
for i, joke in enumerate(BIBLICAL_JOKES):
gr.Markdown(f"{i+1}. {joke}")
gr.Markdown("---")
gr.Markdown("#### πŸ’° $1 Billion Powerball Jokes")
for i, joke in enumerate(BILLION_JOKES):
gr.Markdown(f"{i+1}. {joke}")
with gr.Row():
new_joke_btn = gr.Button("Get Random Joke 🎲")
joke_output = gr.Markdown("Click for a random joke!")
# Facts & Findings Section
with gr.Tab("πŸ“Š Interesting Facts"):
gr.Markdown("### Fun Findings from the AI Generation Project")
facts_list = gr.Dataframe(
headers=["#", "Fact"],
value=[[i+1, fact] for i, fact in enumerate(FACTS)]
)
gr.Markdown("### Generation Time Analysis")
gr.Markdown("""
| Image | Generation Time | Equivalent To |
|-------|-----------------|---------------|
| Mail Carrier | 13,325.8s | 3.7 hours of holiday baking |
| Doctor | 18,321.4s | 5+ hours of watching Hallmark movies |
| Librarian | 501.1s | About 8.5 minutes per iteration |
*Why the time differences? Complexity, details, and AI model variations!*
""")
# Gallery Section
with gr.Tab("πŸ–ΌοΈ Image Gallery"):
gr.Markdown("### All Generated Images")
gallery = gr.Gallery(
label="Hello Kitty Powerball Collection",
value=create_gallery(),
columns=3,
rows=1,
height="auto"
)
# Screenshots Section
with gr.Tab("πŸ“Έ App Screenshots"):
gr.Markdown("### Interface & Generation Screenshots")
gr.Markdown("""
**Included Screenshots from your files:**
1. `Screenshot 2025-12-12 at 3.35.30 PM.png` - Processing completion at 80/100
2. `Screenshot 2025-12-12 at 3.32.02 PM.png` - Generation of images 31 & 32
3. `Screenshot 2025-12-12 at 3.37.28 PM.png` - Final librarian image details
**Key Observations:**
- Image #80 (Librarian) took only 501.1 seconds vs 18,321.4s for Doctor
- All images are 1024x1024 PNG format
- The project processed 100 unique Hello Kitty prompts
- Total generation time appears to be over 8 hours
""")
# Placeholder for actual screenshot display
gr.Markdown("*(To display actual screenshots, add them to the IMAGE_PATHS dictionary)*")
# File Structure Help
with gr.Tab("πŸ› οΈ Setup Help"):
gr.Markdown("### File Structure & Setup")
gr.Code(build_file_structure(), language="shell")
gr.Markdown("""
### To Use This App:
1. Place all image files in the same directory as `app.py`
2. Update `IMAGE_PATHS` dictionary if your filenames differ
3. Install requirements: `pip install gradio Pillow matplotlib numpy`
4. Run: `python app.py`
5. Open the local URL provided (usually http://localhost:7860)
""")
# Footer
gr.Markdown("---")
gr.Markdown("""
### πŸŽ„πŸ•Ž Happy Holidays & Good Luck! πŸŽ€πŸ’°
**Disclaimer**: This app is for entertainment purposes only.
Lottery participation should be responsible and within means.
Hello Kitty is a trademark of Sanrio Co., Ltd.
Powerball is a registered trademark of the Multi-State Lottery Association.
*Generated with AI magic and holiday spirit!*
""")
# Interactive functions
def update_image(profession):
return load_image(profession), f"**Selected:** {profession}\n\n{FACTS[list(IMAGE_PATHS.keys()).index(profession)] if profession in list(IMAGE_PATHS.keys()) else 'No fact available'}"
def update_random_joke():
return f"**🎭 Random Joke:**\n\n{get_random_joke()}"
def update_countdown():
return get_powerball_countdown()
# Connect events
image_dropdown.change(
fn=update_image,
inputs=image_dropdown,
outputs=[image_display, fact_display]
)
new_joke_btn.click(
fn=update_random_joke,
outputs=joke_output
)
# Initial updates
demo.load(
fn=update_image,
inputs=[image_dropdown],
outputs=[image_display, fact_display]
)
# Launch the app
if __name__ == "__main__":
demo.launch(
server_name="0.0.0.0",
server_port=7860,
share=False,
favicon_path=None,
theme=gr.themes.Soft(primary_hue="pink")
)