Ejemplo n.º 1
0
batch_size, eval_batch_size = 4 * mul, 4
ds_train, ds_val, steps_per_epoch, val_steps = make_voc_dataset_sub(
    n_train, n_val, batch_size, eval_batch_size, preprocess)

backbone = resnet10()
model = FCOS(backbone,
             num_classes=20,
             feat_channels=64,
             stacked_convs=2,
             norm='bn')
model.build((None, HEIGHT, WIDTH, 3))

# load_checkpoint("./drive/MyDrive/models/ImageNet-86/ckpt", model=backbone)

criterion = DetectionLoss(box_loss_fn=iou_loss(mode='ciou', offset=True),
                          cls_loss_fn=focal_loss(alpha=0.25, gamma=2.0),
                          centerness=True)
base_lr = 0.0025
epochs = 60
lr_schedule = CosineLR(base_lr * mul,
                       steps_per_epoch,
                       epochs,
                       min_lr=0,
                       warmup_min_lr=base_lr,
                       warmup_epoch=5)
optimizer = SGD(lr_schedule, momentum=0.9, nesterov=True, weight_decay=1e-4)

train_metrics = {
    'loss': Mean(),
}
eval_metrics = {
Ejemplo n.º 2
0
    return image, {'bbox_target': bbox_targets, 'label': labels, 'centerness': centerness,
                   'image_id': image_id}

mul = 1
n_train, n_val = 8, 8
batch_size, eval_batch_size = 4 * mul, 8

ds_train, ds_val, steps_per_epoch, val_steps = make_dataset_sub(
    n_train, n_val, batch_size, eval_batch_size, transform)

backbone = resnet10()
model = ATSS(backbone, num_classes=80, feat_channels=64, stacked_convs=2)
model.build((None, HEIGHT, WIDTH, 3))

criterion = DetectionLoss(
    box_loss_fn=iou_loss(mode='giou'), cls_loss_fn=focal_loss(alpha=0.25, gamma=2.0),
    bbox_coder=bbox_coder, decode_pred=True, centerness=True)

base_lr = 0.0025
epochs = 100
lr_schedule = CosineLR(base_lr * mul, steps_per_epoch, epochs, min_lr=0,
                       warmup_min_lr=0, warmup_epoch=5)
optimizer = SGD(lr_schedule, momentum=0.9, nesterov=True, weight_decay=1e-4)

train_metrics = {
    'loss': Mean(),
}
eval_metrics = {
    'loss': MeanMetricWrapper(criterion),
}