MCPcopy Create free account
hub / github.com/ChenhongyiYang/QueryDet-PyTorch / __call__

Method __call__

visdrone/mapper.py:50–84  ·  view source on GitHub ↗
(self, dataset_dict)

Source from the content-addressed store, hash-verified

48 self.is_train = is_train
49
50 def __call__(self, dataset_dict):
51
52 dataset_dict = copy.deepcopy(dataset_dict)
53 image = utils.read_image(dataset_dict["file_name"], format=self.img_format)
54 utils.check_image_size(dataset_dict, image)
55
56 image, transforms = T.apply_transform_gens(self.tfm_gens, image)
57 image_shape = image.shape[:2] # h, w
58
59 dataset_dict["image"] = torch.as_tensor(np.ascontiguousarray(image.transpose(2, 0, 1)))
60
61
62 if not self.is_train:
63 dataset_dict.pop("annotations", None)
64 return dataset_dict
65
66 if "annotations" in dataset_dict:
67 # USER: Modify this if you want to keep them for some reason.
68 for anno in dataset_dict["annotations"]:
69 anno.pop("segmentation", None)
70 anno.pop("keypoints", None)
71
72 # USER: Implement additional transformations if you have other types of data
73 annos = [
74 utils.transform_instance_annotations(
75 obj, transforms, image_shape
76 )
77 for obj in dataset_dict.pop("annotations")
78 if obj.get("iscrowd", 0) == 0
79 ]
80 instances = utils.annotations_to_instances(
81 annos, image_shape, mask_format=self.mask_format
82 )
83 dataset_dict["instances"] = utils.filter_empty_instances(instances)
84 return dataset_dict
85
86
87def build_transform_gen(cfg, is_train):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected