Tweet_data / app.py
Karlsen's picture
Update app.py
109ac3d verified
raw
history blame contribute delete
No virus
2.22 kB
import streamlit as st
from PIL import Image
import os
# Set page config to make the background dark blue
st.set_page_config(page_title="My App", layout="centered")
# Add CSS for custom background color and text styling
st.markdown(
"""
<style>
.stApp {
background-color: #00008B;
}
.custom-text {
color: white;
font-size: 2em;
text-align: center;
margin-bottom: 10px;
}
.summary-text {
color: white;
font-size: 1.5em;
text-align: center;
margin-bottom: 20px;
}
.image-caption {
color: white;
font-size: 3em;
text-align: center;
margin-bottom: 10px;
}
</style>
""",
unsafe_allow_html=True
)
# Define function to load and display images with error handling
def display_image(image_path, caption):
try:
image = Image.open(image_path)
st.markdown(f'<div class="image-caption">{caption}</div>', unsafe_allow_html=True)
st.image(image, use_column_width=True)
except FileNotFoundError:
st.error(f"File not found: {image_path}")
except Exception as e:
st.error(f"An error occurred while loading {image_path}: {e}")
# List of image files with their captions and correct file extensions in the specified order
image_files = [
("head10.JPG", "Head 10"),
("idm_overlap.jpg", "IDM Overlap"),
("idm.JPG", "IDM"),
("topic_groups.JPG", "Topic Groups"),
("similarity_matrix.JPG", "Similarity Matrix"),
("heirarchy_cluster.JPG", "Hierarchy Cluster"),
]
# Display images
for file, caption in image_files:
display_image(file, caption)
# Display the specified text parts
st.markdown('<div class="custom-text">It was pretty metal at the grocery store today. #Covid_19</div>', unsafe_allow_html=True)
st.markdown('<div class="summary-text">summary: It was pretty metal at the grocery store today. #Covid_19 - a video of a metal event at a grocery store.</div>', unsafe_allow_html=True)
# Continue displaying the remaining images
remaining_images = [
("sentiment.JPG", "Sentiment"),
("accuracy.JPG", "Accuracy")
]
for file, caption in remaining_images:
display_image(file, caption)