Пример #1
0
def gen_bbox_transform(img_size):
    transform = T.Compose([
        T.NormalizeBbox(),
        T.Resize(img_size),
        T.DenormalizeBbox(),
    ])

    def fun(img, bbox):
        _, bbox = transform(img, bbox)
        return torch.from_numpy(bbox)

    return fun
Пример #2
0
def build_concept_quantization_clevr_dataset(args, configs, image_root, scenes_json):
    import jactorch.transforms.bbox as T
    image_transform = T.Compose([
        T.NormalizeBbox(),
        T.Resize(configs.data.image_size),
        T.DenormalizeBbox(),
        T.ToTensor(),
        T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    ])

    from nscl.datasets.datasets import ConceptQuantizationDataset
    dataset = ConceptQuantizationDataset(scenes_json, image_root=image_root, image_transform=image_transform)
    return dataset
Пример #3
0
def build_clevr_dataset(args, configs, image_root, scenes_json, questions_json):
    import jactorch.transforms.bbox as T
    image_transform = T.Compose([
        T.NormalizeBbox(),
        T.Resize(configs.data.image_size),
        T.DenormalizeBbox(),
        T.ToTensor(),
        T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    ])

    from nscl.datasets.datasets import NSCLDataset
    dataset = NSCLDataset(
        scenes_json, questions_json,
        image_root=image_root, image_transform=image_transform,
        vocab_json=args.data_vocab_json
    )

    return dataset
Пример #4
0
def build_concept_retrieval_clevrer_dataset(args, configs, program, image_root,
                                            scenes_json):
    import jactorch.transforms.bbox as T

    image_transform = T.Compose([
        T.NormalizeBbox(),
        T.Resize(configs.data.image_size),
        T.DenormalizeBbox(),
        T.ToTensor(),
        T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
    ])

    from nscl.datasets.datasets import ConceptRetrievalDataset

    dataset = ConceptRetrievalDataset(program,
                                      scenes_json,
                                      image_root=image_root,
                                      image_transform=image_transform)
    return dataset