Giter Site home page Giter Site logo

danielwiegand / deforestation Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 34.88 MB

Classification of aerial rainforest images to detect deforestation

Python 4.33% Jupyter Notebook 95.67%
rainforest convolutional-neural-networks deep-learning image-classification multi-class-classification multi-label-classification satellite-imagery

deforestation's Introduction

Understanding Amazon from Space

This is the code for a submission to the Kaggle challenge "Planet: Understanding the Amazon from Space" (https://www.kaggle.com/c/planet-understanding-the-amazon-from-space).

The challenge

In this competition, satellite image chips with have to be labeled with atmospheric conditions and various classes of land cover/land use. Resulting algorithms will help to better understand where, how, and why deforestation happens all over the world - and ultimately how to respond.

Data

The training data consists of 40,479 labeled images of 256x256 pixels. Test data consists of 61,191 images. The images have three color channels.

The training set is labelled for atmospheric conditions and land cover / land use. The following figure shows some of the available labels:

Alt text

More information on the data: https://www.kaggle.com/c/planet-understanding-the-amazon-from-space/data

Implementation

The problem can be classified as multi-class and multi-label classification, as each image can have several labels. The appropriate classification algorithm are convolutional neural networks which use binary cross-entropy as loss function. The number of output neurons corresponds to the number of classes which is 17 in this case.

The tech stack used comprised the Keras and Scikit-Learn libraries. As models, both a custom CNN and transfer learning with a pre-trained NASnet mobile were tried.

As the classes are highly imbalanced, accuracy is not a suitable success metric. Instead, the organisators of the challenge use the F2 score, which is a weighted balance of precisionand recall.

The optimal classification threshold is determined per class by means of the get_optimal_threshold function in functions.py.

Results

  • The custom CNN with four convolutional layers with some additional Dropout and Batch normalization layers and a large Dense layer before the output layer achieved a F2 score of 0.87125.
  • Using a pre-trained NASnet mobile CNN with an additional Dense (50 neurons) and Dropout layer before the output layer achieves a score of 0.90685.
  • Adding class-weights to better adapt to underrepresented classes slightly degrades performance; the same is the case for additional image augmentation during training.
  • The best result of 0.91585 as public score was achieved with a pre-trained NASnet mobile which was finetuned for additional ten epochs with a very low learning rate of 1e-5. This corresponds to the 374th place of the original competition (top 40%).

The final model ran for about 4 hours and 20 minutes in a Colab notebook with GPU runtime.

The model could be further improved by using the significantly more performant NASnet Large model, but this was not tried due to performance limitations. Additionally, it could be tried to combine the outcomes of several models (ensemble learning).

How to use this repository

  1. Clone this repository
  2. Add a data folder to the cloned folder and add train and test images, as well as the y labels file available under https://www.kaggle.com/c/planet-understanding-the-amazon-from-space/data
  3. Execute train.py line by line (e.g. in Google Colab)

License

MIT License

deforestation's People

Contributors

danielwiegand avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.