ogegadavis254 commited on
Commit
e897423
·
verified ·
1 Parent(s): 516b5b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -10
app.py CHANGED
@@ -3,8 +3,8 @@ import requests
3
  import os
4
  import json
5
  import pandas as pd
6
- import matplotlib.pyplot as plt
7
- from PIL import Image
8
 
9
  # Function to call the Together API with the provided model
10
  def call_ai_model(all_message):
@@ -48,6 +48,10 @@ air_quality_index = st.number_input("Air Quality Index:", min_value=0, max_value
48
  precipitation = st.number_input("Precipitation (mm):", min_value=0.0, max_value=500.0, value=10.0)
49
  atmospheric_pressure = st.number_input("Atmospheric Pressure (hPa):", min_value=900, max_value=1100, value=1013)
50
 
 
 
 
 
51
  # Athlete-specific inputs
52
  age = st.number_input("Athlete Age:", min_value=0, max_value=100, value=25)
53
  sport = st.selectbox("Select Sport:", ["Running", "Cycling", "Swimming", "Football", "Basketball"])
@@ -66,8 +70,8 @@ if st.button("Generate Prediction"):
66
  all_message = (
67
  f"Given the climate conditions: Temperature {temperature}°C, Humidity {humidity}%, Wind Speed {wind_speed} km/h, "
68
  f"UV Index {uv_index}, Air Quality Index {air_quality_index}, Precipitation {precipitation} mm, "
69
- f"Atmospheric Pressure {atmospheric_pressure} hPa. For athlete (Age: {age}, Sport: {sport}), "
70
- f"Facility (Type: {facility_type}, Age: {facility_age}, Materials: {materials_used}). "
71
  f"Assess the impact on sports performance, infrastructure, and socio-economic aspects."
72
  )
73
 
@@ -98,17 +102,20 @@ if st.button("Generate Prediction"):
98
 
99
  # Displaying a table of input data
100
  data = {
101
- 'Condition': ['Temperature', 'Humidity', 'Wind Speed', 'UV Index', 'Air Quality Index', 'Precipitation', 'Atmospheric Pressure'],
102
- 'Value': [temperature, humidity, wind_speed, uv_index, air_quality_index, precipitation, atmospheric_pressure]
103
  }
104
  df = pd.DataFrame(data)
105
  st.subheader("Input Data Overview")
106
  st.table(df)
107
 
108
- # Display an infographic
109
- infographics_path = 'path_to_your_infographic_image.jpg' # Replace with your image path
110
- infographic = Image.open(infographics_path)
111
- st.image(infographic, caption='Climate Impact Infographic', use_column_width=True)
 
 
 
112
 
113
  except ValueError as ve:
114
  st.error(f"Configuration error: {ve}")
 
3
  import os
4
  import json
5
  import pandas as pd
6
+ import folium # For creating the map visualizations
7
+ from folium.plugins import MarkerCluster
8
 
9
  # Function to call the Together API with the provided model
10
  def call_ai_model(all_message):
 
48
  precipitation = st.number_input("Precipitation (mm):", min_value=0.0, max_value=500.0, value=10.0)
49
  atmospheric_pressure = st.number_input("Atmospheric Pressure (hPa):", min_value=900, max_value=1100, value=1013)
50
 
51
+ # Geographic location
52
+ latitude = st.number_input("Latitude:", min_value=-90.0, max_value=90.0, value=0.0)
53
+ longitude = st.number_input("Longitude:", min_value=-180.0, max_value=180.0, value=0.0)
54
+
55
  # Athlete-specific inputs
56
  age = st.number_input("Athlete Age:", min_value=0, max_value=100, value=25)
57
  sport = st.selectbox("Select Sport:", ["Running", "Cycling", "Swimming", "Football", "Basketball"])
 
70
  all_message = (
71
  f"Given the climate conditions: Temperature {temperature}°C, Humidity {humidity}%, Wind Speed {wind_speed} km/h, "
72
  f"UV Index {uv_index}, Air Quality Index {air_quality_index}, Precipitation {precipitation} mm, "
73
+ f"Atmospheric Pressure {atmospheric_pressure} hPa. Location: Latitude {latitude}, Longitude {longitude}. "
74
+ f"For athlete (Age: {age}, Sport: {sport}), Facility (Type: {facility_type}, Age: {facility_age}, Materials: {materials_used}). "
75
  f"Assess the impact on sports performance, infrastructure, and socio-economic aspects."
76
  )
77
 
 
102
 
103
  # Displaying a table of input data
104
  data = {
105
+ 'Condition': ['Temperature', 'Humidity', 'Wind Speed', 'UV Index', 'Air Quality Index', 'Precipitation', 'Atmospheric Pressure', 'Latitude', 'Longitude'],
106
+ 'Value': [temperature, humidity, wind_speed, uv_index, air_quality_index, precipitation, atmospheric_pressure, latitude, longitude]
107
  }
108
  df = pd.DataFrame(data)
109
  st.subheader("Input Data Overview")
110
  st.table(df)
111
 
112
+ # Creating a map with the provided location
113
+ map_center = [latitude, longitude]
114
+ sport_map = folium.Map(location=map_center, zoom_start=12)
115
+ marker_cluster = MarkerCluster().add_to(sport_map)
116
+ folium.Marker(location=map_center, popup="User Location").add_to(marker_cluster)
117
+ map_html = sport_map._repr_html_()
118
+ st.components.v1.html(map_html, height=600)
119
 
120
  except ValueError as ve:
121
  st.error(f"Configuration error: {ve}")