Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,8 @@ def get_coordinates(location):
|
|
13 |
return location.latitude, location.longitude
|
14 |
|
15 |
# Function to get AQI value from OpenWeatherMap API
|
16 |
-
def get_aqi(latitude, longitude
|
|
|
17 |
url = f"http://api.openweathermap.org/data/2.5/air_pollution?lat={latitude}&lon={longitude}&appid={api_key}"
|
18 |
response = requests.get(url)
|
19 |
data = response.json()
|
@@ -21,16 +22,16 @@ def get_aqi(latitude, longitude, api_key):
|
|
21 |
return aqi_value
|
22 |
|
23 |
# Function to make prediction
|
24 |
-
def predict_air_quality(location
|
25 |
latitude, longitude = get_coordinates(location)
|
26 |
-
aqi_value = get_aqi(latitude, longitude
|
27 |
prediction = model.predict([[aqi_value, aqi_value, aqi_value, aqi_value]])
|
28 |
return prediction[0]
|
29 |
|
30 |
# Create Gradio interface
|
31 |
iface = gr.Interface(fn=predict_air_quality,
|
32 |
-
inputs=["text"
|
33 |
outputs="text",
|
34 |
title="Air Quality Prediction",
|
35 |
-
description="Enter location
|
36 |
-
iface.launch()
|
|
|
13 |
return location.latitude, location.longitude
|
14 |
|
15 |
# Function to get AQI value from OpenWeatherMap API
|
16 |
+
def get_aqi(latitude, longitude):
|
17 |
+
api_key = "78b94879cbb50e02397e93687aa24adc" # Hidden API Key
|
18 |
url = f"http://api.openweathermap.org/data/2.5/air_pollution?lat={latitude}&lon={longitude}&appid={api_key}"
|
19 |
response = requests.get(url)
|
20 |
data = response.json()
|
|
|
22 |
return aqi_value
|
23 |
|
24 |
# Function to make prediction
|
25 |
+
def predict_air_quality(location):
|
26 |
latitude, longitude = get_coordinates(location)
|
27 |
+
aqi_value = get_aqi(latitude, longitude)
|
28 |
prediction = model.predict([[aqi_value, aqi_value, aqi_value, aqi_value]])
|
29 |
return prediction[0]
|
30 |
|
31 |
# Create Gradio interface
|
32 |
iface = gr.Interface(fn=predict_air_quality,
|
33 |
+
inputs=["text"],
|
34 |
outputs="text",
|
35 |
title="Air Quality Prediction",
|
36 |
+
description="Enter location:")
|
37 |
+
iface.launch()
|