From 11408d6ce334734774c9e2bf511048cca2625e9e Mon Sep 17 00:00:00 2001 From: Vasilis Vryniotis Date: Sun, 17 Jan 2021 22:51:01 +0000 Subject: [PATCH] Remove fasterrcnn_mobilenet_v3_large prototype and update expected file. --- ...t_fasterrcnn_mobilenet_v3_large_expect.pkl | Bin 4109 -> 0 bytes ...sterrcnn_mobilenet_v3_large_fpn_expect.pkl | Bin 4109 -> 4109 bytes test/test_models.py | 1 - .../test_models_detection_negative_samples.py | 2 +- torchvision/models/detection/faster_rcnn.py | 50 +----------------- 5 files changed, 3 insertions(+), 50 deletions(-) delete mode 100644 test/expect/ModelTester.test_fasterrcnn_mobilenet_v3_large_expect.pkl diff --git a/test/expect/ModelTester.test_fasterrcnn_mobilenet_v3_large_expect.pkl b/test/expect/ModelTester.test_fasterrcnn_mobilenet_v3_large_expect.pkl deleted file mode 100644 index 9a9207b73605db38072db7b2a7b5bfaf8a079b65..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4109 zcmeHKeN0nV6n{`!pwPaT=!*r^dt}8)l2Q^%0$jw? zQf`w&Scp2$?y$JuV}Gh;WyuuclVM0-Xv{Pkvy2((nG3UIRf&T9Yn7_x(1PY5w;Wbv zjxxuZL+a#katW%F)eTmw!)~`(-Ib2@F7><4GMm#@wzSgfR?88oq8#a#HKMF7Q4t!u zWsS}5lBZM9&u$`u~ zk;)*BgR^kL!Ra{7xWT3Q8p!hHq42RGrp6!6o;?3QJ%BM!|Lno4W-?+pUo__A3C3)s zw`d+p8XNPtHR})3$QpoS@;cdv$@}2hbpY!z`{V4>v&cIK&KIpmexmhA-&=Vo`Z?S%)BCgz|K8=m;a?v^zz25Vd;7+Rc$=aYpW|wA_~s^pRTTfi&7pYD z$!^5#p%g>D^uY!M`5q45K!8_2no9Ab!LKMzA3RI(V6_G(f261JO+l>)`1jpeCjg&L zVW1f5IWyOQ?;ZCD2~#CnpXz{w0P8bBC&x7?XXXI5l}VJpt(v3t4pqNO>)&)WQ~*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zC;XI~w=KZ$d;190<7qfTdc(=fLN;;8hzI$%qZ>55ItZ_Giw`lyb=cD7%H_j12T2e7 zOR76Wyn2z}UC}?tqa>pr5|1*%;~VE3j`*c{yE)>c9>haEGCuIC)bK(-As1+}l_P%S zX9J`7oz+6V#V%OhE$?!b^Wn~=+&Rm@rGAr;tEqnAhx&ovA9G#&GacuLX71pxrMQH? zP{Xf`^heK+uwml}Yq7QPUl+9qy@{j$5|18+`GX$#L67`_uk44OOZ+P}{Oh@?_f>1$ zm3i#k>0ZWG9wofwymXAui>wd*w(`+PZ$0juQU27k=B-kjw|dGCcw;_*x9k`Ag??G79@#(e zPx49T2R>Q(8`b6PtI$ri+Z8YH-9q`vd4&Boj(L%IU>@`&OFl!E^AEk8f0{=N@)3BJ zkIkFpTL3i8&U{eeoR!aIyw{13n19R<>cjkC9^|~NqIr>ce5>J6j{U%b{sMowUleNmL%${e zB!6p(zs>tCn!hIUC+9s?!!L*G*%91I^$cBmi@$O%(F#5q^9mUFcxPcZTXO8pivF5A z?4`G_GVuAMGo>QmT*?>tT?_q5{k?zT0Dth)40il%4_kb?n)Ij-c%VMuf%%pD2lnU7 z4DYM`A7=etE21FP-+_X+F!s2$=b$E=QDWeZ9CMYId zu_w$}>*#OctVx!iim&5n>)2yXtf%N*YO<$(fy)%0=u0}*Q#78FJvj_hdZIlp)>AZY zIO&lRCQUwt9gf<{`&tC39rgsAeuYhf Ig7tFk-{vS_X8-^I diff --git a/test/test_models.py b/test/test_models.py index 36b05a38c6f..232a78234b9 100644 --- a/test/test_models.py +++ b/test/test_models.py @@ -37,7 +37,6 @@ 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": lambda x: x[1], "fasterrcnn_mobilenet_v3_large_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 1eab8b72d08..cb35f35894b 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", "fasterrcnn_mobilenet_v3_large_fpn"]: + for name in ["fasterrcnn_resnet50_fpn", "fasterrcnn_mobilenet_v3_large_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 8b1d6952271..ae5150205a7 100644 --- a/torchvision/models/detection/faster_rcnn.py +++ b/torchvision/models/detection/faster_rcnn.py @@ -1,10 +1,7 @@ -from collections import OrderedDict - import torch from torch import nn import torch.nn.functional as F -from torchvision.ops import misc as misc_nn_ops from torchvision.ops import MultiScaleRoIAlign from ._utils import overwrite_eps @@ -19,7 +16,7 @@ __all__ = [ - "FasterRCNN", "fasterrcnn_resnet50_fpn", "fasterrcnn_mobilenet_v3_large", "fasterrcnn_mobilenet_v3_large_fpn" + "FasterRCNN", "fasterrcnn_resnet50_fpn", "fasterrcnn_mobilenet_v3_large_fpn" ] @@ -291,8 +288,7 @@ 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_coco': None, - 'fasterrcnn_mobilenet_v3_large_fpn_coco': None, + 'fasterrcnn_mobilenet_v3_large_fpn_coco': None, # TODO: Add the final model url } @@ -371,48 +367,6 @@ def fasterrcnn_resnet50_fpn(pretrained=False, progress=True, return model -def fasterrcnn_mobilenet_v3_large(pretrained=False, progress=True, num_classes=91, pretrained_backbone=True, - trainable_backbone_layers=None, min_size=320, max_size=640, **kwargs): - """ - Constructs a Faster R-CNN model with a MobileNetV3-Large 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(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. - 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 - """ - 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, False, - trainable_layers=trainable_backbone_layers) - - anchor_sizes = ((32, 64, 128, 256, 512, ), ) - aspect_ratios = ((0.5, 1.0, 2.0), ) - - model = FasterRCNN(backbone, num_classes, rpn_anchor_generator=AnchorGenerator(anchor_sizes, aspect_ratios), - min_size=min_size, max_size=max_size, **kwargs) - if pretrained: - state_dict = load_state_dict_from_url(model_urls['fasterrcnn_mobilenet_v3_large_coco'], progress=progress) - model.load_state_dict(state_dict) - 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):