Skip to main content

Sensitivity of model to input resolution

Sensitivity of the model to resolution

The Deepforest model was trained on 10cm data at 400px crops is way too sensitive to the input resolution of images and quality of images, and it tends to give inaccurate results on these images and it's not possible to always have images from drones from a particular height that is 10cm in our case, so we have to come up with a solution for how to get better results for multiple resolutions of data.

So we have two solutions to get better predictions, which can be preprocessing of data and retraining the model on different input resolutions. In preprocessing what we can do is to try to get nearby patch size to give better results as the resolution of the input data decreases compared to the data used to train the model, the patch size needs to be larger and we can pass the appropriate patch size in ```predict_tile``` function, but retaining of the model on different resolutions can be more amount of work but yes we tried to achieve it by evaluating images on different resolutions regularly.

Resampling of an image on a particular resolution

Resampling refers to changing the cell values due to changes in the raster cell grid. This can occur during reprojection. Even if the projection is not changing, we may want to change the effective cell size of an existing dataset.

Upsampling refers to cases where we are converting to higher resolution/smaller cells. Downsampling is resampling to lower resolution/larger cell sizes. 

There are many ways to resample our image such as Rasterio and Gdal as a python library and we can also use QGis to wrap our image in a particular resolution, I used Gdal to make it work, here is snippet for it

def resample_image_in_place(self, image_path, new_res, resample_image):
args = gdal.WarpOptions(
xRes=new_res,
yRes=new_res
)
gdal.Warp(resample_image, image_path, options=args)

where image_path is the path to the raster which has to be resampled,  resample_image is the destination of the wrapped or resoluted raster which is our result and new_res is the resolution argument that signifies the resolution of the output raster and decides whether the raster should be upscaled or downscaled. 

Below is an example of a raster on different resolutions for better visulization:

The image on 10cm resolution on which model is pretrained:




The image on 20cm resolution:


The image on 50cm resolution:


The image on 100cm resolution:


It's pointless to see after 100cm resolution as the image gets so much blurry that we won't be able to look at anything properly and won't be able to differentiate anything from our eyes so how can the model predict trees in it.

After getting rasters on the different resolutions we also calculated the evaluation score on these rasters which we can cover in our next blog that how to do so and what are the results for it.


After we have these images all we want is to train our model on these rasters so that our model can be robust to any type of input resolution. In long term, we will want to try curriculum learning/cross-training across different spatial resolutions for it to work.




Comments

Popular posts from this blog

Creating flutter packages

  How to create Dart packages for Flutter In Flutter, we use the Dart programming language to build cross-platform applications. Dart packages are like the libraries you might be used to installing for, say, Node.js projects using either npm or yarn. These packages are built by Flutter devs for Flutter devs. In this tutorial, we’ll show you how to build Dart packages and share them with other Flutter developers around the world. We’ll cover the following with practical examples: What is a Dart package? Flutter project requirements Dart package types Creating a Flutter/Dart package Initializing a Git repo Writing a Flutter widget Testing your Flutter package Publishing and sharing your Flutter package What is a Dart package? Dart packages help us solve issues and create workarounds for problems without having to write the code ourselves from scratch. For example, let’s say we’re building a Flutter app and we discover that we need to upload a picture from our local filesystem and dis...

GSoC Final Report

GSoC Final Report My journey on the Google Summer of Code project passed by so fast, A lot of stuff happened during those three months, and as I’m writing this blog post, I feel quite nostalgic about these three months. GSoC was indeed a fantastic experience. It gave me an opportunity to grow as a developer in an open source community and I believe that I ended up GSoC with a better understanding of what open source is. I learned more about the community, how to communicate with them, and who are the actors in this workflow. So, this is a summary report of all my journey at GSoC 2022. Name : Ansh Dassani Organization:   NumFOCUS- Data Retriever Project title : Training and Evaluation of model on various resolutions Project link:  DeepForest Mentors :  Ben Weinstein ,  Henry Senyondo , Ethan White Introduction                                        DeepForest is a pytho...

Start of the Coding Period

Start of the Coding Period After the admission to the GSoC program, there is a time period to get started with the project, contact the mentors and so on. After this, the Coding Period starts. This year, it started on May 27th. In my case, I had already contributed to DeepForest, so I had already set up my working environment even before the proposal submission. Thus, I dedicated this period to add detail to my proposal and to discuss with my mentors who were actually very helpful and were always ready to guide and discussed how to tackle the different tasks. I started by checking some papers on multi class object detection and how Resnet works, similar projects and going issue by issue in DeepForest to find all feature requests related to my project. Afterwards I outlined a list of all the methods with their priority and workflow for the whole project which was then discussed with my mentors. I immediately started with a pull request on making the model able to interact with multiple ...