forked from facebookresearch/detectron2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reviewed By: rbgirshick, wat3rBro, HannaMao Differential Revision: D36117941 fbshipit-source-id: 9608b390b958f2471fbdedfb5f97ae0a3c23e006
- Loading branch information
1 parent
b01e0e9
commit 333efcb
Showing
28 changed files
with
776 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
constants = dict( | ||
imagenet_rgb256_mean=[123.675, 116.28, 103.53], | ||
imagenet_rgb256_std=[58.395, 57.12, 57.375], | ||
imagenet_bgr256_mean=[103.530, 116.280, 123.675], | ||
# When using pre-trained models in Detectron1 or any MSRA models, | ||
# std has been absorbed into its conv1 weights, so the std needs to be set 1. | ||
# Otherwise, you can use [57.375, 57.120, 58.395] (ImageNet std) | ||
imagenet_bgr256_std=[1.0, 1.0, 1.0], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from functools import partial | ||
import torch.nn as nn | ||
from detectron2.config import LazyCall as L | ||
from detectron2.modeling import ViT, SimpleFeaturePyramid | ||
from detectron2.modeling.backbone.fpn import LastLevelMaxPool | ||
|
||
from .mask_rcnn_fpn import model | ||
from ..data.constants import constants | ||
|
||
model.pixel_mean = constants.imagenet_rgb256_mean | ||
model.pixel_std = constants.imagenet_rgb256_std | ||
model.input_format = "RGB" | ||
|
||
# Base | ||
embed_dim, depth, num_heads, dp = 768, 12, 12, 0.1 | ||
# Creates Simple Feature Pyramid from ViT backbone | ||
model.backbone = L(SimpleFeaturePyramid)( | ||
net=L(ViT)( # Single-scale ViT backbone | ||
img_size=1024, | ||
patch_size=16, | ||
embed_dim=embed_dim, | ||
depth=depth, | ||
num_heads=num_heads, | ||
drop_path_rate=dp, | ||
window_size=14, | ||
mlp_ratio=4, | ||
qkv_bias=True, | ||
norm_layer=partial(nn.LayerNorm, eps=1e-6), | ||
window_block_indexes=[ | ||
# 2, 5, 8 11 for global attention | ||
0, | ||
1, | ||
3, | ||
4, | ||
6, | ||
7, | ||
9, | ||
10, | ||
], | ||
residual_block_indexes=[], | ||
use_rel_pos=True, | ||
out_feature="last_feat", | ||
), | ||
in_feature="${.net.out_feature}", | ||
out_channels=256, | ||
scale_factors=(4.0, 2.0, 1.0, 0.5), | ||
top_block=L(LastLevelMaxPool)(), | ||
norm="LN", | ||
square_pad=1024, | ||
) | ||
|
||
model.roi_heads.box_head.conv_norm = model.roi_heads.mask_head.conv_norm = "LN" | ||
|
||
# 2conv in RPN: | ||
model.proposal_generator.head.conv_dims = [-1, -1] | ||
|
||
# 4conv1fc box head | ||
model.roi_heads.box_head.conv_dims = [256, 256, 256, 256] | ||
model.roi_heads.box_head.fc_dims = [1024] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
make_stage, | ||
ViT, | ||
SimpleFeaturePyramid, | ||
get_vit_lr_decay_rate, | ||
MViT, | ||
SwinTransformer, | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.