Giter VIP home page Giter VIP logo

gsoc-ignite's Introduction

GSoC-ignite

This Repository contains the work done during Google Summer of Code 2021 for the Metric Enhancement Project in Pytorch-Ignite.

1. My Project

1.a Ignite

Ignite is a high-level library to help with training and evaluating neural networks in PyTorch flexibly and transparently. Ignite's Distributed Module is one of the greatest attraction of the library. It works on an Engine and Events based setup. The Metric module is an enhancement to this module to provide commonly used metrics out of the box with Ignite.

Read more about Ignite at Ignite Github - https://github.com/pytorch/ignite

1.b My Proposal

My proposal is mainly based on enhancing the metrics module. I proposed to add four new metrics to Ignite, namely, Frechet Inception Distance (FID), Inception Score (IS), Perceptual Path Length (PPL) and Mean Average Precision (mAP). The initial idea was add GAN evaluation metrics (FID and IS), PPL which has great application in Style Transfer for Feature and Style Loss Calculation and mAP for Object Detection model evaluation like Fast-RCNN. Link to the original proposal - https://summerofcode.withgoogle.com/serve/5981180681256960/

2. The Work

2.a Inception Score

Inception Score (IS) is an objective metric for evaluating the quality of generated images, specifically synthetic images output by generative adversarial network models. It is the average of the overall KL Divergence of the features of two images. It uses a pre-trained Inceptionv3 model to calculate these features. Since KL Divergence is calculated featurewise, so it is difficult to calculate it in a distributed setting using the algorithm implemented in the original paper. A different algorithm needed to be devised which could adapt and work well in the ignite distributed setting. You can find more Inception Score in the paper found here.

2.b Frechet Inception Distance

Frechet Inception Distance (FID) is a metric that calculates the distance between feature vectors calculated for real and generated images. Like IS, it also uses a pre-trained Inceptionv3 model. It uses the mean and covariance between the real and generated images' feature vectors to measure performance of a GAN. Similar to IS, FID uses mean and covariances over all samples to calculate the final result. While calculating online mean is easy, the covariance calculation needed to be modified to a more online implementation. The implementation is inline with the Pytorch-FID package found here.You can find more about Frechet Inception Distance in the paper found here.

2.c Perceptual Path length

Perceptual Path Length (PPL) is mathematical formula which could be used as both a loss and an evaluation metric. It measures the difference between consecutive images (their VGG16 embeddings) when interpolating between two random inputs. Since the calculation of this distance can be slightly variable on a case by case basis so it is not suitable to be standarized as a metric. It has a wide array of application including Garment Transfer, Augmented Reality. It's greatest application however lies in style transfer. An ignite based Style Transfer example is implemented for the same. You can find more about Perceptual Path Length in the paper found here

2.d Mean Average Precision

Mean Average Precision (mAP) is a popular metric used to measure the performance of models doing object detection tasks. The mAP metric tries to greedily match detections with ground truths based on confidence scores and measures the Precision value for these matches at a given set of recall values. The average of all the recorded precisions is called Average Precision. The mean of these Average precision over all classes is called mean Average Precision. To implement a distributed mAP metric for ignite, the input had to be changed from per detection to per image as it would be difficult to keep track of imagwise detection in an online distributed setting. The implementation also provides all six flavours of mAP (3 based on Intersection over Union thresholds, 3 based on Detection Box Area) aviavlable in pycocotools. The implementation is inline with the pycocotools implementation found here. You can find more about Mean Average Precision in the paper found here.

3. Conclusion

Working on distributed metric in Ignite has been a wonderful experience so far. I got to learn a lot about working open source, contributing to existing projects, writing standardized tests and documentations amoung other things. It has been a great experience learning and working with my mentor to realize my proposal and contribute something meaningful to the Pytorch Ignite Community.

Repository Structure

The Repository is divided into three folders, namely, metrics, examples and tests.

The metric folder contain the distributed implementation and documentation of three metrics, Frechet Inception Distance, Inception Score and mean Average Precision.

The tests folder contain the tests written for the above three metrics to test there functionality and compatibility with ignite.

The examples folder contain the Google Colab Notebook examples written for the above three metrics using pytorch-ignite.

Note: Further work is being done on PPL Example, mAP PR and mAP Example. This work will be done in the same PR/ Notebook shared here. All three things mentioned above are functionally working and will give results inline with implementation they are being compared/ tested against. Future work is to be done on design and polishing.

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.