From 1862d363bc25d7870ebb76afd5eb610145ddf68e Mon Sep 17 00:00:00 2001 From: Francisco Massa Date: Thu, 2 Jan 2020 18:42:41 +0100 Subject: [PATCH 1/3] Fix lint following #1695 --- torchvision/models/detection/faster_rcnn.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/torchvision/models/detection/faster_rcnn.py b/torchvision/models/detection/faster_rcnn.py index afdbc46a64b..b38076e7383 100644 --- a/torchvision/models/detection/faster_rcnn.py +++ b/torchvision/models/detection/faster_rcnn.py @@ -318,16 +318,18 @@ def fasterrcnn_resnet50_fpn(pretrained=False, progress=True, Example:: >>> model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True) - >>> images,boxes,labels = torch.rand(4,3,600,1200), torch.rand(4,11,4), torch.rand(4,11) # For Training + >>> # For training + >>> images, boxes, labels = torch.rand(4,3,600,1200), torch.rand(4,11,4), torch.rand(4,11) >>> images = list(image for image in images) - >>> targets = [] + >>> targets = [] >>> for i in range(len(images)): >>> d = {} >>> d['boxes'] = boxes[i] >>> d['labels'] = labels[i].type(torch.int64) >>> targets.append(d) >>> output = model(images,targets) - >>> model.eval() # For inference + >>> # For inference + >>> model.eval() >>> x = [torch.rand(3, 300, 400), torch.rand(3, 500, 400)] >>> predictions = model(x) From 2bdb74665b7d2daece9dd53aa7c4018c96e77f8c Mon Sep 17 00:00:00 2001 From: Francisco Massa Date: Thu, 2 Jan 2020 18:43:37 +0100 Subject: [PATCH 2/3] V2 --- torchvision/models/detection/faster_rcnn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchvision/models/detection/faster_rcnn.py b/torchvision/models/detection/faster_rcnn.py index b38076e7383..8dcb107f059 100644 --- a/torchvision/models/detection/faster_rcnn.py +++ b/torchvision/models/detection/faster_rcnn.py @@ -319,7 +319,7 @@ def fasterrcnn_resnet50_fpn(pretrained=False, progress=True, >>> model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True) >>> # For training - >>> images, boxes, labels = torch.rand(4,3,600,1200), torch.rand(4,11,4), torch.rand(4,11) + >>> images, boxes, labels = torch.rand(4, 3, 600, 1200), torch.rand(4, 11, 4), torch.rand(4, 11) >>> images = list(image for image in images) >>> targets = [] >>> for i in range(len(images)): From 88d326eb5ac2679ea0134cc74602f00b562f7cb3 Mon Sep 17 00:00:00 2001 From: Francisco Massa Date: Thu, 2 Jan 2020 18:48:40 +0100 Subject: [PATCH 3/3] V3 --- torchvision/models/detection/faster_rcnn.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/torchvision/models/detection/faster_rcnn.py b/torchvision/models/detection/faster_rcnn.py index 8dcb107f059..19534f193ed 100644 --- a/torchvision/models/detection/faster_rcnn.py +++ b/torchvision/models/detection/faster_rcnn.py @@ -319,15 +319,16 @@ def fasterrcnn_resnet50_fpn(pretrained=False, progress=True, >>> model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True) >>> # For training - >>> images, boxes, labels = torch.rand(4, 3, 600, 1200), torch.rand(4, 11, 4), torch.rand(4, 11) + >>> images, boxes = torch.rand(4, 3, 600, 1200), torch.rand(4, 11, 4) + >>> labels = torch.randint(1, 91, (4, 11)) >>> images = list(image for image in images) >>> targets = [] >>> for i in range(len(images)): >>> d = {} >>> d['boxes'] = boxes[i] - >>> d['labels'] = labels[i].type(torch.int64) + >>> d['labels'] = labels[i] >>> targets.append(d) - >>> output = model(images,targets) + >>> output = model(images, targets) >>> # For inference >>> model.eval() >>> x = [torch.rand(3, 300, 400), torch.rand(3, 500, 400)]