Code Monkey home page Code Monkey logo

fcakyon / augmented-maskrcnn Goto Github PK

View Code? Open in Web Editor NEW
19.0 2.0 3.0 2.24 MB

Object detection and instance segmentation on MaskRCNN with torchvision, albumentations, tensorboard and cocoapi. Supports custom coco datasets with positive/negative samples.

Python 100.00%
maskrcnn instance-segmentation albumentations augmentation computer-vision python pytorch windows linux macos torchvision tensorboard image-augmentation coco visualization negative-samples object-detection train radam

augmented-maskrcnn's Introduction

Augmented MaskRCNN

CI

This repo lets you easily fine tune pretrained MaskRCNN model with 64 fast image augmentation types using your custom data/annotations, then apply prediction based on the trained model. Training and inference works both on Windows & Linux.

  • torchvision is integrated for MaskRCNN training which provides faster convergence with negative sample support
  • albumentations is integrated for image augmentation which is much faster than imgaug and supports 64 augmentation types for images, bounding boxes and masks
  • torch-optimizer is integrated to support AdaBound, Lamb, RAdam optimizers.
  • tensorboard is integrated for visualizing the training/validation losses, category based training/validation coco ap results and iteration based learning rate changes
  • Pretrained resnet50 + feature pyramid weights on COCO is downloaded upon training
  • COCO evaluation is performed after each epoch, for training and validation sets for each category

Installation

Or install Miniconda (Python3) by bash script on Linux:

sudo apt update --yes
sudo apt upgrade --yes
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p ~/miniconda
rm ~/miniconda.sh
  • Inside the base project directory, open up a terminal/anaconda promt window and create environment:
conda env create -f environment.yml
  • After environment setup, activate environment and run the tests to see if everything is ready:
conda activate augmented-maskrcnn
python -m unittest

Usage

  • In the base project directory, open up a terminal/anaconda promt window, and activate environment:
conda activate augmented-maskrcnn
  • Create a config yml file similar to default_config.yml for your needs

  • Perform training by giving the config path as argument:

python train.py configs/default_config.yml
  • Visualize realtime training/validation losses and accuracies via tensorboard from http://localhost:6006 in your browser:
tensorboard --logdir=experiments
  • Perform prediction for image "CA01_01.tif" using model "artifacts/maskrcnn-best.pt":
python predict.py CA01_01.tif artifacts/maskrcnn-best.pt

augmented-maskrcnn's People

Contributors

fcakyon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

augmented-maskrcnn's Issues

Training takes forever

I'm training to train with roof data but the training never starts... probably is in the augmenting stage... but it's take forever...

What can I do to debug that?

Bounding Box sizes

Hi !
First, great implementation, much better than most out there when it comes to code clarity.

I am running into some small issues:
When dataset entries are handed of too albumentations, albumentations throws a value array because the bbox of an annotation
is too small. It seems to me that after checking my dataset that this comes from numerical imprecision when rastering the mask polygons and calculating the bbox based on those ... Any advice ?

Secondly, the code assumes that category_ids are continuous from 0 to x ... i can work around that by remapping them, but there are a lot of places in the codebase where this is used and so far i have not managed to find one central place where to do the remapping so that it gets picked up by all other parts of the codebase. Our category ids come from a licensed SAAS tool for image labeling, and as such we have to remap them after exporting from there, as we cannot change the SAAS providers code ..

empty target field during training

๐Ÿ› Bug

During the training, in some images, following error occurs:

Exception has occurred: RuntimeError
cannot reshape tensor of 0 elements into shape [0, -1, 4] because the unspecified dimension size -1 can be any value and is ambiguous
  File "/home/augmented-maskrcnn/core/engine.py", line 30, in train_one_epoch
    loss_dict = model(images, targets)
  File "/home/augmented-maskrcnn/train.py", line 188, in train
    train_one_epoch(model, optimizer, data_loader, device, epoch, print_freq=10)
  File "/home/augmented-maskrcnn/train.py", line 208, in <module>
    train()

To Reproduce

Steps to reproduce the behavior:

  1. set configuration
  2. start training
  3. get exception during evaluation

Expected behavior

Should continue training without any issues

Environment

  • Python version (e.g., 3.6/3.7): Python 3.6
  • OS (e.g., Linux/Windows/MacOS): Ubuntu 18.04

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.