All Projects → mukeshmithrakumar → Retinanet

mukeshmithrakumar / Retinanet

Licence: mit
Keras implementation of RetinaNet for object detection and visual relationship identification

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Retinanet

Basic cnns tensorflow2
A tensorflow2 implementation of some basic CNNs(MobileNetV1/V2/V3, EfficientNet, ResNeXt, InceptionV4, InceptionResNetV1/V2, SENet, SqueezeNet, DenseNet, ShuffleNetV2, ResNet).
Stars: ✭ 374 (+1458.33%)
Mutual labels:  resnet
Mmclassification
OpenMMLab Image Classification Toolbox and Benchmark
Stars: ✭ 532 (+2116.67%)
Mutual labels:  resnet
Vqa.pytorch
Visual Question Answering in Pytorch
Stars: ✭ 602 (+2408.33%)
Mutual labels:  resnet
Fpn tensorflow
A Tensorflow implementation of FPN detection framework.
Stars: ✭ 407 (+1595.83%)
Mutual labels:  resnet
Awesome Very Deep Learning
♾A curated list of papers and code about very deep neural networks
Stars: ✭ 435 (+1712.5%)
Mutual labels:  resnet
Video Classification
Tutorial for video classification/ action recognition using 3D CNN/ CNN+RNN on UCF101
Stars: ✭ 543 (+2162.5%)
Mutual labels:  resnet
Cnn Models
ImageNet pre-trained models with batch normalization for the Caffe framework
Stars: ✭ 355 (+1379.17%)
Mutual labels:  resnet
Keras Idiomatic Programmer
Books, Presentations, Workshops, Notebook Labs, and Model Zoo for Software Engineers and Data Scientists wanting to learn the TF.Keras Machine Learning framework
Stars: ✭ 720 (+2900%)
Mutual labels:  resnet
Tf Tutorials
A collection of deep learning tutorials using Tensorflow and Python
Stars: ✭ 524 (+2083.33%)
Mutual labels:  resnet
Cifar Zoo
PyTorch implementation of CNNs for CIFAR benchmark
Stars: ✭ 584 (+2333.33%)
Mutual labels:  resnet
Cbir
🏞 A content-based image retrieval (CBIR) system
Stars: ✭ 407 (+1595.83%)
Mutual labels:  resnet
Resnext.pytorch
Reproduces ResNet-V3 with pytorch
Stars: ✭ 424 (+1666.67%)
Mutual labels:  resnet
Medicalzoopytorch
A pytorch-based deep learning framework for multi-modal 2D/3D medical image segmentation
Stars: ✭ 546 (+2175%)
Mutual labels:  resnet
Pytorch classification
利用pytorch实现图像分类的一个完整的代码,训练,预测,TTA,模型融合,模型部署,cnn提取特征,svm或者随机森林等进行分类,模型蒸馏,一个完整的代码
Stars: ✭ 395 (+1545.83%)
Mutual labels:  resnet
Deep Ctr Prediction
CTR prediction models based on deep learning(基于深度学习的广告推荐CTR预估模型)
Stars: ✭ 628 (+2516.67%)
Mutual labels:  resnet
Tf Faster Rcnn
Tensorflow Faster RCNN for Object Detection
Stars: ✭ 3,604 (+14916.67%)
Mutual labels:  resnet
Pytorch resnet cifar10
Proper implementation of ResNet-s for CIFAR10/100 in pytorch that matches description of the original paper.
Stars: ✭ 537 (+2137.5%)
Mutual labels:  resnet
Bmw Tensorflow Training Gui
This repository allows you to get started with a gui based training a State-of-the-art Deep Learning model with little to no configuration needed! NoCode training with TensorFlow has never been so easy.
Stars: ✭ 736 (+2966.67%)
Mutual labels:  resnet
Pytorch2keras
PyTorch to Keras model convertor
Stars: ✭ 676 (+2716.67%)
Mutual labels:  resnet
Dogs vs cats
猫狗大战
Stars: ✭ 570 (+2275%)
Mutual labels:  resnet

Keras RetinaNet

Open Source Love GitHub Python 3.6 GitHub Stars LinkedIn

What is it ❓

This is the Keras implementation of RetinaNet for object detection as described in Focal Loss for Dense Object Detection by Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He and Piotr Dollár.

If this repository helps you in anyway, show your love ❤️ by putting a ⭐️ on this project ✌️

Object Detection:

The RetinaNet used is a single, unified network composed of a resnet50 backbone network and two task-specific subnetworks. The backbone is responsible for computing a convolution feature map over an entire input image and is an off-the-self convolution network. The first subnet performs classification on the backbones output; the second subnet performs convolution bounding box regression. The RetinaNet is a good model for object detection but getting it to work was a challenge. I underestimated the high number of classes and the size of the data set but was still able to land a bronze medal (Top 20%) among 450 competitors with some tweaks. The benchmark file is added for reference with the local score for predictions and the parameter used.

Visual Relationship:

I focused on Object detection and used a simple multi class linear regressor for relationship prediction. Unlike the usual approach of using a LSTM, I experimented with a Random Forest Classifier and a Multi Output Classifier from sklearn just to prove LSTM doesn't have much intelligence behind it and it was just a statistical tool. And the local classification scores proved I was right with giving me an accuracy greater than 90%. And since my visual relationship was based on how good my object detector performed I was not able to get a better score but with this model I was able to land a bronze model (Top 30%) among 230 competitors.

Lessons Learned with Tips:
  1. Not to threshold the predictions and leave the low confidence predictions in the submission file. Because of the way average precision works, you cannot be penalised for adding additional false positives with a lower confidence than all your other predictions, however you can still improve your recall if you find additional objects that weren’t previously detected.
  2. The number of steps and epochs, due to the number of images in the train set, having a balanced number of steps and epochs is very important and more important than that is to take all these classes and divide it into bins. Where each bin is occupied by classes with similar frequency in the data set to prepare proper epoch.
  3. When running the training for the classes, to make sure that each class (within an epoch) has similar number of occurrences by implementing a sampler to do this work.

📋 Getting Started

The build was made for the Google AI Object Detection and Visual Relationship Kaggle challenge so if you are using this project on Googles' Open Image data set follow the instructions below to run the module. Also the code is written in such a way that you can take individual modules to build a custom model as per your needs. So when you install the model, make sure you turn the imports into absolute imports or follow the Folder Structure shown below.

📀 Software Prerequisites

  • keras
  • keras-resnet
  • tensorflow
  • pandas
  • numpy
  • pillow
  • opencv
  • sklearn

💻 Hardware Prerequisites

The code was initially run on a NVIDIA GeForce GTX 1050 Ti but the model exploded since for the Open Image data set consisted of 1,743,042 Images and 500 classes with 12,195,144 bounding boxes and the image size was resized to 600 by 600. Resizing the images could have solved the issue but did not try it. Instead the code was run on a NVIDIA Tesla K80 and the model worked fine and to convert the training model to a inference model NVIDIA Tesla P100 was used. So I would recommend a K80 or a higher version of GPU.

📘 Folder Structure

main_dir
- challenge2018 (The folder containing data files for the challenge)
- images
    - train (consists of the train images)
    - test (consists of the test images)
- keras_retinanet (keras retinanet package)
    - callbacks
        - callbacks.py
    - models
        - classifier.py
        - model_backbone.py
        - resnet.py
        - retinanet.py
    - preprocessing
        - generator.py
        - image.py
        - open_images.py
    - trainer
        - convert_model.py
        - evaluate.py
        - model.py
        - task.py
    - utils
        - anchors.py
        - clean.py
        - freeze.py
        - initializers.py
        - layers.py
        - losses.py

⌛️ Train

Run the task.py from the trainer folder.

Usage

task.py main_dir(path/to/main directory) dataset_type(oid)

⌚️ Test

First run the convert_model.py to convert the training model to inference model. Then run the evaluate.py for evaluation. Evaluation is defaulted for both object detection and visual relationship identification, to select between the object detection and the visual relationship identification add 'od' or 'vr' when calling the evaluate.py

Usage

convert_model.py main_dir(path/to/main directory) model_in(model name to be used to convert)
evaluate.py main_dir(path/to/main directory) model_in(model name to be used for evaluation)

📄 Documentation

callbacks.py:

  • CALLED: at model.py by the create callbacks function
  • DOES: returns a set of callbacks used for training

classifier.py:

  • CALLED: at evaluate.py by the main function
  • DOES: returns a Logistic Regression regressor for visual relationship prediction

model_backbone.py:

  • CALLED: at model.py by the train function
  • DOES: Load the retinanet model using the correct backbone.

resnet.py:

  • CALLED: at model_backbone.py by the backbone function
  • DOES: Constructs a retinanet model using a resnet backbone.

retinanet.py:

  • CALLED: at resnet.py by the resnet_retinanet function
  • DOES: Construct a RetinaNet model on top of a backbone

generator.py:

  • CALLED: at open_images.py by the OpenImagesGenerator class
  • DOES: creates a train and validation generator for open_images.py processing

image.py:

  • CALLED: at generator.py by the Generator class
  • DOES: transformations and pre processing on the images

open_images.py:

  • CALLED: at model.py by the create_generators function
  • DOES: returns train and validation generators

convert_model.py:

  • CALLED: stand alone file to convert the train model to inference model
  • DOES: converts a train model to inference model

evaluate.py:

  • CALLED: stand alone evaluation file
  • DOES: object and visual relationship detection and identification

model.py:

  • CALLED: at task.py
  • DOES: the training

task.py:

  • CALLED: stand alone file to be called to start training
  • DOES: initiates the training

anchors.py:

  • CALLED: at generator.py
  • DOES: Generate anchors for bbox detection

clean.py:

  • CALLED: stand alone file
  • DOES: creates ddata files based on the downloaded train and test images

freeze.py:

  • CALLED: at model.py by the create_models function
  • DOES: freeze layers for training

initializers.py:

  • CALLED: at retinanet.py
  • DOES: Applies a prior probability to the weights

layers.py:

  • CALLED: at retinanet.py
  • DOES: Keras layer for filtering detections

losses.py:

  • CALLED: at model.py by the create_models function
  • DOES: calculate the focal and smooth_l1 losses

👽 Authors

🔑 License

This project is licensed under the MIT License - see the LICENSE file for details

📢 Acknowledgments

  • Inspiration from Fizyr Keras RetinaNet
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].