15. Object Detection
15.1. Data
[1]:
import numpy as np
import torch
from torch.utils.data import Dataset, DataLoader, Subset
from torchvision import transforms, utils
from torchvision.transforms import *
from PIL import Image
import pathlib
import xml.etree.ElementTree as ET
np.random.seed(37)
torch.manual_seed(37)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
def get_device():
if torch.cuda.is_available():
return torch.device('cuda')
else:
return torch.device('cpu')
def collate_fn(batch):
return tuple(zip(*batch))
class ShapeDataset(Dataset):
def __init__(self, root_dir, annot_dir='annots', image_dir='images',
transform=transforms.Compose([ToTensor()])):
self.annot_dir = f'{root_dir}/{annot_dir}'
self.image_dir = f'{root_dir}/{image_dir}'
self.transform = transform
self.__init()
def num_classes(self):
return len(self.class2index)
def __get_annot_files(self):
def clean_up(path):
import os
from shutil import rmtree
ipynb_checkpoints = f'{path}/.ipynb_checkpoints'
if os.path.exists(ipynb_checkpoints):
rmtree(ipynb_checkpoints)
clean_up(self.annot_dir)
return [f for f in pathlib.Path(self.annot_dir).glob('**/*.xml')]
def __get_classes(self):
xml_files = self.__get_annot_files()
names = set()
for xml_file in xml_files:
tree = ET.parse(xml_file)
root = tree.getroot()
for item in root.findall('./object'):
name = item.find('name').text
if name not in names:
names.add(name)
names = {name: i for i, name in enumerate(sorted(list(names)))}
return names
def __get_image_annotations(self, annot_path):
root = ET.parse(annot_path).getroot()
d = {}
# file names
d['annot_path'] = annot_path
d['image_path'] = f"{self.image_dir}/{root.find('filename').text}"
# size
size = root.find('./size')
d['size'] = {
'width': int(size.find('width').text),
'height': int(size.find('height').text),
'depth': int(size.find('depth').text)
}
# objects
d['objects'] = []
for obj in root.findall('./object'):
o = {}
o['name'] = obj.find('name').text
b = obj.find('bndbox')
o['xmin'] = int(b.find('xmin').text)
o['ymin'] = int(b.find('ymin').text)
o['xmax'] = int(b.find('xmax').text)
o['ymax'] = int(b.find('ymax').text)
d['objects'].append(o)
return d
def __init(self):
self.class2index = self.__get_classes()
annot_paths = [f'{str(f)}' for f in self.__get_annot_files()]
self.annotations = [self.__get_image_annotations(p) for p in annot_paths]
def __len__(self):
return len(self.annotations)
def __getitem__(self, idx):
def get_boxes(annot):
boxes = [[obj[f] for f in ['xmin', 'ymin', 'xmax', 'ymax']] for obj in annot['objects']]
return torch.as_tensor(boxes, dtype=torch.float)
def get_labels(annot):
labels = [self.class2index[obj['name']] for obj in annot['objects']]
return torch.as_tensor(labels, dtype=torch.int64)
def get_areas(annot):
areas = [(obj['xmax'] - obj['xmin']) * (obj['ymax'] - obj['ymin']) for obj in annot['objects']]
return torch.as_tensor(areas, dtype=torch.int64)
def get_iscrowds(annot):
return torch.zeros((len(annot['objects']),), dtype=torch.uint8)
annot = self.annotations[idx]
image_path = annot['image_path']
image = Image.open(image_path)
if self.transform:
image = self.transform(image)
target = {}
target['boxes'] = get_boxes(annot)
target['labels'] = get_labels(annot)
target['image_id'] = torch.as_tensor([idx], dtype=torch.int64)
target['area'] = get_areas(annot)
target['iscrowd'] = get_iscrowds(annot)
return image, target
dataset = ShapeDataset('./output/iaia-polygons')
indices = torch.randperm(len(dataset)).tolist()
dataset_train = Subset(dataset, indices[0:800])
dataset_test = Subset(dataset, indices[800:1000])
dataloader_train = DataLoader(
dataset, batch_size=2, shuffle=True, num_workers=4, collate_fn=collate_fn)
dataloader_test = DataLoader(
dataset_test, batch_size=1, shuffle=False, num_workers=4, collate_fn=collate_fn)
15.2. Model
[2]:
import torchvision
from torchvision.models.detection.faster_rcnn import FastRCNNPredictor
device = get_device()
model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True)
num_classes = dataset.num_classes()
in_features = model.roi_heads.box_predictor.cls_score.in_features
model.roi_heads.box_predictor = FastRCNNPredictor(in_features, num_classes)
model = model.to(device)
15.3. Optimizer and scheduler
[4]:
# construct an optimizer
params = [p for p in model.parameters() if p.requires_grad]
optimizer = torch.optim.SGD(params, lr=0.005, momentum=0.9, weight_decay=0.0005)
# and a learning rate scheduler
lr_scheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=3, gamma=0.1)
15.4. Helper code
[5]:
%%sh
if [ ! -d "output/vision" ]; then
git clone https://github.com/pytorch/vision.git output/vision
else
echo "output/vision already cloned"
fi
cp output/vision/references/detection/utils.py .
cp output/vision/references/detection/transforms.py .
cp output/vision/references/detection/coco_eval.py .
cp output/vision/references/detection/engine.py .
cp output/vision/references/detection/coco_utils.py .
output/vision already cloned
15.5. Training and testing
[6]:
from engine import train_one_epoch, evaluate
import utils
num_epochs = 10
for epoch in range(num_epochs):
# train for one epoch, printing every 10 iterations
train_one_epoch(model, optimizer, dataloader_train, device, epoch, print_freq=100)
# update the learning rate
lr_scheduler.step()
# evaluate on the test dataset
evaluate(model, dataloader_test, device=device)
print("That's it!")
Epoch: [0] [ 0/500] eta: 0:06:42 lr: 0.000015 loss: 2.2455 (2.2455) loss_classifier: 1.6276 (1.6276) loss_box_reg: 0.3966 (0.3966) loss_objectness: 0.1743 (0.1743) loss_rpn_box_reg: 0.0469 (0.0469) time: 0.8047 data: 0.2026 max mem: 1425
Epoch: [0] [100/500] eta: 0:01:29 lr: 0.001016 loss: 0.5915 (1.0514) loss_classifier: 0.3690 (0.6415) loss_box_reg: 0.2081 (0.3743) loss_objectness: 0.0001 (0.0153) loss_rpn_box_reg: 0.0148 (0.0203) time: 0.2184 data: 0.0036 max mem: 1691
Epoch: [0] [200/500] eta: 0:01:06 lr: 0.002017 loss: 0.0921 (0.6134) loss_classifier: 0.0525 (0.3667) loss_box_reg: 0.0295 (0.2214) loss_objectness: 0.0000 (0.0080) loss_rpn_box_reg: 0.0101 (0.0173) time: 0.2185 data: 0.0035 max mem: 1691
Epoch: [0] [300/500] eta: 0:00:44 lr: 0.003018 loss: 0.0811 (0.4349) loss_classifier: 0.0338 (0.2571) loss_box_reg: 0.0314 (0.1570) loss_objectness: 0.0002 (0.0054) loss_rpn_box_reg: 0.0095 (0.0155) time: 0.2187 data: 0.0036 max mem: 1691
Epoch: [0] [400/500] eta: 0:00:22 lr: 0.004019 loss: 0.0724 (0.3435) loss_classifier: 0.0320 (0.2012) loss_box_reg: 0.0228 (0.1241) loss_objectness: 0.0003 (0.0041) loss_rpn_box_reg: 0.0109 (0.0142) time: 0.2190 data: 0.0036 max mem: 1691
Epoch: [0] [499/500] eta: 0:00:00 lr: 0.005000 loss: 0.0608 (0.2873) loss_classifier: 0.0316 (0.1675) loss_box_reg: 0.0172 (0.1031) loss_objectness: 0.0003 (0.0034) loss_rpn_box_reg: 0.0101 (0.0133) time: 0.2197 data: 0.0036 max mem: 1691
Epoch: [0] Total time: 0:01:50 (0.2202 s / it)
creating index...
index created!
Test: [ 0/200] eta: 0:01:07 model_time: 0.1846 (0.1846) evaluator_time: 0.0035 (0.0035) time: 0.3380 data: 0.1491 max mem: 1691
Test: [100/200] eta: 0:00:04 model_time: 0.0389 (0.0406) evaluator_time: 0.0023 (0.0025) time: 0.0437 data: 0.0019 max mem: 1691
Test: [199/200] eta: 0:00:00 model_time: 0.0393 (0.0398) evaluator_time: 0.0024 (0.0024) time: 0.0445 data: 0.0021 max mem: 1691
Test: Total time: 0:00:09 (0.0457 s / it)
Averaged stats: model_time: 0.0393 (0.0398) evaluator_time: 0.0024 (0.0024)
Accumulating evaluation results...
DONE (t=0.11s).
IoU metric: bbox
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.786
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.802
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.780
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.615
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.806
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.806
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.816
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.799
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Epoch: [1] [ 0/500] eta: 0:03:05 lr: 0.005000 loss: 0.0618 (0.0618) loss_classifier: 0.0346 (0.0346) loss_box_reg: 0.0132 (0.0132) loss_objectness: 0.0006 (0.0006) loss_rpn_box_reg: 0.0134 (0.0134) time: 0.3716 data: 0.1524 max mem: 1691
Epoch: [1] [100/500] eta: 0:01:28 lr: 0.005000 loss: 0.0528 (0.0532) loss_classifier: 0.0280 (0.0268) loss_box_reg: 0.0123 (0.0139) loss_objectness: 0.0005 (0.0005) loss_rpn_box_reg: 0.0133 (0.0120) time: 0.2193 data: 0.0036 max mem: 1691
Epoch: [1] [200/500] eta: 0:01:06 lr: 0.005000 loss: 0.0398 (0.0538) loss_classifier: 0.0226 (0.0264) loss_box_reg: 0.0080 (0.0161) loss_objectness: 0.0002 (0.0004) loss_rpn_box_reg: 0.0068 (0.0109) time: 0.2201 data: 0.0037 max mem: 1691
Epoch: [1] [300/500] eta: 0:00:44 lr: 0.005000 loss: 0.0349 (0.0488) loss_classifier: 0.0193 (0.0247) loss_box_reg: 0.0069 (0.0137) loss_objectness: 0.0003 (0.0004) loss_rpn_box_reg: 0.0078 (0.0101) time: 0.2204 data: 0.0037 max mem: 1691
Epoch: [1] [400/500] eta: 0:00:21 lr: 0.005000 loss: 0.0398 (0.0457) loss_classifier: 0.0201 (0.0235) loss_box_reg: 0.0073 (0.0122) loss_objectness: 0.0004 (0.0004) loss_rpn_box_reg: 0.0100 (0.0096) time: 0.2197 data: 0.0036 max mem: 1691
Epoch: [1] [499/500] eta: 0:00:00 lr: 0.005000 loss: 0.0381 (0.0439) loss_classifier: 0.0179 (0.0229) loss_box_reg: 0.0076 (0.0113) loss_objectness: 0.0004 (0.0004) loss_rpn_box_reg: 0.0086 (0.0094) time: 0.2195 data: 0.0036 max mem: 1691
Epoch: [1] Total time: 0:01:49 (0.2200 s / it)
creating index...
index created!
Test: [ 0/200] eta: 0:00:42 model_time: 0.0488 (0.0488) evaluator_time: 0.0035 (0.0035) time: 0.2146 data: 0.1613 max mem: 1691
Test: [100/200] eta: 0:00:04 model_time: 0.0392 (0.0393) evaluator_time: 0.0024 (0.0022) time: 0.0442 data: 0.0020 max mem: 1691
Test: [199/200] eta: 0:00:00 model_time: 0.0392 (0.0392) evaluator_time: 0.0021 (0.0022) time: 0.0440 data: 0.0020 max mem: 1691
Test: Total time: 0:00:09 (0.0451 s / it)
Averaged stats: model_time: 0.0392 (0.0392) evaluator_time: 0.0021 (0.0022)
Accumulating evaluation results...
DONE (t=0.12s).
IoU metric: bbox
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.811
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.816
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.810
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.632
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.829
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.829
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.830
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.828
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Epoch: [2] [ 0/500] eta: 0:03:15 lr: 0.005000 loss: 0.0397 (0.0397) loss_classifier: 0.0215 (0.0215) loss_box_reg: 0.0083 (0.0083) loss_objectness: 0.0003 (0.0003) loss_rpn_box_reg: 0.0096 (0.0096) time: 0.3920 data: 0.1738 max mem: 1691
Epoch: [2] [100/500] eta: 0:01:28 lr: 0.005000 loss: 0.0338 (0.0362) loss_classifier: 0.0178 (0.0196) loss_box_reg: 0.0074 (0.0071) loss_objectness: 0.0003 (0.0004) loss_rpn_box_reg: 0.0076 (0.0091) time: 0.2194 data: 0.0035 max mem: 1691
Epoch: [2] [200/500] eta: 0:01:06 lr: 0.005000 loss: 0.0335 (0.0375) loss_classifier: 0.0206 (0.0199) loss_box_reg: 0.0070 (0.0076) loss_objectness: 0.0004 (0.0004) loss_rpn_box_reg: 0.0069 (0.0097) time: 0.2191 data: 0.0035 max mem: 1691
Epoch: [2] [300/500] eta: 0:00:44 lr: 0.005000 loss: 0.0327 (0.0363) loss_classifier: 0.0189 (0.0201) loss_box_reg: 0.0059 (0.0069) loss_objectness: 0.0004 (0.0004) loss_rpn_box_reg: 0.0083 (0.0089) time: 0.2200 data: 0.0037 max mem: 1691
Epoch: [2] [400/500] eta: 0:00:22 lr: 0.005000 loss: 0.0301 (0.0365) loss_classifier: 0.0170 (0.0204) loss_box_reg: 0.0046 (0.0068) loss_objectness: 0.0003 (0.0004) loss_rpn_box_reg: 0.0084 (0.0089) time: 0.2199 data: 0.0037 max mem: 1691
Epoch: [2] [499/500] eta: 0:00:00 lr: 0.005000 loss: 0.0307 (0.0357) loss_classifier: 0.0147 (0.0202) loss_box_reg: 0.0063 (0.0066) loss_objectness: 0.0002 (0.0004) loss_rpn_box_reg: 0.0068 (0.0085) time: 0.2192 data: 0.0035 max mem: 1691
Epoch: [2] Total time: 0:01:50 (0.2200 s / it)
creating index...
index created!
Test: [ 0/200] eta: 0:00:40 model_time: 0.0480 (0.0480) evaluator_time: 0.0036 (0.0036) time: 0.2046 data: 0.1519 max mem: 1691
Test: [100/200] eta: 0:00:04 model_time: 0.0391 (0.0395) evaluator_time: 0.0023 (0.0022) time: 0.0440 data: 0.0020 max mem: 1691
Test: [199/200] eta: 0:00:00 model_time: 0.0389 (0.0393) evaluator_time: 0.0020 (0.0022) time: 0.0436 data: 0.0019 max mem: 1691
Test: Total time: 0:00:09 (0.0451 s / it)
Averaged stats: model_time: 0.0389 (0.0393) evaluator_time: 0.0020 (0.0022)
Accumulating evaluation results...
DONE (t=0.11s).
IoU metric: bbox
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.825
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.843
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.817
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.642
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.841
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.841
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.853
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.832
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Epoch: [3] [ 0/500] eta: 0:03:10 lr: 0.000500 loss: 0.0252 (0.0252) loss_classifier: 0.0105 (0.0105) loss_box_reg: 0.0046 (0.0046) loss_objectness: 0.0004 (0.0004) loss_rpn_box_reg: 0.0097 (0.0097) time: 0.3820 data: 0.1618 max mem: 1691
Epoch: [3] [100/500] eta: 0:01:28 lr: 0.000500 loss: 0.0209 (0.0223) loss_classifier: 0.0143 (0.0152) loss_box_reg: 0.0031 (0.0030) loss_objectness: 0.0003 (0.0003) loss_rpn_box_reg: 0.0033 (0.0039) time: 0.2199 data: 0.0036 max mem: 1691
Epoch: [3] [200/500] eta: 0:01:06 lr: 0.000500 loss: 0.0207 (0.0216) loss_classifier: 0.0145 (0.0151) loss_box_reg: 0.0026 (0.0027) loss_objectness: 0.0001 (0.0002) loss_rpn_box_reg: 0.0026 (0.0035) time: 0.2194 data: 0.0036 max mem: 1691
Epoch: [3] [300/500] eta: 0:00:44 lr: 0.000500 loss: 0.0189 (0.0210) loss_classifier: 0.0141 (0.0149) loss_box_reg: 0.0024 (0.0026) loss_objectness: 0.0001 (0.0002) loss_rpn_box_reg: 0.0027 (0.0033) time: 0.2199 data: 0.0036 max mem: 1691
Epoch: [3] [400/500] eta: 0:00:22 lr: 0.000500 loss: 0.0215 (0.0207) loss_classifier: 0.0145 (0.0148) loss_box_reg: 0.0027 (0.0026) loss_objectness: 0.0001 (0.0002) loss_rpn_box_reg: 0.0032 (0.0031) time: 0.2197 data: 0.0036 max mem: 1691
Epoch: [3] [499/500] eta: 0:00:00 lr: 0.000500 loss: 0.0178 (0.0205) loss_classifier: 0.0127 (0.0147) loss_box_reg: 0.0026 (0.0026) loss_objectness: 0.0001 (0.0002) loss_rpn_box_reg: 0.0028 (0.0031) time: 0.2201 data: 0.0037 max mem: 1691
Epoch: [3] Total time: 0:01:50 (0.2202 s / it)
creating index...
index created!
Test: [ 0/200] eta: 0:00:39 model_time: 0.0476 (0.0476) evaluator_time: 0.0033 (0.0033) time: 0.1989 data: 0.1470 max mem: 1691
Test: [100/200] eta: 0:00:04 model_time: 0.0391 (0.0393) evaluator_time: 0.0023 (0.0022) time: 0.0439 data: 0.0020 max mem: 1691
Test: [199/200] eta: 0:00:00 model_time: 0.0393 (0.0393) evaluator_time: 0.0022 (0.0022) time: 0.0443 data: 0.0020 max mem: 1691
Test: Total time: 0:00:09 (0.0450 s / it)
Averaged stats: model_time: 0.0393 (0.0393) evaluator_time: 0.0022 (0.0022)
Accumulating evaluation results...
DONE (t=0.12s).
IoU metric: bbox
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.865
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.868
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.863
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.664
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.870
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.870
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.871
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.868
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Epoch: [4] [ 0/500] eta: 0:03:10 lr: 0.000500 loss: 0.0092 (0.0092) loss_classifier: 0.0055 (0.0055) loss_box_reg: 0.0017 (0.0017) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0020 (0.0020) time: 0.3803 data: 0.1605 max mem: 1691
Epoch: [4] [100/500] eta: 0:01:28 lr: 0.000500 loss: 0.0180 (0.0180) loss_classifier: 0.0131 (0.0130) loss_box_reg: 0.0024 (0.0023) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0027 (0.0026) time: 0.2202 data: 0.0036 max mem: 1691
Epoch: [4] [200/500] eta: 0:01:06 lr: 0.000500 loss: 0.0196 (0.0188) loss_classifier: 0.0140 (0.0135) loss_box_reg: 0.0024 (0.0024) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0029 (0.0027) time: 0.2197 data: 0.0036 max mem: 1691
Epoch: [4] [300/500] eta: 0:00:44 lr: 0.000500 loss: 0.0191 (0.0189) loss_classifier: 0.0135 (0.0136) loss_box_reg: 0.0025 (0.0024) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0026 (0.0027) time: 0.2201 data: 0.0036 max mem: 1691
Epoch: [4] [400/500] eta: 0:00:22 lr: 0.000500 loss: 0.0182 (0.0188) loss_classifier: 0.0139 (0.0136) loss_box_reg: 0.0025 (0.0024) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0024 (0.0027) time: 0.2199 data: 0.0037 max mem: 1691
Epoch: [4] [499/500] eta: 0:00:00 lr: 0.000500 loss: 0.0188 (0.0187) loss_classifier: 0.0139 (0.0135) loss_box_reg: 0.0023 (0.0024) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0026 (0.0027) time: 0.2201 data: 0.0037 max mem: 1691
Epoch: [4] Total time: 0:01:50 (0.2205 s / it)
creating index...
index created!
Test: [ 0/200] eta: 0:00:40 model_time: 0.0479 (0.0479) evaluator_time: 0.0036 (0.0036) time: 0.2043 data: 0.1517 max mem: 1691
Test: [100/200] eta: 0:00:04 model_time: 0.0393 (0.0395) evaluator_time: 0.0024 (0.0023) time: 0.0443 data: 0.0020 max mem: 1691
Test: [199/200] eta: 0:00:00 model_time: 0.0390 (0.0394) evaluator_time: 0.0019 (0.0023) time: 0.0436 data: 0.0019 max mem: 1691
Test: Total time: 0:00:09 (0.0452 s / it)
Averaged stats: model_time: 0.0390 (0.0394) evaluator_time: 0.0019 (0.0023)
Accumulating evaluation results...
DONE (t=0.11s).
IoU metric: bbox
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.865
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.866
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.865
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.663
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.869
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.869
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.870
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.869
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Epoch: [5] [ 0/500] eta: 0:03:14 lr: 0.000500 loss: 0.0269 (0.0269) loss_classifier: 0.0205 (0.0205) loss_box_reg: 0.0026 (0.0026) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0037 (0.0037) time: 0.3881 data: 0.1662 max mem: 1691
Epoch: [5] [100/500] eta: 0:01:28 lr: 0.000500 loss: 0.0157 (0.0185) loss_classifier: 0.0112 (0.0135) loss_box_reg: 0.0020 (0.0024) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0023 (0.0025) time: 0.2209 data: 0.0038 max mem: 1691
Epoch: [5] [200/500] eta: 0:01:06 lr: 0.000500 loss: 0.0194 (0.0184) loss_classifier: 0.0134 (0.0134) loss_box_reg: 0.0025 (0.0024) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0027 (0.0025) time: 0.2201 data: 0.0036 max mem: 1691
Epoch: [5] [300/500] eta: 0:00:44 lr: 0.000500 loss: 0.0161 (0.0183) loss_classifier: 0.0110 (0.0133) loss_box_reg: 0.0024 (0.0024) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0025 (0.0025) time: 0.2197 data: 0.0036 max mem: 1691
Epoch: [5] [400/500] eta: 0:00:22 lr: 0.000500 loss: 0.0158 (0.0182) loss_classifier: 0.0112 (0.0132) loss_box_reg: 0.0024 (0.0024) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0024 (0.0025) time: 0.2200 data: 0.0037 max mem: 1691
Epoch: [5] [499/500] eta: 0:00:00 lr: 0.000500 loss: 0.0184 (0.0182) loss_classifier: 0.0123 (0.0132) loss_box_reg: 0.0023 (0.0024) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0022 (0.0025) time: 0.2210 data: 0.0037 max mem: 1691
Epoch: [5] Total time: 0:01:50 (0.2209 s / it)
creating index...
index created!
Test: [ 0/200] eta: 0:00:40 model_time: 0.0477 (0.0477) evaluator_time: 0.0035 (0.0035) time: 0.2011 data: 0.1491 max mem: 1691
Test: [100/200] eta: 0:00:04 model_time: 0.0390 (0.0394) evaluator_time: 0.0022 (0.0022) time: 0.0437 data: 0.0019 max mem: 1691
Test: [199/200] eta: 0:00:00 model_time: 0.0389 (0.0392) evaluator_time: 0.0019 (0.0021) time: 0.0435 data: 0.0019 max mem: 1691
Test: Total time: 0:00:08 (0.0448 s / it)
Averaged stats: model_time: 0.0389 (0.0392) evaluator_time: 0.0019 (0.0021)
Accumulating evaluation results...
DONE (t=0.11s).
IoU metric: bbox
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.866
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.870
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.865
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.664
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.870
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.870
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.872
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.869
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Epoch: [6] [ 0/500] eta: 0:03:11 lr: 0.000050 loss: 0.0210 (0.0210) loss_classifier: 0.0143 (0.0143) loss_box_reg: 0.0024 (0.0024) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0042 (0.0042) time: 0.3839 data: 0.1648 max mem: 1691
Epoch: [6] [100/500] eta: 0:01:28 lr: 0.000050 loss: 0.0170 (0.0173) loss_classifier: 0.0119 (0.0128) loss_box_reg: 0.0024 (0.0022) loss_objectness: 0.0000 (0.0001) loss_rpn_box_reg: 0.0020 (0.0022) time: 0.2204 data: 0.0037 max mem: 1691
Epoch: [6] [200/500] eta: 0:01:06 lr: 0.000050 loss: 0.0161 (0.0173) loss_classifier: 0.0120 (0.0128) loss_box_reg: 0.0023 (0.0023) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0018 (0.0022) time: 0.2200 data: 0.0036 max mem: 1691
Epoch: [6] [300/500] eta: 0:00:44 lr: 0.000050 loss: 0.0170 (0.0176) loss_classifier: 0.0127 (0.0130) loss_box_reg: 0.0025 (0.0023) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0024 (0.0022) time: 0.2202 data: 0.0036 max mem: 1691
Epoch: [6] [400/500] eta: 0:00:22 lr: 0.000050 loss: 0.0166 (0.0177) loss_classifier: 0.0122 (0.0131) loss_box_reg: 0.0019 (0.0023) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0019 (0.0022) time: 0.2199 data: 0.0036 max mem: 1691
Epoch: [6] [499/500] eta: 0:00:00 lr: 0.000050 loss: 0.0161 (0.0176) loss_classifier: 0.0122 (0.0130) loss_box_reg: 0.0021 (0.0023) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0020 (0.0022) time: 0.2205 data: 0.0037 max mem: 1691
Epoch: [6] Total time: 0:01:50 (0.2210 s / it)
creating index...
index created!
Test: [ 0/200] eta: 0:00:39 model_time: 0.0480 (0.0480) evaluator_time: 0.0035 (0.0035) time: 0.1984 data: 0.1457 max mem: 1691
Test: [100/200] eta: 0:00:04 model_time: 0.0394 (0.0395) evaluator_time: 0.0024 (0.0022) time: 0.0446 data: 0.0021 max mem: 1691
Test: [199/200] eta: 0:00:00 model_time: 0.0392 (0.0394) evaluator_time: 0.0019 (0.0023) time: 0.0439 data: 0.0020 max mem: 1691
Test: Total time: 0:00:09 (0.0452 s / it)
Averaged stats: model_time: 0.0392 (0.0394) evaluator_time: 0.0019 (0.0023)
Accumulating evaluation results...
DONE (t=0.11s).
IoU metric: bbox
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.868
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.868
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.868
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.665
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.871
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.871
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.871
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.871
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Epoch: [7] [ 0/500] eta: 0:03:14 lr: 0.000050 loss: 0.0221 (0.0221) loss_classifier: 0.0153 (0.0153) loss_box_reg: 0.0027 (0.0027) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0040 (0.0040) time: 0.3893 data: 0.1700 max mem: 1691
Epoch: [7] [100/500] eta: 0:01:28 lr: 0.000050 loss: 0.0151 (0.0182) loss_classifier: 0.0107 (0.0137) loss_box_reg: 0.0022 (0.0023) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0020 (0.0022) time: 0.2199 data: 0.0035 max mem: 1691
Epoch: [7] [200/500] eta: 0:01:06 lr: 0.000050 loss: 0.0181 (0.0178) loss_classifier: 0.0141 (0.0133) loss_box_reg: 0.0022 (0.0022) loss_objectness: 0.0000 (0.0001) loss_rpn_box_reg: 0.0019 (0.0021) time: 0.2200 data: 0.0035 max mem: 1691
Epoch: [7] [300/500] eta: 0:00:44 lr: 0.000050 loss: 0.0172 (0.0175) loss_classifier: 0.0129 (0.0131) loss_box_reg: 0.0023 (0.0022) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0021 (0.0021) time: 0.2200 data: 0.0036 max mem: 1691
Epoch: [7] [400/500] eta: 0:00:22 lr: 0.000050 loss: 0.0168 (0.0175) loss_classifier: 0.0119 (0.0130) loss_box_reg: 0.0023 (0.0023) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0019 (0.0021) time: 0.2213 data: 0.0039 max mem: 1691
Epoch: [7] [499/500] eta: 0:00:00 lr: 0.000050 loss: 0.0158 (0.0175) loss_classifier: 0.0111 (0.0130) loss_box_reg: 0.0020 (0.0022) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0017 (0.0021) time: 0.2209 data: 0.0038 max mem: 1691
Epoch: [7] Total time: 0:01:50 (0.2208 s / it)
creating index...
index created!
Test: [ 0/200] eta: 0:00:39 model_time: 0.0483 (0.0483) evaluator_time: 0.0039 (0.0039) time: 0.1992 data: 0.1460 max mem: 1691
Test: [100/200] eta: 0:00:04 model_time: 0.0391 (0.0395) evaluator_time: 0.0023 (0.0023) time: 0.0439 data: 0.0019 max mem: 1691
Test: [199/200] eta: 0:00:00 model_time: 0.0390 (0.0393) evaluator_time: 0.0019 (0.0022) time: 0.0435 data: 0.0019 max mem: 1691
Test: Total time: 0:00:08 (0.0450 s / it)
Averaged stats: model_time: 0.0390 (0.0393) evaluator_time: 0.0019 (0.0022)
Accumulating evaluation results...
DONE (t=0.11s).
IoU metric: bbox
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.869
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.869
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.870
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.666
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.872
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.872
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.872
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.872
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Epoch: [8] [ 0/500] eta: 0:03:11 lr: 0.000050 loss: 0.0162 (0.0162) loss_classifier: 0.0112 (0.0112) loss_box_reg: 0.0026 (0.0026) loss_objectness: 0.0000 (0.0000) loss_rpn_box_reg: 0.0024 (0.0024) time: 0.3835 data: 0.1635 max mem: 1691
Epoch: [8] [100/500] eta: 0:01:28 lr: 0.000050 loss: 0.0171 (0.0170) loss_classifier: 0.0120 (0.0126) loss_box_reg: 0.0021 (0.0022) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0022 (0.0021) time: 0.2204 data: 0.0037 max mem: 1691
Epoch: [8] [200/500] eta: 0:01:06 lr: 0.000050 loss: 0.0187 (0.0176) loss_classifier: 0.0137 (0.0131) loss_box_reg: 0.0024 (0.0022) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0023 (0.0021) time: 0.2211 data: 0.0037 max mem: 1691
Epoch: [8] [300/500] eta: 0:00:44 lr: 0.000050 loss: 0.0167 (0.0175) loss_classifier: 0.0123 (0.0130) loss_box_reg: 0.0021 (0.0023) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0020 (0.0022) time: 0.2204 data: 0.0037 max mem: 1691
Epoch: [8] [400/500] eta: 0:00:22 lr: 0.000050 loss: 0.0158 (0.0175) loss_classifier: 0.0113 (0.0130) loss_box_reg: 0.0019 (0.0023) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0021 (0.0022) time: 0.2203 data: 0.0036 max mem: 1691
Epoch: [8] [499/500] eta: 0:00:00 lr: 0.000050 loss: 0.0145 (0.0173) loss_classifier: 0.0104 (0.0129) loss_box_reg: 0.0022 (0.0022) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0019 (0.0021) time: 0.2199 data: 0.0036 max mem: 1691
Epoch: [8] Total time: 0:01:50 (0.2208 s / it)
creating index...
index created!
Test: [ 0/200] eta: 0:00:40 model_time: 0.0479 (0.0479) evaluator_time: 0.0036 (0.0036) time: 0.2024 data: 0.1499 max mem: 1691
Test: [100/200] eta: 0:00:04 model_time: 0.0390 (0.0393) evaluator_time: 0.0022 (0.0022) time: 0.0438 data: 0.0019 max mem: 1691
Test: [199/200] eta: 0:00:00 model_time: 0.0391 (0.0392) evaluator_time: 0.0019 (0.0021) time: 0.0438 data: 0.0019 max mem: 1691
Test: Total time: 0:00:08 (0.0448 s / it)
Averaged stats: model_time: 0.0391 (0.0392) evaluator_time: 0.0019 (0.0021)
Accumulating evaluation results...
DONE (t=0.11s).
IoU metric: bbox
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.869
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.868
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.869
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.666
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.872
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.872
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.871
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.872
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Epoch: [9] [ 0/500] eta: 0:03:08 lr: 0.000005 loss: 0.0205 (0.0205) loss_classifier: 0.0156 (0.0156) loss_box_reg: 0.0025 (0.0025) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0024 (0.0024) time: 0.3780 data: 0.1579 max mem: 1691
Epoch: [9] [100/500] eta: 0:01:28 lr: 0.000005 loss: 0.0159 (0.0173) loss_classifier: 0.0114 (0.0128) loss_box_reg: 0.0021 (0.0023) loss_objectness: 0.0000 (0.0001) loss_rpn_box_reg: 0.0021 (0.0021) time: 0.2200 data: 0.0035 max mem: 1691
Epoch: [9] [200/500] eta: 0:01:06 lr: 0.000005 loss: 0.0170 (0.0171) loss_classifier: 0.0127 (0.0126) loss_box_reg: 0.0023 (0.0023) loss_objectness: 0.0000 (0.0001) loss_rpn_box_reg: 0.0022 (0.0021) time: 0.2203 data: 0.0036 max mem: 1691
Epoch: [9] [300/500] eta: 0:00:44 lr: 0.000005 loss: 0.0151 (0.0169) loss_classifier: 0.0112 (0.0125) loss_box_reg: 0.0021 (0.0023) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0019 (0.0021) time: 0.2203 data: 0.0036 max mem: 1691
Epoch: [9] [400/500] eta: 0:00:22 lr: 0.000005 loss: 0.0153 (0.0170) loss_classifier: 0.0115 (0.0126) loss_box_reg: 0.0019 (0.0022) loss_objectness: 0.0001 (0.0001) loss_rpn_box_reg: 0.0020 (0.0021) time: 0.2205 data: 0.0036 max mem: 1691
Epoch: [9] [499/500] eta: 0:00:00 lr: 0.000005 loss: 0.0149 (0.0170) loss_classifier: 0.0106 (0.0126) loss_box_reg: 0.0019 (0.0022) loss_objectness: 0.0000 (0.0001) loss_rpn_box_reg: 0.0018 (0.0021) time: 0.2207 data: 0.0036 max mem: 1691
Epoch: [9] Total time: 0:01:50 (0.2211 s / it)
creating index...
index created!
Test: [ 0/200] eta: 0:00:39 model_time: 0.0481 (0.0481) evaluator_time: 0.0035 (0.0035) time: 0.1973 data: 0.1443 max mem: 1691
Test: [100/200] eta: 0:00:04 model_time: 0.0391 (0.0395) evaluator_time: 0.0023 (0.0022) time: 0.0439 data: 0.0019 max mem: 1691
Test: [199/200] eta: 0:00:00 model_time: 0.0393 (0.0394) evaluator_time: 0.0022 (0.0022) time: 0.0441 data: 0.0020 max mem: 1691
Test: Total time: 0:00:09 (0.0453 s / it)
Averaged stats: model_time: 0.0393 (0.0394) evaluator_time: 0.0022 (0.0022)
Accumulating evaluation results...
DONE (t=0.12s).
IoU metric: bbox
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.869
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.875
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.868
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.869
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.666
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.872
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.872
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.871
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.872
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
That's it!
15.6. Predictions
[85]:
import matplotlib.pyplot as plt
from matplotlib.pyplot import imshow
import matplotlib.patches as patches
def get_prediction(dataset, idx, model):
img, _ = dataset[idx]
model.eval()
with torch.no_grad():
prediction = model([img.to(device)])
return img, prediction
def get_rects(boxes):
rect = lambda x, y, w, h: patches.Rectangle((x, y), w - x, h - y, linewidth=1, edgecolor='r', facecolor='none')
return [rect(box[0], box[1], box[2], box[3]) for box in boxes]
def get_clazzes(labels, boxes, index2class):
return [{'x': box[0].item(), 'y': box[1].item() - 5.0, 's': index2class[label.item()], 'fontsize': 10}
for label, box in zip(labels, boxes)]
def show_prediction(img, index2class, fig, ax):
pil_image = Image.fromarray(img.mul(255).permute(1, 2, 0).byte().numpy())
ax.imshow(pil_image)
ax.axes.xaxis.set_visible(False)
ax.axes.yaxis.set_visible(False)
for rect in get_rects(prediction[0]['boxes']):
ax.add_patch(rect)
for label in get_clazzes(prediction[0]['labels'], prediction[0]['boxes'], index2class):
ax.text(**label)
predictions = [get_prediction(dataset_train, i, model) for i in range(3)]
fig, ax = plt.subplots(1, 3, figsize=(20, 5))
index2class = {i: c for c, i in dataset.class2index.items()}
for (img, prediction), a in zip(predictions, ax):
show_prediction(img, index2class, fig, a)
plt.tight_layout()