results = F.concat(id, score, bbox, dim=-1) # (b, 169, 3, 6) return F.reshape(results, shape=(0, -1, 6)) # (b, -1, 6) # test if __name__ == "__main__": from core import Yolov3, YoloTrainTransform, DetectionDataset import os input_size = (416, 416) root = os.path.dirname( os.path.dirname( os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) transform = YoloTrainTransform(input_size[0], input_size[1]) dataset = DetectionDataset(path=os.path.join(root, 'Dataset', 'train'), transform=transform) num_classes = dataset.num_class image, label, _ = dataset[0] net = Yolov3( Darknetlayer=53, input_size=input_size, anchors={ "shallow": [(10, 13), (16, 30), (33, 23)], "middle": [(30, 61), (62, 45), (59, 119)], "deep": [(116, 90), (156, 198), (373, 326)] }, num_classes=num_classes, # foreground만
scores = F.slice_axis(results, axis=-1, begin=1, end=2) bboxes = F.slice_axis(results, axis=-1, begin=2, end=6) return ids, scores, bboxes # test if __name__ == "__main__": from core import Yolov3, YoloTrainTransform, DetectionDataset import os input_size = (416, 416) root = os.path.dirname( os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) transform = YoloTrainTransform(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 = Yolov3( Darknetlayer=53, input_size=input_size, anchors={ "shallow": [(10, 13), (16, 30), (33, 23)], "middle": [(30, 61), (62, 45), (59, 119)], "deep": [(116, 90), (156, 198), (373, 326)]