From 16927a29dc0f14704d75b491e51fa3b14c9e31d8 Mon Sep 17 00:00:00 2001 From: Vasilis Vryniotis Date: Tue, 19 Jan 2021 11:33:41 +0000 Subject: [PATCH 1/5] Tag fasterrcnn mobilenetv3 model with 320, add new inference config that makes it 2x faster sacrificing a bit of mAP. --- docs/source/models.rst | 36 ++++----- references/detection/README.md | 2 +- ...cnn_mobilenet_v3_large_320_fpn_expect.pkl} | Bin test/test_models.py | 2 +- .../test_models_detection_negative_samples.py | 2 +- torchvision/models/detection/faster_rcnn.py | 74 +++++++++++------- 6 files changed, 65 insertions(+), 51 deletions(-) rename test/expect/{ModelTester.test_fasterrcnn_mobilenet_v3_large_fpn_expect.pkl => ModelTester.test_fasterrcnn_mobilenet_v3_large_320_fpn_expect.pkl} (100%) diff --git a/docs/source/models.rst b/docs/source/models.rst index fa2dfec14d9..e7904c00599 100644 --- a/docs/source/models.rst +++ b/docs/source/models.rst @@ -358,14 +358,14 @@ models return the predictions of the following classes: Here are the summary of the accuracies for the models trained on the instances set of COCO train2017 and evaluated on COCO val2017. -================================== ======= ======== =========== -Network box AP mask AP keypoint AP -================================== ======= ======== =========== -Faster R-CNN ResNet-50 FPN 37.0 - - -Faster R-CNN MobileNetV3-Large FPN 23.0 - - -RetinaNet ResNet-50 FPN 36.4 - - -Mask R-CNN ResNet-50 FPN 37.9 34.6 - -================================== ======= ======== =========== +====================================== ======= ======== =========== +Network box AP mask AP keypoint AP +====================================== ======= ======== =========== +Faster R-CNN ResNet-50 FPN 37.0 - - +Faster R-CNN MobileNetV3-Large 320 FPN 22.8 - - +RetinaNet ResNet-50 FPN 36.4 - - +Mask R-CNN ResNet-50 FPN 37.9 34.6 - +====================================== ======= ======== =========== For person keypoint detection, the accuracies for the pre-trained models are as follows @@ -415,22 +415,22 @@ For test time, we report the time for the model evaluation and postprocessing (including mask pasting in image), but not the time for computing the precision-recall. -================================== =================== ================== =========== -Network train time (s / it) test time (s / it) memory (GB) -================================== =================== ================== =========== -Faster R-CNN ResNet-50 FPN 0.2288 0.0590 5.2 -Faster R-CNN MobileNetV3-Large FPN 0.0978 0.0376 0.6 -RetinaNet ResNet-50 FPN 0.2514 0.0939 4.1 -Mask R-CNN ResNet-50 FPN 0.2728 0.0903 5.4 -Keypoint R-CNN ResNet-50 FPN 0.3789 0.1242 6.8 -================================== =================== ================== =========== +====================================== =================== ================== =========== +Network train time (s / it) test time (s / it) memory (GB) +====================================== =================== ================== =========== +Faster R-CNN ResNet-50 FPN 0.2288 0.0590 5.2 +Faster R-CNN MobileNetV3-Large 320 FPN 0.0978 0.0376 0.6 +RetinaNet ResNet-50 FPN 0.2514 0.0939 4.1 +Mask R-CNN ResNet-50 FPN 0.2728 0.0903 5.4 +Keypoint R-CNN ResNet-50 FPN 0.3789 0.1242 6.8 +====================================== =================== ================== =========== Faster R-CNN ------------ .. autofunction:: torchvision.models.detection.fasterrcnn_resnet50_fpn -.. autofunction:: torchvision.models.detection.fasterrcnn_mobilenet_v3_large_fpn +.. autofunction:: torchvision.models.detection.fasterrcnn_mobilenet_v3_large_320_fpn RetinaNet diff --git a/references/detection/README.md b/references/detection/README.md index e7ac6e48e11..c4e8fd7d852 100644 --- a/references/detection/README.md +++ b/references/detection/README.md @@ -30,7 +30,7 @@ python -m torch.distributed.launch --nproc_per_node=8 --use_env train.py\ ### Faster R-CNN MobileNetV3-Large FPN ``` python -m torch.distributed.launch --nproc_per_node=8 --use_env train.py\ - --dataset coco --model fasterrcnn_mobilenet_v3_large_fpn --epochs 26\ + --dataset coco --model fasterrcnn_mobilenet_v3_large_320_fpn --epochs 26\ --lr-steps 16 22 --aspect-ratio-group-factor 3 ``` diff --git a/test/expect/ModelTester.test_fasterrcnn_mobilenet_v3_large_fpn_expect.pkl b/test/expect/ModelTester.test_fasterrcnn_mobilenet_v3_large_320_fpn_expect.pkl similarity index 100% rename from test/expect/ModelTester.test_fasterrcnn_mobilenet_v3_large_fpn_expect.pkl rename to test/expect/ModelTester.test_fasterrcnn_mobilenet_v3_large_320_fpn_expect.pkl diff --git a/test/test_models.py b/test/test_models.py index 232a78234b9..c5e9b2549f3 100644 --- a/test/test_models.py +++ b/test/test_models.py @@ -37,7 +37,7 @@ def get_available_video_models(): 'googlenet': lambda x: x.logits, 'inception_v3': lambda x: x.logits, "fasterrcnn_resnet50_fpn": lambda x: x[1], - "fasterrcnn_mobilenet_v3_large_fpn": lambda x: x[1], + "fasterrcnn_mobilenet_v3_large_320_fpn": lambda x: x[1], "maskrcnn_resnet50_fpn": lambda x: x[1], "keypointrcnn_resnet50_fpn": lambda x: x[1], "retinanet_resnet50_fpn": lambda x: x[1], diff --git a/test/test_models_detection_negative_samples.py b/test/test_models_detection_negative_samples.py index cb35f35894b..12e86afa158 100644 --- a/test/test_models_detection_negative_samples.py +++ b/test/test_models_detection_negative_samples.py @@ -97,7 +97,7 @@ def test_assign_targets_to_proposals(self): self.assertEqual(labels[0].dtype, torch.int64) def test_forward_negative_sample_frcnn(self): - for name in ["fasterrcnn_resnet50_fpn", "fasterrcnn_mobilenet_v3_large_fpn"]: + for name in ["fasterrcnn_resnet50_fpn", "fasterrcnn_mobilenet_v3_large_320_fpn"]: model = torchvision.models.detection.__dict__[name]( num_classes=2, min_size=100, max_size=100) diff --git a/torchvision/models/detection/faster_rcnn.py b/torchvision/models/detection/faster_rcnn.py index f5b4696e2ce..91ba32e3a68 100644 --- a/torchvision/models/detection/faster_rcnn.py +++ b/torchvision/models/detection/faster_rcnn.py @@ -16,7 +16,7 @@ __all__ = [ - "FasterRCNN", "fasterrcnn_resnet50_fpn", "fasterrcnn_mobilenet_v3_large_fpn" + "FasterRCNN", "fasterrcnn_resnet50_fpn", "fasterrcnn_mobilenet_v3_large_320_fpn" ] @@ -288,8 +288,8 @@ def forward(self, x): model_urls = { 'fasterrcnn_resnet50_fpn_coco': 'https://download.pytorch.org/models/fasterrcnn_resnet50_fpn_coco-258fb6c6.pth', - 'fasterrcnn_mobilenet_v3_large_fpn_coco': - 'https://download.pytorch.org/models/fasterrcnn_mobilenet_v3_large_fpn-907ea3f9.pth', + 'fasterrcnn_mobilenet_v3_large_320_fpn_coco': + 'https://download.pytorch.org/models/fasterrcnn_mobilenet_v3_large_320_fpn-907ea3f9.pth', } @@ -368,16 +368,38 @@ def fasterrcnn_resnet50_fpn(pretrained=False, progress=True, return model -def fasterrcnn_mobilenet_v3_large_fpn(pretrained=False, progress=True, num_classes=91, pretrained_backbone=True, - trainable_backbone_layers=None, min_size=320, max_size=640, rpn_score_thresh=0.05, - **kwargs): +def _fasterrcnn_mobilenet_v3_large_fpn(weights_name, pretrained=False, progress=True, num_classes=91, + pretrained_backbone=True, trainable_backbone_layers=None, **kwargs): + trainable_backbone_layers = _validate_trainable_layers( + pretrained or pretrained_backbone, trainable_backbone_layers, 6, 3) + + if pretrained: + pretrained_backbone = False + backbone = mobilenet_backbone("mobilenet_v3_large", pretrained_backbone, True, + trainable_layers=trainable_backbone_layers) + + anchor_sizes = ((32, 64, 128, 256, 512, ), ) * 3 + aspect_ratios = ((0.5, 1.0, 2.0),) * len(anchor_sizes) + + model = FasterRCNN(backbone, num_classes, rpn_anchor_generator=AnchorGenerator(anchor_sizes, aspect_ratios), + **kwargs) + if pretrained: + if model_urls.get(weights_name, None) is None: + raise ValueError("No checkpoint is available for model {}".format(weights_name)) + state_dict = load_state_dict_from_url(model_urls[weights_name], progress=progress) + model.load_state_dict(state_dict) + return model + + +def fasterrcnn_mobilenet_v3_large_320_fpn(pretrained=False, progress=True, num_classes=91, pretrained_backbone=True, + trainable_backbone_layers=None, **kwargs): """ - Constructs a Faster R-CNN model with a MobileNetV3-Large FPN backbone. It works similarly - to Faster R-CNN with ResNet-50 FPN backbone. See `fasterrcnn_resnet50_fpn` for more details. + Constructs a Faster R-CNN model with a MobileNetV3-Large FPN backbone tunned for mobile use-cases. + It works similarly to Faster R-CNN with ResNet-50 FPN backbone. See `fasterrcnn_resnet50_fpn` for more details. Example:: - >>> model = torchvision.models.detection.fasterrcnn_mobilenet_v3_large_fpn(pretrained=True) + >>> model = torchvision.models.detection.fasterrcnn_mobilenet_v3_large_320_fpn(pretrained=True) >>> model.eval() >>> x = [torch.rand(3, 300, 400), torch.rand(3, 500, 400)] >>> predictions = model(x) @@ -389,25 +411,17 @@ def fasterrcnn_mobilenet_v3_large_fpn(pretrained=False, progress=True, num_class pretrained_backbone (bool): If True, returns a model with backbone pre-trained on Imagenet trainable_backbone_layers (int): number of trainable (not frozen) resnet layers starting from final block. Valid values are between 0 and 6, with 6 meaning all backbone layers are trainable. - min_size (int): minimum size of the image to be rescaled before feeding it to the backbone - max_size (int): maximum size of the image to be rescaled before feeding it to the backbone - rpn_score_thresh (float): during inference, only return proposals with a classification score - greater than rpn_score_thresh """ - trainable_backbone_layers = _validate_trainable_layers( - pretrained or pretrained_backbone, trainable_backbone_layers, 6, 3) - - if pretrained: - pretrained_backbone = False - backbone = mobilenet_backbone("mobilenet_v3_large", pretrained_backbone, True, - trainable_layers=trainable_backbone_layers) - - anchor_sizes = ((32, 64, 128, 256, 512, ), ) * 3 - aspect_ratios = ((0.5, 1.0, 2.0),) * len(anchor_sizes) - - model = FasterRCNN(backbone, num_classes, rpn_anchor_generator=AnchorGenerator(anchor_sizes, aspect_ratios), - min_size=min_size, max_size=max_size, rpn_score_thresh=rpn_score_thresh, **kwargs) - if pretrained: - state_dict = load_state_dict_from_url(model_urls['fasterrcnn_mobilenet_v3_large_fpn_coco'], progress=progress) - model.load_state_dict(state_dict) - return model + weights_name = "fasterrcnn_mobilenet_v3_large_320_fpn_coco" + defaults = { + "min_size": 320, + "max_size": 640, + "rpn_pre_nms_top_n_test": 150, + "rpn_post_nms_top_n_test": 150, + "rpn_score_thresh": 0.05, + } + + kwargs = {**defaults, **kwargs} + return _fasterrcnn_mobilenet_v3_large_fpn(weights_name, pretrained=pretrained, progress=progress, + num_classes=num_classes, pretrained_backbone=pretrained_backbone, + trainable_backbone_layers=trainable_backbone_layers, **kwargs) \ No newline at end of file From 4b65b1a14049080acacfd169b00a47abad2e2262 Mon Sep 17 00:00:00 2001 From: Vasilis Vryniotis Date: Tue, 19 Jan 2021 12:08:08 +0000 Subject: [PATCH 2/5] Add a high resolution fasterrcnn mobilenetv3 model. --- docs/source/models.rst | 3 ++ torchvision/models/detection/faster_rcnn.py | 41 +++++++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/docs/source/models.rst b/docs/source/models.rst index e7904c00599..7fbae2a55d1 100644 --- a/docs/source/models.rst +++ b/docs/source/models.rst @@ -362,6 +362,7 @@ the instances set of COCO train2017 and evaluated on COCO val2017. Network box AP mask AP keypoint AP ====================================== ======= ======== =========== Faster R-CNN ResNet-50 FPN 37.0 - - +Faster R-CNN MobileNetV3-Large FPN 32.8 - - Faster R-CNN MobileNetV3-Large 320 FPN 22.8 - - RetinaNet ResNet-50 FPN 36.4 - - Mask R-CNN ResNet-50 FPN 37.9 34.6 - @@ -419,6 +420,7 @@ precision-recall. Network train time (s / it) test time (s / it) memory (GB) ====================================== =================== ================== =========== Faster R-CNN ResNet-50 FPN 0.2288 0.0590 5.2 +Faster R-CNN MobileNetV3-Large FPN 0.1020 0.0415 1.0 Faster R-CNN MobileNetV3-Large 320 FPN 0.0978 0.0376 0.6 RetinaNet ResNet-50 FPN 0.2514 0.0939 4.1 Mask R-CNN ResNet-50 FPN 0.2728 0.0903 5.4 @@ -430,6 +432,7 @@ Faster R-CNN ------------ .. autofunction:: torchvision.models.detection.fasterrcnn_resnet50_fpn +.. autofunction:: torchvision.models.detection.fasterrcnn_mobilenet_v3_large_fpn .. autofunction:: torchvision.models.detection.fasterrcnn_mobilenet_v3_large_320_fpn diff --git a/torchvision/models/detection/faster_rcnn.py b/torchvision/models/detection/faster_rcnn.py index 91ba32e3a68..c37a5632ebd 100644 --- a/torchvision/models/detection/faster_rcnn.py +++ b/torchvision/models/detection/faster_rcnn.py @@ -16,7 +16,8 @@ __all__ = [ - "FasterRCNN", "fasterrcnn_resnet50_fpn", "fasterrcnn_mobilenet_v3_large_320_fpn" + "FasterRCNN", "fasterrcnn_resnet50_fpn", "fasterrcnn_mobilenet_v3_large_320_fpn", + "fasterrcnn_mobilenet_v3_large_fpn" ] @@ -290,6 +291,8 @@ def forward(self, x): 'https://download.pytorch.org/models/fasterrcnn_resnet50_fpn_coco-258fb6c6.pth', 'fasterrcnn_mobilenet_v3_large_320_fpn_coco': 'https://download.pytorch.org/models/fasterrcnn_mobilenet_v3_large_320_fpn-907ea3f9.pth', + 'fasterrcnn_mobilenet_v3_large_fpn_coco': + 'https://download.pytorch.org/models/fasterrcnn_mobilenet_v3_large_fpn-fb6a3cc7.pth' } @@ -394,7 +397,7 @@ def _fasterrcnn_mobilenet_v3_large_fpn(weights_name, pretrained=False, progress= def fasterrcnn_mobilenet_v3_large_320_fpn(pretrained=False, progress=True, num_classes=91, pretrained_backbone=True, trainable_backbone_layers=None, **kwargs): """ - Constructs a Faster R-CNN model with a MobileNetV3-Large FPN backbone tunned for mobile use-cases. + Constructs a low resolution Faster R-CNN model with a MobileNetV3-Large FPN backbone tunned for mobile use-cases. It works similarly to Faster R-CNN with ResNet-50 FPN backbone. See `fasterrcnn_resnet50_fpn` for more details. Example:: @@ -424,4 +427,36 @@ def fasterrcnn_mobilenet_v3_large_320_fpn(pretrained=False, progress=True, num_c kwargs = {**defaults, **kwargs} return _fasterrcnn_mobilenet_v3_large_fpn(weights_name, pretrained=pretrained, progress=progress, num_classes=num_classes, pretrained_backbone=pretrained_backbone, - trainable_backbone_layers=trainable_backbone_layers, **kwargs) \ No newline at end of file + trainable_backbone_layers=trainable_backbone_layers, **kwargs) + + +def fasterrcnn_mobilenet_v3_large_fpn(pretrained=False, progress=True, num_classes=91, pretrained_backbone=True, + trainable_backbone_layers=None, **kwargs): + """ + Constructs a high resolution Faster R-CNN model with a MobileNetV3-Large FPN backbone. + It works similarly to Faster R-CNN with ResNet-50 FPN backbone. See `fasterrcnn_resnet50_fpn` for more details. + + Example:: + + >>> model = torchvision.models.detection.fasterrcnn_mobilenet_v3_large_fpn(pretrained=True) + >>> model.eval() + >>> x = [torch.rand(3, 300, 400), torch.rand(3, 500, 400)] + >>> predictions = model(x) + + Args: + pretrained (bool): If True, returns a model pre-trained on COCO train2017 + progress (bool): If True, displays a progress bar of the download to stderr + num_classes (int): number of output classes of the model (including the background) + pretrained_backbone (bool): If True, returns a model with backbone pre-trained on Imagenet + trainable_backbone_layers (int): number of trainable (not frozen) resnet layers starting from final block. + Valid values are between 0 and 6, with 6 meaning all backbone layers are trainable. + """ + weights_name = "fasterrcnn_mobilenet_v3_large_fpn_coco" + defaults = { + "rpn_score_thresh": 0.05, + } + + kwargs = {**defaults, **kwargs} + return _fasterrcnn_mobilenet_v3_large_fpn(weights_name, pretrained=pretrained, progress=progress, + num_classes=num_classes, pretrained_backbone=pretrained_backbone, + trainable_backbone_layers=trainable_backbone_layers, **kwargs) From 2d7213a0bb9e8fd2825c47df0e4f1f6c3670a0d7 Mon Sep 17 00:00:00 2001 From: Vasilis Vryniotis Date: Tue, 19 Jan 2021 12:23:44 +0000 Subject: [PATCH 3/5] Update tests and expected values. --- references/detection/README.md | 7 +++++++ ...rcnn_mobilenet_v3_large_320_fpn_expect.pkl | Bin 4109 -> 4109 bytes ...sterrcnn_mobilenet_v3_large_fpn_expect.pkl | Bin 0 -> 4109 bytes test/test_models.py | 1 + .../test_models_detection_negative_samples.py | 3 ++- 5 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/expect/ModelTester.test_fasterrcnn_mobilenet_v3_large_fpn_expect.pkl diff --git a/references/detection/README.md b/references/detection/README.md index c4e8fd7d852..c8eaf46da5f 100644 --- a/references/detection/README.md +++ b/references/detection/README.md @@ -29,6 +29,13 @@ python -m torch.distributed.launch --nproc_per_node=8 --use_env train.py\ ### Faster R-CNN MobileNetV3-Large FPN ``` +python -m torch.distributed.launch --nproc_per_node=8 --use_env train.py\ + --dataset coco --model fasterrcnn_mobilenet_v3_large_fpn --epochs 26\ + --lr-steps 16 22 --aspect-ratio-group-factor 3 +``` + +### Faster R-CNN MobileNetV3-Large 320 FPN +``` python -m torch.distributed.launch --nproc_per_node=8 --use_env train.py\ --dataset coco --model fasterrcnn_mobilenet_v3_large_320_fpn --epochs 26\ --lr-steps 16 22 --aspect-ratio-group-factor 3 diff --git a/test/expect/ModelTester.test_fasterrcnn_mobilenet_v3_large_320_fpn_expect.pkl b/test/expect/ModelTester.test_fasterrcnn_mobilenet_v3_large_320_fpn_expect.pkl index 94c6261b7fc2a957bcaba9f0a5b8a44568894041..cdc46a4a701520c2ef005dcc760d69fe06002058 100644 GIT binary patch delta 365 zcmeBG=vA1ojK|E>%)r#b%*fo-!erv6N^U6Mz}&!mvKgZzOy1bQ$jD@JGou#EmCB_W zlQ%M&2_UI7a&zKj*u0%9m{~=JL5v}>C^;juELA@xu_RI7(8K`Q4mT$uhRyGojo38e zg*BYd7B@PzC)PN>Y0Y+CyuZNd4R3){f!hbCx2hkU0=(Hde)73wP4?h|TLyN9o0Ad4 zS_i6|huJHVTf wi2(>WI6x!=1K7TId}0a)tPF5dv3X0H!f!bpQYW delta 369 zcmeBG=vA1ojK{>t(%8_@(A?PE%wXcCN^Th6!qRZE8KWai-ps(<*lcn$qZUiD%%9B3 z8yU?6pen&KZcdyGo6UI+Gpfiis4*lKC1+%orRt|7mL%#Mni#;$1li%{q{J{;kVk2A z1FHg?#`}ibP7Os2&QdW<&I{&hI~N>awq-sg>2xze)zQg%u~UFIJBQsp`-78DaKkM$ z2RhBj&B+L4jQ-}ojK0j`{0z!)OUqJ=iZk=`+??b=3gjm{@F_vuoW^H0*@Rze@-99R z1!T7ecr!9F009RFh-6>@+xL!7Okn{t1Kd<>UYR_BPfHj?(PlMbQ+dXeQ8-I2I65DRtmbVoV^R_H)H8VmH+InBIPtNeD_5T}(! zSIEqlTb#|2sA27te>zQ@e?F~Qv#!=t@2T}{+*n^%ySC0O@aNIL!Gk@fecMouWjc1~ zF1=LGKWfgQpPZwnb1)c;Mk1l0)g3($cW#e$hGL=4&D}xEX%;@?Gm9*9uFst3FCdtR z(GiNo&G}(s6rNzQHF}_Hl7uUpM7?K?$6OG$>z$TayhG2|O9#vn-8NvB9uEWl3CmpQ zGZzW?crY3xMam?6__2iQ>(_eBCneTmh4mD$mJAB4rIuOlGb?(GYOij0{Qddazq)fY z4YzmN!Y$F}W)!X_OTcC}XR3(F)U#YOD)}AvW^N5P@MLO>8hh0^Kx0nxVH&sd)uR`f z*1wcpY8_!WPIs{C(JM^5{v{h}{fhn6_A@(^s^MDyHa6zoz{lH;(|9@8t|w_+MdPb- zy96{x?}+qrVaR->V#MlKe^(KQ|ZajS`Oa*05XUw^ZOk zuViY!!nXvzh);SUKJ?Nbyhiy}@JR7d;$KVo5?`7}Jj{!Hj5y6F_%+|_D&M%s7vnRj zMM|$_B7cET`2%0(5B=^^JsdQzDZZ78Z-dmA>Vf%*dLUoa1NjR5MSU@k`cl1#FX|1x zt4EKKzAsY!&Qksnu0J?N^Wb|z@Rj_!Xg&D#5&xY$F)~2>U!wVwG(N<09p5)0zZ<9P zWPPa~s4wcV_k2Lq<5Fuv)I-*ftNOJIJopoMQg8UVMEL>rAU}|wfDeB>+|$C!9`-j@ z4E@4V&LW;z_yX6?UucSXNIf8-B7;0r#`OXhz< zFXKXg(Vq#bFZvVpM}MOJ=ugUz=4F5P2|bVx{3rDy{|P=0#pgG6Z)GX*-NY^1Nri`g z0-l@npnf2~p&#Hk*mR}oqP~PL{e$y~`iJzF{a(azUchhiyg)qk z3;YW|qTj|D=79%4Y9Bto$z6D#{cz$S+g3qh(CeD-9qv6h z#@vNtZ10Axe0TX)(sMtzxq6%KxGl;zSNR3{;QWFA;g6*72hJC9J_!F}JKG_ z<7ukC@H@`$c83U`&?Q_n6L}ywyQo3&V)SbHS&z(Y2 z)$r;C1yyQAdEV;DwfOMHHSxQLgu&&TCx2-lKDD)vRRm0XbsN5ZX^&0Adb#!=>YqrN literal 0 HcmV?d00001 diff --git a/test/test_models.py b/test/test_models.py index c5e9b2549f3..5572b37d061 100644 --- a/test/test_models.py +++ b/test/test_models.py @@ -37,6 +37,7 @@ def get_available_video_models(): 'googlenet': lambda x: x.logits, 'inception_v3': lambda x: x.logits, "fasterrcnn_resnet50_fpn": lambda x: x[1], + "fasterrcnn_mobilenet_v3_large_fpn": lambda x: x[1], "fasterrcnn_mobilenet_v3_large_320_fpn": lambda x: x[1], "maskrcnn_resnet50_fpn": lambda x: x[1], "keypointrcnn_resnet50_fpn": lambda x: x[1], diff --git a/test/test_models_detection_negative_samples.py b/test/test_models_detection_negative_samples.py index 12e86afa158..ad976a78b09 100644 --- a/test/test_models_detection_negative_samples.py +++ b/test/test_models_detection_negative_samples.py @@ -97,7 +97,8 @@ def test_assign_targets_to_proposals(self): self.assertEqual(labels[0].dtype, torch.int64) def test_forward_negative_sample_frcnn(self): - for name in ["fasterrcnn_resnet50_fpn", "fasterrcnn_mobilenet_v3_large_320_fpn"]: + for name in ["fasterrcnn_resnet50_fpn", "fasterrcnn_mobilenet_v3_large_fpn", + "fasterrcnn_mobilenet_v3_large_320_fpn"]: model = torchvision.models.detection.__dict__[name]( num_classes=2, min_size=100, max_size=100) From e6294cc5a0b2ce63313872ad1e38f5f4923e788b Mon Sep 17 00:00:00 2001 From: Vasilis Vryniotis Date: Tue, 19 Jan 2021 12:56:25 +0000 Subject: [PATCH 4/5] Update expected values. --- ...rcnn_mobilenet_v3_large_320_fpn_expect.pkl | Bin 4109 -> 4109 bytes ...sterrcnn_mobilenet_v3_large_fpn_expect.pkl | Bin 4109 -> 4109 bytes test/test_models.py | 4 +++- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/expect/ModelTester.test_fasterrcnn_mobilenet_v3_large_320_fpn_expect.pkl b/test/expect/ModelTester.test_fasterrcnn_mobilenet_v3_large_320_fpn_expect.pkl index cdc46a4a701520c2ef005dcc760d69fe06002058..6be43475f2cb742ad22544c8530101f6d24986b8 100644 GIT binary patch delta 242 zcmeBG=vA1ojN8=0*u>1z+}P64VB*Fq9w^tu$k@zcvN@vzOu)?8($r{jGou!Z)pc>Z z$r~BX1dw!^xH)k$Y%XVQXM>4?4RCWZVwfz*qrdqtVlMusZJsuM#h;eCr zR+C@xNlo6xCjzq&b?O J)ARV}0|55EJ_rB+ delta 251 zcmeBG=vA1ojN8oA%)r#b%*fo-V&cXs9w^tq+`!yuvN@vzOu*Q{$jD@JGou#EmCB_W zlQ%M&2_P$VbK+#!yqzPRSrW-S6E`OzhA0@={GG9#4W= zrtw)#e#Iv>c^97u%w~vFCh%z~7_c%hBo-xSWR|7srzDmn>KmFEAX_(Cg-0 diff --git a/test/expect/ModelTester.test_fasterrcnn_mobilenet_v3_large_fpn_expect.pkl b/test/expect/ModelTester.test_fasterrcnn_mobilenet_v3_large_fpn_expect.pkl index 58fcdf96fcd7e292c049e4201a76d15bd86f81a5..f3882de48383d48241263c2610064631f89c052d 100644 GIT binary patch delta 310 zcmeBG=vA1ojK|d6(%j6{!pzvv$YA28N*LeN*xb@+vN@vzOu)?2(!gYLGou!Z8GGmT z$r~BX1fW{MO5L0|88&a{3TD=oVGv_TEK1JEEKAi-Ni0d!H#9Low#3azh#?9FHh*Vq zXM-68w!+QHh+*Wkd<&@P0yl0&V1MWFYcW2UJd?i!0B!A5-~a#s delta 304 zcmeBG=vA1ojK|E>%)rdj($vVn*l6OWN;u!t%+PGIIimwYz|`1maxmsmO=mr1Kb1*>p-5Fz^A2 Date: Tue, 19 Jan 2021 14:04:34 +0000 Subject: [PATCH 5/5] Change test threshold to resolve flaky test. --- ...rcnn_mobilenet_v3_large_320_fpn_expect.pkl | Bin 4109 -> 4109 bytes test/test_models.py | 7 ++++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/expect/ModelTester.test_fasterrcnn_mobilenet_v3_large_320_fpn_expect.pkl b/test/expect/ModelTester.test_fasterrcnn_mobilenet_v3_large_320_fpn_expect.pkl index 6be43475f2cb742ad22544c8530101f6d24986b8..94c6261b7fc2a957bcaba9f0a5b8a44568894041 100644 GIT binary patch delta 384 zcmeBG=vA1ojK{>t(%8_@(A?PE%wXcCN;u!b($HwKIimwiz|6qh*lcn$qZUiD%%9B3 z8yU?6pjyE)ZcdyGo6UI+Gpfiis4*lKC1+%orRt|7mL%#MniwEk;^w5pFnJ<}(k3Pa zHjVcUx1Ab_7@VbIn4A~P)pjm8z--HWO48|Of~upF^dvL(*GY2`% z&B+L4ivH%k9KOur{0z!)JIhjwiZk=`+??b=3gjm{@F_u@oW^H0*@Rze@-9A+Fl46( zcr!9F009RFh-6>@+2_E1z+}P64z+~d4N*Le7$k@zcvN@vzOu)?8($r{jGou!Z)pc>Z z$r~BX1dz45IdL*<{?4q)rV%f!;e58Z(WyPL#`#Taw)5is1x{~x3!DnvJ~+Kq{ooYf z&Cc