Spaces:
Sleeping
Sleeping
File size: 4,970 Bytes
b5734ec db65e54 4ec975b 08af828 4ec975b 08af828 4ec975b d99adf7 2b1ccb9 60c9571 4ec975b 2b1ccb9 60c9571 2b1ccb9 4ec975b d99adf7 60c9571 d99adf7 60c9571 4ec975b 60c9571 d99adf7 60c9571 4ec975b 60c9571 4ec975b 08af828 fdd2160 08af828 0b5e0d8 2b1ccb9 b5734ec 0b5e0d8 d99adf7 08af828 0b5e0d8 08af828 29b864c d99adf7 08af828 0b5e0d8 08af828 f80ff0a 0b5e0d8 4ec975b d99adf7 0a9aa5b 60c9571 0b5e0d8 60c9571 0a9aa5b 60c9571 4ec975b 0b5e0d8 60c9571 0b5e0d8 db65e54 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
import streamlit as st
import matplotlib.pyplot as plt
import numpy as np
# Inject custom CSS (without background image)
st.markdown(
"""
<style>
.stApp {
background-color: #f0f2f6;
}
.header {
text-align: center;
color: red;
font-size: 30px;
font-weight: bold;
display: flex;
justify-content: center;
align-items: center;
position: relative;
padding-top: 20px;
}
.logo {
position: absolute;
right: 20px;
top: 10px;
width: 80px;
height: auto;
}
.sub-header {
color: darkorange;
font-size: 26px;
font-weight: bold;
margin-top: 30px;
}
.text {
font-size: 17px;
color: black;
font-style: italic;
background-color: rgba(255, 255, 255, 0.75);
padding: 15px;
border-radius: 10px;
margin-bottom: 20px;
}
.footer {
font-size: 14px;
color: #333;
margin-top: 50px;
text-align: center;
font-style: italic;
}
</style>
""",
unsafe_allow_html=True
)
# App Header with Logo
st.markdown(
"""
<div class='header'>
π Cric Metrics - AI-Powered Cricket Insights π
<img src='1.png' class='logo'>
</div>
""",
unsafe_allow_html=True
)
# Sub-sections
st.markdown("<h2 class='sub-header'>Cricket - The Gentlemanβs Game π</h2>", unsafe_allow_html=True)
st.markdown(
"<p class='text'>"
"Cricket is one of the most popular sports worldwide, loved by millions. "
"It is played in multiple formats, including Tests, ODIs, and T20s. "
"With legendary players, thrilling rivalries, and unforgettable moments, cricket is more than a gameβit's an emotion! π"
"</p>",
unsafe_allow_html=True
)
st.markdown("<h2 class='sub-header'>What is Cric Metrics? π</h2>", unsafe_allow_html=True)
st.markdown(
"<p class='text'>"
"Cric Metrics is an AI-powered cricket analytics platform. It offers player comparisons, performance analysis, "
"team stats, and match predictions. It empowers fans, analysts, and teams with smart, data-driven insights. π€π"
"</p>",
unsafe_allow_html=True
)
st.markdown("<h2 class='sub-header'>More About Cric Metrics</h2>", unsafe_allow_html=True)
st.markdown(
"<p class='text'>"
"From grassroots cricket to international glory, Cric Metrics helps track form, fitness, and match-winning impact. "
"We leverage machine learning models and visual analytics to make cricket smarter and more fun! π"
"</p>",
unsafe_allow_html=True
)
st.markdown("<h2 class='sub-header'>About the Author π¨βπ»</h2>", unsafe_allow_html=True)
st.markdown(
"""
<div class='text'>
<b>Sai Kalyan Satwik</b> is a seasoned cricket enthusiast and tech entrepreneur having experience in data science and software development. <br><br>
His passion for cricket meets his technical expertise in this app, blending numbers with narratives for fans and analysts alike.
</div>
""",
unsafe_allow_html=True
)
# Navigation Button
if st.button("π Player Information"):
st.switch_page("pages/1player_information.py")
# Footer
st.markdown("<div class='footer'>Created with β€οΈ by Sai Kalyan Satwik</div>", unsafe_allow_html=True)
def plot_pie_charts(player1_data, player2_data, player1_name, player2_name):
# Extract batting and bowling values with fallback to 0 if not found
sizes1 = [
player1_data.get('Batting', 0),
player1_data.get('Bowling', 0)
]
sizes2 = [
player2_data.get('Batting', 0),
player2_data.get('Bowling', 0)
]
# Replace NaNs or None with 0
sizes1 = [0 if x is None or np.isnan(x) else x for x in sizes1]
sizes2 = [0 if x is None or np.isnan(x) else x for x in sizes2]
# Warn and skip if all values are 0 (nothing to plot)
if sum(sizes1) == 0 and sum(sizes2) == 0:
st.warning("Unable to display pie charts. No valid data found for both players.")
return
elif sum(sizes1) == 0:
st.warning(f"No valid contribution data for {player1_name}.")
return
elif sum(sizes2) == 0:
st.warning(f"No valid contribution data for {player2_name}.")
return
# Plot pie charts
fig, axes = plt.subplots(1, 2, figsize=(10, 5))
labels = ['Batting', 'Bowling']
axes[0].pie(sizes1, labels=labels, autopct='%1.1f%%', startangle=90, colors=['#4CAF50', '#2196F3'])
axes[0].set_title(f'{player1_name} Contribution')
axes[1].pie(sizes2, labels=labels, autopct='%1.1f%%', startangle=90, colors=['#4CAF50', '#2196F3'])
axes[1].set_title(f'{player2_name} Contribution')
# Display in Streamlit
st.pyplot(fig)
|