BodyMapAI / app.py
awacke1's picture
Update app.py
0780026 verified
raw
history blame
9.18 kB
import streamlit as st
import os
from PIL import Image
import json
from datetime import datetime, timedelta
# File to store click history and last update timestamp
HISTORY_FILE = 'click_history.json'
# Initialize or load click history and last update time
def init_click_history():
if os.path.exists(HISTORY_FILE):
with open(HISTORY_FILE, 'r') as file:
return json.load(file)
else:
# Initialize with all buttons set to zero clicks and current time
return {"click_counts": {button: 0 for button in all_buttons}, "last_update": datetime.now().isoformat()}
# Save click history and last update time
def save_click_history(history):
with open(HISTORY_FILE, 'w') as file:
json.dump(history, file)
# Update click count for a button and save history
def update_click_count(button_name):
history = init_click_history()
history["click_counts"][button_name] += 1
history["last_update"] = datetime.now().isoformat()
save_click_history(history)
st.experimental_rerun()
# Display buttons and handle clicks
def display_buttons():
columns = st.columns(3)
for i, category in enumerate(categories):
with columns[i % 3]:
st.markdown(f"### {category['name']}")
for button in category['buttons']:
if st.button(button["text"]):
update_click_count(button["text"])
# Calculate time since last update
def time_since_last_update():
history = init_click_history()
last_update = datetime.fromisoformat(history["last_update"])
now = datetime.now()
return int((now - last_update).total_seconds())
# Main categories and buttons
categories = [
{"name": "Inputs", "buttons": [{"text": "๐Ÿ“ Text"}, {"text": "๐Ÿ“– Read"}, {"text": "๐Ÿ“ท Photo"}, {"text": "๐Ÿ–ผ๏ธ View"}, {"text": "๐ŸŽ™๏ธ Record"}, {"text": "๐ŸŽง Listen"}, {"text": "๐ŸŽฅ Video"}, {"text": "๐Ÿ“น Capture"}]},
{"name": "Outputs", "buttons": [{"text": "๐Ÿ’ฌ Chat"}, {"text": "โœ๏ธ Write"}, {"text": "๐ŸŽจ Art"}, {"text": "๐ŸŒ„ Create"}, {"text": "๐ŸŽต Music"}, {"text": "๐ŸŽถ Compose"}, {"text": "๐Ÿ“ผ Watch"}, {"text": "๐Ÿฟ Movies"}]},
{"name": "Health", "buttons": [{"text": "๐Ÿ’‰ Vaccinate"}, {"text": "๐Ÿฉบ Diagnose"}, {"text": "๐Ÿฅ Hospital"}, {"text": "๐Ÿš‘ Emergency"}, {"text": "๐Ÿ’Š Meds"}, {"text": "๐Ÿฉน Bandage"}, {"text": "๐Ÿงฌ DNA"}, {"text": "๐Ÿ”ฌ Research"}, {"text": "๐ŸŒก๏ธ Temperature"}, {"text": "๐Ÿ Nutrition"}]},
{"name": "Learning", "buttons": [{"text": "๐Ÿ“š Study"}, {"text": "๐Ÿง  Brain"}, {"text": "๐Ÿ‘ฉโ€๐ŸŽ“ Graduate"}, {"text": "๐Ÿ“ Measure"}, {"text": "๐Ÿ” Search"}, {"text": "๐Ÿ“Š Analyze"}, {"text": "๐Ÿ“‹ Plan"}, {"text": "๐Ÿ–‹๏ธ Write"}, {"text": "๐Ÿ‘จโ€๐Ÿซ Teach"}, {"text": "๐Ÿงฉ Puzzle"}]},
{"name": "AI", "buttons": [{"text": "๐Ÿค– Robot"}, {"text": "๐Ÿ‘พ Game"}, {"text": "๐Ÿ’ป Code"}, {"text": "๐Ÿงฎ Calculate"}, {"text": "๐Ÿ“ก Connect"}, {"text": "๐Ÿ”‹ Power"}, {"text": "๐Ÿ•น๏ธ Play"}, {"text": "๐Ÿ–ฅ๏ธ Display"}, {"text": "๐Ÿง‘โ€๐Ÿ’ป Develop"}, {"text": "๐Ÿ‘จโ€๐Ÿ”ฌ Experiment"}]},
{"name": "Writing", "buttons": [{"text": "โœ๏ธ Author"}, {"text": "๐Ÿ“ Note"}, {"text": "๐Ÿ–Š๏ธ Pen"}, {"text": "๐Ÿ–‹๏ธ Sign"}, {"text": "๐Ÿ“š Library"}, {"text": "๐Ÿ”– Bookmark"}, {"text": "๐Ÿ““ Journal"}, {"text": "โœ’๏ธ Ink"}, {"text": "๐Ÿ“œ Scroll"}]},
]
all_buttons = [button["text"] for category in categories for button in category["buttons"]]
# App title
st.markdown("# Remixable!!\n## Classifications")
# Display all buttons
display_buttons()
# Show time since last update
seconds_since_update = time_since_last_update()
st.write(f"๐Ÿ•’ Time since last update: {seconds_since_update} seconds")
# Placeholder function for Wikipedia content fetching
# You'll need to replace this with actual fetching logic
def fetch_wikipedia_summary(keyword):
# Placeholder text, replace with actual Wikipedia fetching logic
return f"Summary about {keyword} from Wikipedia."
# Display images from the current directory and fetch related Wikipedia stories
def display_images_and_wikipedia_summaries():
st.title('Gallery with Related Stories')
# Scan current directory for PNG images
image_files = [f for f in os.listdir('.') if f.endswith('.png')]
# Check if there are any PNG images
if not image_files:
st.write("No PNG images found in the current directory.")
return
# Iterate over found images
for image_file in image_files:
# Open and display each image
image = Image.open(image_file)
st.image(image, caption=image_file, use_column_width='always')
# Extract a keyword from the image file name for Wikipedia search
# This is a simple example; adjust logic as needed for more complex titles
keyword = image_file.split('.')[0] # Assumes keyword is the file name without extension
# Fetch and display related Wikipedia content
wikipedia_summary = fetch_wikipedia_summary(keyword)
st.write(wikipedia_summary)
# Call the function to display images and summaries
display_images_and_wikipedia_summaries()
import streamlit as st
st.markdown('# Three Dragons ๐Ÿ‰๐ŸŒ Mythical Dragons Around the World by Aaron Wacker')
dragons = {
'#Fafnir #Norse': '- **Story**: Fafnir originally a dwarf, transformed into a fierce dragon due to his greed for the treasure he guarded. He was later slain by the hero Sigurd. - **Significance**: deadly sin of greed and the corrupting power of wealth.',
'#Quetzalcoatl #Aztec': '- **Story**: Quetzalcoatl, the Feathered Serpent, is not a dragon in the traditional sense but shares many similarities. He was a deity representing wind, air, and learning. - **Significance**: creator god and a symbol of death and rebirth.',
'#Tiamat #Mesopotamian': '- **Story**: Tiamat, primordial goddess of ocean, turned into a dragon-like creature in a battle against her children who threatened her authority. - **Significance**: chaos of primordial creation and is often associated with the forces of nature.'
}
for dragon, story in dragons.items():
st.subheader(dragon)
st.markdown(f"- {story}")
st.markdown('''
https://github.com/AaronCWacker/ThreeDragons
![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/vkNh6XnEtGSj8mXea1W6p.png)
![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/Kr_nqtaglHE_aiFxWH9zF.png)
![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/WLRKWqB6dKlMH6saVV9cX.png)
![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/Lyazf6FuX4nH__4illVki.png)
![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/ZemsxlT3b5idB0W5IjL1o.png)
''')
st.markdown('''
# Remixable!!
## Classifications''')
# Create three columns for Inputs, Outputs, and Health
col1, col2, col3 = st.columns(3)
with col1:
st.markdown('''### Inputs''')
st.button("๐Ÿ“ Text")
st.button("๐Ÿ“– Read")
st.button("๐Ÿ“ท Photo")
st.button("๐Ÿ–ผ๏ธ View")
st.button("๐ŸŽ™๏ธ Record")
st.button("๐ŸŽง Listen")
st.button("๐ŸŽฅ Video")
st.button("๐Ÿ“น Capture")
with col2:
st.markdown('''### Outputs''')
st.button("๐Ÿ’ฌ Chat")
st.button("โœ๏ธ Write")
st.button("๐ŸŽจ Art")
st.button("๐ŸŒ„ Create")
st.button("๐ŸŽต Music")
st.button("๐ŸŽถ Compose")
st.button("๐Ÿ“ผ Watch")
st.button("๐Ÿฟ Movies")
with col3:
st.markdown('''### Health''')
st.button("๐Ÿ’‰ Vaccinate")
st.button("๐Ÿฉบ Diagnose")
st.button("๐Ÿฅ Hospital")
st.button("๐Ÿš‘ Emergency")
st.button("๐Ÿ’Š Meds")
st.button("๐Ÿฉน Bandage")
st.button("๐Ÿงฌ DNA")
st.button("๐Ÿ”ฌ Research")
st.button("๐ŸŒก๏ธ Temperature")
st.button("๐Ÿ Nutrition")
# Create another set of three columns for Learning, AI, and Writing
col4, col5, col6 = st.columns(3)
with col4:
st.markdown('''### Learning''')
st.button("๐Ÿ“š Study")
st.button("๐Ÿง  Brain")
st.button("๐Ÿ‘ฉโ€๐ŸŽ“ Graduate")
st.button("๐Ÿ“ Measure")
st.button("๐Ÿ” Search")
st.button("๐Ÿ“Š Analyze")
st.button("๐Ÿ“‹ Plan")
st.button("๐Ÿ–‹๏ธ Write")
st.button("๐Ÿ‘จโ€๐Ÿซ Teach")
st.button("๐Ÿงฉ Puzzle")
with col5:
st.markdown('''### AI''')
st.button("๐Ÿค– Robot")
st.button("๐Ÿ‘พ Game")
st.button("๐Ÿ’ป Code")
st.button("๐Ÿงฎ Calculate")
st.button("๐Ÿ“ก Connect")
st.button("๐Ÿ”‹ Power")
st.button("๐Ÿ•น๏ธ Play")
st.button("๐Ÿ–ฅ๏ธ Display")
st.button("๐Ÿง‘โ€๐Ÿ’ป Develop")
st.button("๐Ÿ‘จโ€๐Ÿ”ฌ Experiment")
with col6:
st.markdown('''### Writing''')
st.button("โœ๏ธ Author")
st.button("๐Ÿ“ Note")
st.button("๐Ÿ–Š๏ธ Pen")
st.button("๐Ÿ–‹๏ธ Sign")
st.button("๐Ÿ“š Library")
st.button("๐Ÿ”– Bookmark")
st.button("๐Ÿ““ Journal")
st.button("โœ’๏ธ Ink")
st.button("๐Ÿ“œ Scroll")
# Similarly, create columns for Coding, Remix, Movies, Video, and Audio as needed
# You can continue this pattern for organizing the rest of your buttons into columns