def get_embeddings(image, net, device):
    transform = cvtransforms.Compose([
        cvtransforms.Resize((112, 112)),
        cvtransforms.RandomHorizontalFlip(),
        cvtransforms.ToTensor(),
        cvtransforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
    ])
    transformed_image = transform(image).to(device)
    the_image = Variable(transformed_image).unsqueeze(0)
    # net.eval()
    embeddings = l2_norm(net.forward(the_image)).detach()  # remain data at gpu
    return embeddings
Esempio n. 2
0
                                        test_indices, trainer):
    pass


def parameters_dict_to_model_name(parameters_dict):
    pass


if __name__ == "__main__":
    img_path = args.img_path
    gt_path = args.gt_path

    # create dataset
    train_input_transform_list = [
        cvtransforms.Resize(size=input_tensor_res, interpolation='BILINEAR'),
        cvtransforms.RandomHorizontalFlip(),
        cvtransforms.RandomVerticalFlip(),
        cvtransforms.RandomRotation(90),
        cvtransforms.ToTensor(),
        # cvtransforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    ]

    val_input_transform_list = [
        cvtransforms.Resize(size=input_tensor_res, interpolation='BILINEAR'),
        cvtransforms.ToTensor(),
        # cvtransforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    ]

    train_transforms = [
        compose_input_output_transform(
            input_transform=cvtransforms.Compose(train_input_transform_list)),