Skip to content

Commit

Permalink
add readthedoc support
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-haochen committed Feb 26, 2020
1 parent 28c879e commit cc8caaf
Show file tree
Hide file tree
Showing 26 changed files with 529 additions and 19 deletions.
2 changes: 1 addition & 1 deletion adet/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from adet import modeling

__version__ = "0.1"
__version__ = "0.1.1"
4 changes: 4 additions & 0 deletions adet/checkpoint/adet_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@


class AdetCheckpointer(DetectionCheckpointer):
"""
Same as :class:`DetectronCheckpointer`, but is able to convert models
in AdelaiDet, such as LPF backbone.
"""
def _load_file(self, filename):
if filename.endswith(".pkl"):
with PathManager.open(filename, "rb") as f:
Expand Down
3 changes: 0 additions & 3 deletions adet/config/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,10 @@
# ---------------------------------------------------------------------------- #

_C.MODEL.VOVNET = CN()

_C.MODEL.VOVNET.CONV_BODY = "V-39-eSE"
_C.MODEL.VOVNET.OUT_FEATURES = ["stage2", "stage3", "stage4", "stage5"]

# Options: FrozenBN, GN, "SyncBN", "BN"
_C.MODEL.VOVNET.NORM = "FrozenBN"

_C.MODEL.VOVNET.OUT_CHANNELS = 256

_C.MODEL.VOVNET.BACKBONE_OUT_CHANNELS = 256
4 changes: 2 additions & 2 deletions adet/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from . import builtin # ensure the builtin datasets are registered
from .dataset_mapper import DatasetMapperWithBasis
# from .dataset_mapper import DatasetMapperWithBasis


__all__ = ["DatasetMapperWithBasis"]
# __all__ = ["DatasetMapperWithBasis"]
4 changes: 1 addition & 3 deletions adet/data/builtin.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os

from detectron2.data.datasets.register_coco import register_coco_instances
from detectron2.data.datasets.builtin_meta import _get_builtin_metadata

# register plane reconstruction
# register person in context dataset

_PREDEFINED_SPLITS_PIC = {
"pic_person_train": ("pic/image/train", "pic/annotations/train_person.json"),
Expand All @@ -25,5 +24,4 @@ def register_all_coco(root="datasets"):
os.path.join(root, image_root),
)


register_all_coco()
10 changes: 9 additions & 1 deletion adet/layers/deform_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ def backward(ctx, grad):


class DFConv2d(nn.Module):
"""Deformable convolutional layer"""
"""
Deformable convolutional layer with configurable
deformable groups, dilations and groups.
Code is from:
https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/maskrcnn_benchmark/layers/misc.py
"""
def __init__(
self,
in_channels,
Expand Down
14 changes: 14 additions & 0 deletions adet/layers/iou_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,25 @@


class IOULoss(nn.Module):
"""
Intersetion Over Union (IoU) loss which supports three
different IoU computations:
* IoU
* Linear IoU
* gIoU
"""
def __init__(self, loc_loss_type='iou'):
super(IOULoss, self).__init__()
self.loc_loss_type = loc_loss_type

def forward(self, pred, target, weight=None):
"""
Args:
pred: Nx4 predicted bounding boxes
target: Nx4 target bounding boxes
weight: N loss weight for each instance
"""
pred_left = pred[:, 0]
pred_top = pred[:, 1]
pred_right = pred[:, 2]
Expand Down
9 changes: 5 additions & 4 deletions adet/layers/ml_nms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ def ml_nms(boxlist, nms_thresh, max_proposals=-1,
"""
Performs non-maximum suppression on a boxlist, with scores specified
in a boxlist field via score_field.
Arguments:
boxlist(BoxList)
nms_thresh (float)
Args:
boxlist (detectron2.structures.Boxes):
nms_thresh (float):
max_proposals (int): if > 0, then only the top max_proposals are kept
after non-maximum suppression
score_field (str)
score_field (str):
"""
if nms_thresh <= 0:
return boxlist
Expand Down
3 changes: 3 additions & 0 deletions adet/modeling/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from .fcos import FCOS
from .backbone import build_fcos_resnet_fpn_backbone
from .one_stage_detector import OneStageDetector

_EXCLUDE = {"torch", "ShapeSpec"}
__all__ = [k for k in globals().keys() if k not in _EXCLUDE and not k.startswith("_")]
1 change: 0 additions & 1 deletion adet/modeling/backbone/vovnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ def __init__(self,

self.ese = eSEModule(concat_ch)


def forward(self, x):

identity_feat = x
Expand Down
3 changes: 3 additions & 0 deletions adet/modeling/fcos/fcos.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def forward(self, input):

@PROPOSAL_GENERATOR_REGISTRY.register()
class FCOS(nn.Module):
"""
Implement FCOS (https://arxiv.org/abs/1904.01355).
"""
def __init__(self, cfg, input_shape: Dict[str, ShapeSpec]):
super().__init__()
# fmt: off
Expand Down
4 changes: 4 additions & 0 deletions adet/modeling/one_stage_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

@META_ARCH_REGISTRY.register()
class OneStageDetector(ProposalNetwork):
"""
Same as :class:`detectron2.modeling.ProposalNetwork`.
Uses "instances" as the return key instead of using "proposal".
"""
def forward(self, batched_inputs):
if self.training:
return super().forward(batched_inputs)
Expand Down
4 changes: 3 additions & 1 deletion adet/modeling/poolers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
ROIPooler, convert_boxes_to_pooler_format, assign_boxes_to_levels
)

__all__ = ["TopPooler"]


def _box_max_size(boxes):
box = boxes.tensor
Expand All @@ -20,7 +22,7 @@ def assign_boxes_to_levels_by_length(
vector.
Args:
box_lists (list[Boxes] | list[RotatedBoxes]): A list of N Boxes or N RotatedBoxes,
box_lists (list[detectron2.structures.Boxes]): A list of N Boxes or N RotatedBoxes,
where N is the number of images in the batch.
min_level (int): Smallest feature map level index. The input is considered index 0,
the output of stage 1 is index 1, and so.
Expand Down
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_build
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

0 comments on commit cc8caaf

Please sign in to comment.