Git Product home page Git Product logo

detectron2_backbone's Introduction

Detectron2_Backbone

Installation

First install Detectron2 following the official guide: INSTALL.md. Then build detectron2_backbone with:

git clone https://github.com/sxhxliang/detectron2_backbone.git
cd detectron2_backbone
python setup.py build develop

Quick Start

  1. install detectron2 and detectron2_backbone
  2. import detectron2, import detectron2.
  3. import detectron2_backbone import detectron2_backbone
  4. add config to detectron2
# for example
# import detectron2
import detectron2 
from detectron2.config import get_cfg
# import detectron2_backbone
from detectron2_backbone import backbone
from detectron2_backbone.config import add_backbone_config

def setup(args):
    """
    Create configs and perform basic setups.
    """
    cfg = get_cfg()
    # add config to detectron2
    add_backbone_config(cfg)
    cfg.merge_from_file(args.config_file)
    cfg.merge_from_list(args.opts)
    cfg.freeze()
    default_setup(cfg, args)
    return cfg

Build Your Own Models

# your_config.yaml
MODEL:
  WEIGHTS: "your_path/resnet18_detectron2.pth"
  BACKBONE:
    NAME: "build_resnet18_fpn_backbone"
  ...

Backbones for Detectron2

resnet18:

  • build_resnet18_bacbkone
  • build_resnet18_fpn_backbone
  • build_fcos_resnet18_fpn_backbone

efficientnet:

  • build_efficientnet_backbone
  • build_efficientnet_fpn_backbone
  • build_fcos_efficientnet_fpn_backbone
# your_config.yaml
MODEL:
  WEIGHTS: "your_path/efficientnet_b0_detectron2.pth"
  BACKBONE:
    NAME: "build_efficientnet_fpn_backbone"
  EFFICIENTNET:
    NAME: "efficientnet_b0" # efficientnet_b1, efficientnet_2,  ..., efficientnet_b7
    OUT_FEATURES: ["stride4", "stride8", "stride16", "stride32"]
  FPN:
    IN_FEATURES: ["stride4", "stride8", "stride16", "stride32"]
  ...

dla:

  • build_dla_backbone
  • build_dla_fpn_backbone
  • build_fcos_dla_fpn_backbone

resnest:

  • build_resnest_backbone
  • build_resnest_fpn_backbone
  • build_fcos_resnest_fpn_backbone

vovnet:

  • build_vovnet_backbone
  • build_vovnet_fpn_backbone
  • build_fcos_vovnet_fpn_backbone

mobilenet v2:

  • build_mnv2_backbone
  • build_mnv2_fpn_backbone
  • build_fcos_mnv2_fpn_backbone

hrnet:

  • build_hrnet_backbone
  • build_hrnet_fpn_backbone

bifpn:

  • build_efficientnet_bifpn_backbone
# your_config.yaml
MODEL:
  WEIGHTS: "your_path/efficientnet_b0_detectron2.pth"
  BACKBONE:
    NAME: "build_efficientnet_bifpn_backbone"
  EFFICIENTNET:
    NAME: "efficientnet_b0" # efficientnet_b1, efficientnet_2,  ..., efficientnet_b7
    OUT_FEATURES: ["stride8", "stride16", "stride32"]
  FPN:
    IN_FEATURES: ["stride8", "stride16", "stride32"]
    OUT_CHANNELS: 64
    REPEAT: 3
  ...

Convert Model for Detectron2

python3 -m detectron2_backbone.tools.convert_weight --help
# download model
wget https://github.com/lukemelas/EfficientNet-PyTorch/releases/download/1.0/efficientnet-b0-355c32eb.pth -P your_path
# convert weight
python3 -m detectron2_backbone.tools.convert_weight --model your_path/efficientnet-b0-355c32eb.pth --output your_path/efficientnet_b0_detectron2.pth
your_config.yaml
MODEL:
  WEIGHTS: "your_path/efficientnet_b0_detectron2.pth"

detectron2_backbone's People

Contributors

sxhxliang avatar philgineer 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.