AQI PREDICTOR

What is it?

An App to Predict the Quality of Air Just by Clicking a Photo!

Overview

Declining air quality index is a serious problem of the world and many International Organizations have worked to mitigate the problems arisen by Air Quality Index (AQI). Now in Pakistan there is no application or software available which can judge the AQI of our environment and help us take certain measures.


Our app predicts the Air Quality level of a place through a picture which can be taken by anybody at any time anywhere. This accomplishment will help the Government to tackle the areas and alleviate the problems of bad air quality 

PM 2.5

PM stands for particulate matter (also called particle pollution): the term for a mixture of solid particles and liquid droplets found in the air. Some particles, such as dust, dirt, soot, or smoke, are large or dark enough to be seen with the naked eye. 

PM2.5 : Fine inhalable particles, with diameters that are generally 2.5 micrometers and smaller.

For more details

https://www.epa.gov/pm-pollution/particulate-matter-pm-basics 

Dataset

For the purpose of training our model we have relied upon China dataset which mainly includes pictures of Shanghai, Beijing and Phoenix .For availability of dataset link has been given.

Link

https://figshare.com/articles/Particle_pollution_estimation_based_on_image_analysis/1603556/2 

USA Contribution

United States of America Embassies in China have installed Air quality monitors in Beijing and Shanghai which measures PM2.5 hourly and that hourly readings are also publically available.Moreover, that hourly readings are uploaded on twitter for different cities like Shanghai Chengdu and Beijing etc.That twitter accounts are available on the following link

Link

https://china.usembassy-china.org.cn/embassy-consulates/beijing/air-quality-monitor/ 

For Lahore Daily AQI Readings

https://twitter.com/Lahore_Air 

For Islamabad Daily AQI Readings

https://twitter.com/Islamabad_Air 

For Karachi Daily AQI Readings

https://twitter.com/Karachi_Air 

How it Works?

It takes image at runtime and a trained model that works in conjunction with the app to increase the accuracy of the predictions. Along with the app, we created a website that is synchronized with the app and the data that's collected. This helps us to show a map of the areas the AQL has been calculated for. The quality of air is predicted through our application providing us an Air Quality Level which further tells us more details such as if the air is harmful or good and how necessary precautions can be taken.

Our Mission

After having these factors and results, we and the authorities including the government and relevant governmental and other bodies will be able to decide certain measures to make the air quality better. Moreover for. This will help people in deciding which areas have what kind of air quality.

Challenges We Faced

We had multiple problems that we faced during the entire project, the solutions of which are discussed below: 

Today fields of ML/DL is very successful as compare other fields of CS. The reason behind the success of this field is only one thing that is data. If we said Data is one of pillar of this field then it is not wrong. Whenever we want machine start learning we need data because machine doesn't have senses like humans. So for starting this project we also need data.

Collecting the dataset was very difficult as we required a dataset that was either of Pakistan or was near to Pakistan in terms of atmosphere and climate and sky colors. We tried to obtain dataset through multiple sources of Pakistan but we couldn’t find any. We opted to use dataset of China that we were able to find. It was appropriate as Chinese climate is similar to ours and source of our dataset is provided in Dataset section.

Now we have dataset but our dataset is not annotated. We manually labeled our data. As show in picture our dataset have timestamp on every picture. So we match the data and time our image with US embassy data. The link of US embassy data is provided in US Contribution section.

Now the problem is either we apply machine learning  or Deep learning approaches or both. First we apply regression. For this we extract five features from images which are:

We extract features on MATLAB and training a linear regression model but this model doesn't predict right on any image from their dataset.

Now we use Deep Learning approach but for this dataset is not enough. So we do argumentation on images and now our dataset contain approximately 18,000 images and technique we used in argumentation are:

Now we apply Transfer learning techniques on our model and train that model on our dataset. We achieved good result and deploy this model. 

The biggest issue we faced was how to port the application on a mobile device as the model is too big to be run on such platforms. Two possible solutions are, either transform the model into another model, a rather lighter one, that can run on a mobile device, or serve the model and get requests from the mobile application and respond accordingly. Both the choices have its pros and cons as discussed below:

Our trained model is pretty extensive and big which makes it harder to deploy it on android/iOS platforms. If we deploy the model on mobile, we would need to convert our keras model into tensorflow and then into tensorflow lite model so its flexible and light enough to work on a mobile phone which in turn also reduces the accuracy of model. This would be the finest solution. Doing so will be entirely too time-consuming but it will make the model more efficient response-wise. Following are the steps that one can take to make the model port on mobile(Android/iOS).

i. Convert your model to tensorflow model

Either your trained your whole model into tensorflow or convert your trained keras model into tensorflow. We choose second option because we already train our model in keras but when we convert our model our accuracy drops. That's why this solution is not feasible in our case and we choose second option. To learn more about conversion, learn more meduim.

ii. .tf to .tflite

There are multiple inputs that tensorflow lite accepts like frozen graphs, saved models etc. To understand the concepts thoroughly, learn more from tensorflow website.

2. Serve The Model

The other option is to serve the model but serving it causes too long to respond. To serve the model, following steps can be used:

i. Establish a Server

First, establish a server. For us, we created a server on on of our PCs that has Ubuntu as the OS using many tutorials freely available on the internet. On sever side we use flask framework

ii. Communication 

Once the model is placed on the server, create an android application and communicate with the server using Php or other relative framework. 

Choosing framework as our option, we are able to get the respective result and we Choose Volley framework to connect our android app to server.

Results

AQIPredictorAndroidAppDemo.mp4

Android Application Demo

AQIPredictorWebDemo.mp4

Web Application Demo

Tools and Technologies 

Tools and technologies that are used for this project include: 

Software, Technologies & Framework

For Model Training & Deployment

For Website & Android Application

Android App Interfaces

GitHub Repositories 

Final Presentation


CS15_AQI Predictor_Final_Presentation

Final Thesis

CS15_AQI Predictor_Final_Thesis.pdf

Poster

Achievements

AQI Predictor

We scored 2nd Position among 176 Final Year Projects submitted in COMSATS University Islamabad, Lahore Campus. 

Dice IET Innovation Event

Our project is selected by Dice Committee for presentation among hundreds of different Projects.

And Here We Are

Supervisor

Dr. Usama Ijaz Bajwa 

Associate Head of Department / Assistant Professor, Computer Science. Image Processing and Computer Vision ( Biometrics, Medical Image Analysis, Video Analytics ) 

Team Members

Waqas Ahmad

BS Computer Science Student | CUI, Lahore

Ali Hassan

BS Computer Science Student | CUI, Lahore

Hamza Sadiq

BS Computer Science Student | CUI, Lahore