コード例 #1
0
if __name__ == "__main__":
    import random
    from core import CenterNet, DetectionDataset, CenterValidTransform
    from core import Prediction
    from collections import OrderedDict

    input_size = (512, 512)
    root = os.path.dirname(
        os.path.dirname(
            os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
    transform = CenterValidTransform(input_size,
                                     mean=(0.485, 0.456, 0.406),
                                     std=(0.229, 0.224, 0.225),
                                     make_target=False)
    dataset = DetectionDataset(path=os.path.join(root, 'valid'),
                               transform=transform)
    num_classes = dataset.num_class
    name_classes = dataset.classes
    length = len(dataset)
    image, label, _, _, _ = dataset[random.randint(0, length - 1)]

    net = CenterNet(base=18,
                    heads=OrderedDict([('heatmap', {
                        'num_output': num_classes,
                        'bias': -2.19
                    }), ('offset', {
                        'num_output': 2
                    }), ('wh', {
                        'num_output': 2
                    })]),
                    head_conv_channel=64,
コード例 #2
0
        return ids, scores, bboxes


# test
if __name__ == "__main__":
    from core import Efficient, EfficientTrainTransform, DetectionDataset
    import os

    input_size = (512, 512)
    root = os.path.dirname(
        os.path.dirname(
            os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
    transform = EfficientTrainTransform(input_size[0],
                                        input_size[1],
                                        make_target=False)
    dataset = DetectionDataset(path=os.path.join(root, 'Dataset', 'train'),
                               transform=transform)
    num_classes = dataset.num_class
    image, label, _, _, _ = dataset[0]
    label = mx.nd.array(label)

    net = Efficient(
        version=0,
        input_size=input_size,
        anchor_sizes=[32, 64, 128, 256, 512],
        anchor_size_ratios=[1, pow(2, 1 / 3), pow(2, 2 / 3)],
        anchor_aspect_ratios=[0.5, 1, 2],
        num_classes=num_classes,  # foreground만
        anchor_box_offset=(0.5, 0.5),
        anchor_box_clip=True,
        alloc_size=[256, 256],
        ctx=mx.cpu())
コード例 #3
0
ファイル: mAP_voc.py プロジェクト: Royzon/Mxnet-Detector
        index = np.where(recall[1:] != recall[:-1])[0]
        AP = np.sum((recall[index + 1] - recall[index]) * precision[index + 1])
        return name, AP


if __name__ == "__main__":
    import random
    from core import SSD_VGG16, DetectionDataset
    from core import Prediction

    input_size = (512, 512)
    root = os.path.dirname(
        os.path.dirname(
            os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
    dataset = DetectionDataset(path=os.path.join(root, 'Dataset', 'train'),
                               input_size=input_size,
                               box_normalization=True)
    num_classes = dataset.num_class
    name_classes = dataset.classes
    length = len(dataset)
    image, label, _ = dataset[random.randint(0, length - 1)]

    net = SSD_VGG16(
        height_width_size=input_size,
        box_sizes=[21, 51.2, 133.12, 215.04, 296.96, 378.88, 460.8, 542.72],
        box_ratios=[[1, 2, 0.5]] +  # conv4_3
        [[1, 2, 0.5, 3, 1.0 / 3]] * 4 +  # conv7, conv8_2, conv9_2, conv10_2
        [[1, 2, 0.5]] * 2,  # conv11_2, conv12_2
        num_classes=num_classes,
        # feature_sizes=[38, 19, 10, 5, 3, 1], # input_size : 300 - 6개
        feature_sizes=[64, 32, 16, 8, 4, 2, 1],  # input_size : 512 - 7개