예제 #1
0
print(largest_object)

target_tensor = data.target_to_tensor(largest_object)
# Expected : {'bboxes': torch.tensor([0.5240, 0.5735, 0.8360, 0.7534]), 'labels': torch.tensor([5])})
print(target_tensor)

# The datasets is already downloaded on the cluster
dataset_dir = "/opt/Datasets/Pascal-VOC2012/"
download = False

# How do we preprocessing the image (e.g. none, crop, shrink)
image_transform_params = {'image_mode': 'none'}

# How do we preprocess the targets
target_transform_params = {
    'target_mode': 'largest_bbox',
    'image_transform_params': image_transform_params
}

# The post-processing of the image
image_transform = transforms.ToTensor()

train_dataset, valid_dataset = data.make_trainval_dataset(
    dataset_dir=dataset_dir,
    image_transform_params=image_transform_params,
    transform=image_transform,
    target_transform_params=target_transform_params,
    download=download)

print(train_dataset[203])
예제 #2
0
    }
}
target_transform_params = {
    'target_mode': 'only_cls',
    'image_transform_params': image_transform_params
}

imagenet_preprocessing = transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                              std=[0.229, 0.224, 0.225])

image_transform = transforms.Compose(
    [transforms.ToTensor(), imagenet_preprocessing])

train_dataset, val_dataset = data.make_trainval_dataset(
    image_transform_params=image_transform_params,
    transform=image_transform,
    target_transform_params=target_transform_params,
    download=True)
print(train_dataset[0])

train_loader = torch.utils.data.DataLoader(dataset=train_dataset,
                                           batch_size=32,
                                           shuffle=True,
                                           **kwargs)

valid_loader = torch.utils.data.DataLoader(dataset=val_dataset,
                                           batch_size=32,
                                           shuffle=False,
                                           **kwargs)
############################################ Model
model = extract.FeatureExtractor()