In the summer monsoon season of 2022, Pakistan experienced a devastating flood event. This flood event impacted approximately one-third of Pakistan's vast population, resulting in the displacement of around 32 million individuals and tragically causing the loss of 1,486 lives, including 530 children. The economic toll of this disaster has been estimated at exceeding $30 billion. The study area encompasses the regions in Pakistan most severely affected by the flood. The Indus River basin, a critical drainage system, plays a pivotal role in this study area's hydrology. Therefore, we would like to utilize ML to predict flood extents and flood depts in this challenge.

What it does⚙️

In this hackathon, our goal was to develop a robust flood modeling framework capable of performing at large scales using input and ground truth data from the Pakistan flood in 2022. We focused on applying supervised machine learning methods, specifically utilizing the Linear Regression for Neural Networks model, to solve the 2-D shallow water equations. Our ultimate objective was to create a flood forecast model that can provide valuable insights and predictions in the event of future floods in Pakistan.

How we built it🛠️

Data Preprocessing step:

1.1. DEM

Load data from tiff file then selected the values that less than -2,000 and clean missing data.


Load data from tiff file in ordering by name. After that, down sampling the image by 16 to get the image of size 881x440 and unsqueeze to 1x1x881x440


Load data from numpy file then selected the down sampling the image by 16 and unsqueeze the data to be the size of 1x1x881x440

1.4.Trainning and Validation data

Load data from of tiff files from training and validation path and make the first layer as a ground height. After that, generate grid x, y and t and put them together in tensor list in the order of x, y, t and initial height

1.5 Data for input layer

Concatenate the tensor of t, dem,manning,rain and height together in the shape of 1x16x881x440x5

Method: The model consist of 3 Linear layers, 4 SpectralConv3d, Modulelist of [5 Conv1d]

Challenges we ran into⌛

-We tried to connect with GPU resources of EO-Lab but it did not work for us.

-The dataset was too large and therefore required more space to load and train our model.

-The GPU provided by the hackathon was barely enough and it required us to purchase extra GPU from Google Colab.

-When we run models, they are crashed several times so we needed to run and try it again.

-We had no previous knowledge of the 2D SWE thus required a steep learning curve and we spent a lot of time developing a model that suited the problem.

-According to the time limitations, we needed to plan and understand all the processes but we took time to understand the provided dataset, also the model codes. But at first, it was difficult to understand and familiar with it.

Accomplishments that we're proud of👏

We have tried to run our models several times to get the best results, also we have tested some models and brainstormed to see if it works. Finally, we fixed all those bugs and get the best results of our Neural Network model. Additionally, our team integrated Geoinformatics and remote sensing tools to analyze the results and the dataset.

What we learned✏️

We have learned about using Pytorch to train neural networks to do predictions from images and also adapt the equations to help the performance of the model. Moreover, we have learned about how to deal with limited resources when the model does a lot of computation. Overall, we gain a comprehensive understanding of the entire process of applying neural networks to real-world problems from data preprocessing.

What's next for ML4Earth2023_Physics-aware ML📈

If there was more time for this activity we would like to do more research on flood factors related to flood phenomena for training the model to get more accurate results. Also, search for physics formulas that may be able to improve the results. Moreover, we wanted to do change detection by using ML in order to compare flood results from the beginning to the last time step.

Built With

Share this project: