MCPcopy Create free account
hub / github.com/TPCD/DCCL / __init__

Method __init__

project_utils/sampler.py:47–63  ·  view source on GitHub ↗
(self, data_source, num_instances=4)

Source from the content-addressed store, hash-verified

45
46class RandomMultipleGallerySampler(Sampler):
47 def __init__(self, data_source, num_instances=4):
48 super().__init__(data_source)
49 self.data_source = data_source
50 self.index_pid = defaultdict(int)
51 self.pid_cam = defaultdict(list)
52 self.pid_index = defaultdict(list)
53 self.num_instances = num_instances
54
55 for index, (_, pid, cam) in enumerate(data_source):
56 if pid < 0:
57 continue
58 self.index_pid[index] = pid
59 self.pid_cam[pid].append(cam)
60 self.pid_index[pid].append(index)
61
62 self.pids = list(self.pid_index.keys())
63 self.num_samples = len(self.pids)
64
65 def __len__(self):
66 return self.num_samples * self.num_instances

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected