Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -38,10 +38,7 @@ def call_ai_model(all_message):
|
|
38 |
def get_performance_data(conditions):
|
39 |
all_message = (
|
40 |
f"Provide the expected sports performance score at conditions: "
|
41 |
-
f"Temperature {conditions['temperature']}°C
|
42 |
-
f"Wind Speed {conditions['wind_speed']} km/h, UV Index {conditions['uv_index']}, "
|
43 |
-
f"Air Quality Index {conditions['air_quality_index']}, Precipitation {conditions['precipitation']} mm, "
|
44 |
-
f"Atmospheric Pressure {conditions['atmospheric_pressure']} hPa."
|
45 |
)
|
46 |
response = call_ai_model(all_message)
|
47 |
generated_text = ""
|
@@ -65,38 +62,23 @@ def get_performance_data(conditions):
|
|
65 |
|
66 |
# Streamlit app layout
|
67 |
st.title("Climate Impact on Sports Performance")
|
68 |
-
st.write("Analyze and visualize the impact of
|
69 |
|
70 |
-
#
|
71 |
temperature = st.number_input("Temperature (°C):", min_value=-50, max_value=50, value=25)
|
72 |
-
humidity = st.number_input("Humidity (%):", min_value=0, max_value=100, value=50)
|
73 |
-
wind_speed = st.number_input("Wind Speed (km/h):", min_value=0.0, max_value=200.0, value=15.0)
|
74 |
-
uv_index = st.number_input("UV Index:", min_value=0, max_value=11, value=5)
|
75 |
-
air_quality_index = st.number_input("Air Quality Index:", min_value=0, max_value=500, value=100)
|
76 |
-
precipitation = st.number_input("Precipitation (mm):", min_value=0.0, max_value=500.0, value=10.0)
|
77 |
-
atmospheric_pressure = st.number_input("Atmospheric Pressure (hPa):", min_value=900, max_value=1100, value=1013)
|
78 |
|
79 |
# Button to generate predictions
|
80 |
if st.button("Generate Prediction"):
|
81 |
conditions = {
|
82 |
-
"temperature": temperature
|
83 |
-
"humidity": humidity,
|
84 |
-
"wind_speed": wind_speed,
|
85 |
-
"uv_index": uv_index,
|
86 |
-
"air_quality_index": air_quality_index,
|
87 |
-
"precipitation": precipitation,
|
88 |
-
"atmospheric_pressure": atmospheric_pressure
|
89 |
}
|
90 |
|
91 |
try:
|
92 |
with st.spinner("Generating predictions..."):
|
93 |
# Call AI model to get qualitative analysis
|
94 |
qualitative_analysis = (
|
95 |
-
f"Assess the impact on sports performance at
|
96 |
-
f"
|
97 |
-
f"Wind Speed {wind_speed} km/h, UV Index {uv_index}, "
|
98 |
-
f"Air Quality Index {air_quality_index}, Precipitation {precipitation} mm, "
|
99 |
-
f"Atmospheric Pressure {atmospheric_pressure} hPa."
|
100 |
)
|
101 |
qualitative_result = call_ai_model(qualitative_analysis)
|
102 |
|
@@ -114,18 +96,14 @@ if st.button("Generate Prediction"):
|
|
114 |
st.write(f"Predicted Performance Scores: {performance_scores}")
|
115 |
|
116 |
# Plotting the data
|
117 |
-
st.subheader("Performance Score vs
|
118 |
|
119 |
-
#
|
120 |
-
climate_conditions = list(conditions.keys())
|
121 |
-
climate_values = list(conditions.values())
|
122 |
-
|
123 |
-
# Plotting performance score against climate conditions
|
124 |
fig, ax = plt.subplots()
|
125 |
-
ax.plot(
|
126 |
-
ax.set_xlabel('
|
127 |
ax.set_ylabel('Performance Score')
|
128 |
-
ax.set_title('Performance Score vs
|
129 |
ax.grid(True)
|
130 |
st.pyplot(fig)
|
131 |
|
|
|
38 |
def get_performance_data(conditions):
|
39 |
all_message = (
|
40 |
f"Provide the expected sports performance score at conditions: "
|
41 |
+
f"Temperature {conditions['temperature']}°C."
|
|
|
|
|
|
|
42 |
)
|
43 |
response = call_ai_model(all_message)
|
44 |
generated_text = ""
|
|
|
62 |
|
63 |
# Streamlit app layout
|
64 |
st.title("Climate Impact on Sports Performance")
|
65 |
+
st.write("Analyze and visualize the impact of temperature on sports performance.")
|
66 |
|
67 |
+
# Input for temperature
|
68 |
temperature = st.number_input("Temperature (°C):", min_value=-50, max_value=50, value=25)
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
# Button to generate predictions
|
71 |
if st.button("Generate Prediction"):
|
72 |
conditions = {
|
73 |
+
"temperature": temperature
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
75 |
|
76 |
try:
|
77 |
with st.spinner("Generating predictions..."):
|
78 |
# Call AI model to get qualitative analysis
|
79 |
qualitative_analysis = (
|
80 |
+
f"Assess the impact on sports performance at temperature: "
|
81 |
+
f"{temperature}°C."
|
|
|
|
|
|
|
82 |
)
|
83 |
qualitative_result = call_ai_model(qualitative_analysis)
|
84 |
|
|
|
96 |
st.write(f"Predicted Performance Scores: {performance_scores}")
|
97 |
|
98 |
# Plotting the data
|
99 |
+
st.subheader("Performance Score vs Temperature")
|
100 |
|
101 |
+
# Plot performance score against temperature
|
|
|
|
|
|
|
|
|
102 |
fig, ax = plt.subplots()
|
103 |
+
ax.plot(conditions['temperature'], performance_scores, marker='o', linestyle='-', color='b')
|
104 |
+
ax.set_xlabel('Temperature (°C)')
|
105 |
ax.set_ylabel('Performance Score')
|
106 |
+
ax.set_title('Performance Score vs Temperature')
|
107 |
ax.grid(True)
|
108 |
st.pyplot(fig)
|
109 |
|