in src/data_packer.py [0:0]
def extract_batch(self, frames, **kwargs):
result = np.empty((len(frames), self.entries), dtype=np.float32)
idx = 0
if "random_occlusion" in kwargs and kwargs["random_occlusion"] is not None:
random_occlusion = float(kwargs["random_occlusion"])
occ = np.random.rand(frames.shape[0], frames.shape[1])
if random_occlusion > 0.0001:
frames[:, :, 9][occ > (1 - random_occlusion)] = 1
frames[:, :, 9][occ <= (1 - random_occlusion)] = 0
elif random_occlusion < 0.0001:
frames[:, :, 9][occ > (1 + random_occlusion)] = 1
# all joints with an id less that min_occluded_index cannot be occluded
min_occluded_index = -1
for f in self.features:
result[:, idx: idx + f.entries] = f.extract_batch(frames, **kwargs).reshape((result.shape[0], f.entries))
if self.replace_occluded is not None and f.idx >= min_occluded_index and \
(type(f) is not IsOccluded and type(f) is not IsOccludedSince and type(f) is not IsOccludedSinceZeroOffset):
occ_mask = frames[:, f.idx, 9] > 0.00001
occluded_frames = result[occ_mask, idx:idx + f.entries]
if isinstance(self.replace_occluded, float):
occluded_frames = self.replace_occluded
elif callable(self.replace_occluded):
occluded_frames = self.replace_occluded(occluded_frames)
elif self.replace_occluded == "last_known" or self.replace_occluded == "repeat":
if len(occluded_frames) > 0:
non_nan = np.where(~occ_mask, np.arange(occ_mask.shape[0]), 0)
np.maximum.accumulate(non_nan, axis=0, out=non_nan)
tmp = result[non_nan, idx:idx + f.entries]
occluded_frames = tmp[occ_mask]
elif self.replace_occluded == "keep":
pass
elif self.replace_occluded == "random":
occluded_frames = np.random.random(occluded_frames.shape)
else:
raise AttributeError("invalid replacement")
result[occ_mask, idx:idx + f.entries] = occluded_frames
idx += f.entries
return result