|
|
import gradio as gr |
|
|
import os |
|
|
from PIL import Image |
|
|
import matplotlib.pyplot as plt |
|
|
import numpy as np |
|
|
from datetime import datetime |
|
|
|
|
|
|
|
|
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! |
|
|
""" |
|
|
|
|
|
|
|
|
IMAGE_PATHS = { |
|
|
"Mail Carrier": "batch_031_20251211_201120.png", |
|
|
"Doctor": "batch_032_20251211_201120.png", |
|
|
"Librarian": "batch_080_20251211_201120.png" |
|
|
} |
|
|
|
|
|
|
|
|
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!" |
|
|
] |
|
|
|
|
|
|
|
|
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_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.'" |
|
|
] |
|
|
|
|
|
|
|
|
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: |
|
|
|
|
|
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() |
|
|
|
|
|
|
|
|
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) |
|
|
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 |
|
|
|
|
|
|
|
|
with gr.Blocks(title=TITLE) as demo: |
|
|
gr.Markdown(f"# {TITLE}") |
|
|
gr.Markdown(DESCRIPTION) |
|
|
|
|
|
|
|
|
with gr.Row(): |
|
|
countdown = gr.Markdown(get_powerball_countdown()) |
|
|
|
|
|
|
|
|
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]}") |
|
|
|
|
|
|
|
|
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!") |
|
|
|
|
|
|
|
|
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!* |
|
|
""") |
|
|
|
|
|
|
|
|
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" |
|
|
) |
|
|
|
|
|
|
|
|
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 |
|
|
""") |
|
|
|
|
|
|
|
|
gr.Markdown("*(To display actual screenshots, add them to the IMAGE_PATHS dictionary)*") |
|
|
|
|
|
|
|
|
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) |
|
|
""") |
|
|
|
|
|
|
|
|
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!* |
|
|
""") |
|
|
|
|
|
|
|
|
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() |
|
|
|
|
|
|
|
|
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 |
|
|
) |
|
|
|
|
|
|
|
|
demo.load( |
|
|
fn=update_image, |
|
|
inputs=[image_dropdown], |
|
|
outputs=[image_display, fact_display] |
|
|
) |
|
|
|
|
|
|
|
|
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") |
|
|
) |