MCPcopy Create free account
hub / github.com/Netflix/void-model / get_random_downsample_ratio

Function get_random_downsample_ratio

scripts/cogvideox_fun/train.py:87–117  ·  view source on GitHub ↗
(sample_size, image_ratio=[],
                                all_choices=False, rng=None)

Source from the content-addressed store, hash-verified

85
86
87def get_random_downsample_ratio(sample_size, image_ratio=[],
88 all_choices=False, rng=None):
89 def _create_special_list(length):
90 if length == 1:
91 return [1.0]
92 if length >= 2:
93 first_element = 0.75
94 remaining_sum = 1.0 - first_element
95 other_elements_value = remaining_sum / (length - 1)
96 special_list = [first_element] + [other_elements_value] * (length - 1)
97 return special_list
98
99 if sample_size >= 1536:
100 number_list = [1, 1.25, 1.5, 2, 2.5, 3] + image_ratio
101 elif sample_size >= 1024:
102 number_list = [1, 1.25, 1.5, 2] + image_ratio
103 elif sample_size >= 768:
104 number_list = [1, 1.25, 1.5] + image_ratio
105 elif sample_size >= 512:
106 number_list = [1] + image_ratio
107 else:
108 number_list = [1]
109
110 if all_choices:
111 return number_list
112
113 number_list_prob = np.array(_create_special_list(len(number_list)))
114 if rng is None:
115 return np.random.choice(number_list, p = number_list_prob)
116 else:
117 return rng.choice(number_list, p = number_list_prob)
118
119def resize_mask(mask, latent, process_first_frame_only=True):
120 latent_size = latent.size()

Callers 1

collate_fnFunction · 0.70

Calls 1

_create_special_listFunction · 0.70

Tested by

no test coverage detected