help='Enable or not cuda') parser.add_argument('--test_filenames', default='test_images/*.jpg', type=str, help='Regex of filenames') args = parser.parse_args() net = SSD(cuda=args.cuda, architecture='300_VGG16', num_classes=len(LogoDataset.CLASSES)) has_cuda = args.cuda and torch.cuda.is_available() if has_cuda: weights = torch.load(args.weights)['model'] else: weights = torch.load(args.weights, map_location='cpu')['model'] net = SSD.load(weights=weights) COLORMAP = [(255, 0, 0), (0, 255, 0), (0, 0, 255)] images = [] images = [cv2.imread(filename) for filename in glob.glob(args.test_filenames)] results = net.predict(images) for im, result_image in zip(images, results): for i, result in enumerate(result_image): print(LogoDataset.CLASSES[result['class']]) class_ = LogoDataset.CLASSES[result['class']] position = result['position'] confidence = int(100 * result['confidence']) cv2.rectangle(im, (int(position[0]), int(position[1])),