modelzoo.vision.pytorch.dit.samplers.sampler_utils.threshold_sample#

modelzoo.vision.pytorch.dit.samplers.sampler_utils.threshold_sample(sample: torch.FloatTensor, dynamic_thresholding_ratio, sample_max_value) torch.FloatTensor[source]#

“Dynamic thresholding: At each sampling step we set s to a certain percentile absolute pixel value in xt0 (the prediction of x_0 at timestep t), and if s > 1, then we threshold xt0 to the range [-s, s] and then divide by s. Dynamic thresholding pushes saturated pixels (those near -1 and 1) inwards, thereby actively preventing pixels from saturation at each step. We find that dynamic thresholding results in significantly better photorealism as well as better image-text alignment, especially when using very large guidance weights.”

https://arxiv.org/abs/2205.11487