MCPcopy Index your code
hub / github.com/MotrixLab/ViMoGen / __init__

Method __init__

datasets/bucket.py:31–79  ·  view source on GitHub ↗
(self, bucket_config)

Source from the content-addressed store, hash-verified

29class Bucket:
30
31 def __init__(self, bucket_config):
32 for key in bucket_config:
33 assert key in ASPECT_RATIOS, f'Aspect ratio {key} not found.'
34 # wrap config with OrderedDict
35 bucket_probs = OrderedDict()
36 bucket_bs = OrderedDict()
37 bucket_names = sorted(
38 bucket_config.keys(),
39 key=lambda x: ASPECT_RATIOS[x][0],
40 reverse=True)
41 for key in bucket_names:
42 bucket_time_names = sorted(
43 bucket_config[key].keys(), key=lambda x: x, reverse=True)
44 bucket_probs[key] = OrderedDict(
45 {k: bucket_config[key][k][0]
46 for k in bucket_time_names})
47 bucket_bs[key] = OrderedDict(
48 {k: bucket_config[key][k][1]
49 for k in bucket_time_names})
50
51 # first level: HW
52 num_bucket = 0
53 hw_criteria = dict()
54 t_criteria = dict()
55 ar_criteria = dict()
56 bucket_id = OrderedDict()
57 bucket_id_cnt = 0
58 for k1, v1 in bucket_probs.items():
59 hw_criteria[k1] = ASPECT_RATIOS[k1][0]
60 t_criteria[k1] = dict()
61 ar_criteria[k1] = dict()
62 bucket_id[k1] = dict()
63 for k2, _ in v1.items():
64 t_criteria[k1][k2] = k2
65 bucket_id[k1][k2] = bucket_id_cnt
66 bucket_id_cnt += 1
67 ar_criteria[k1][k2] = dict()
68 for k3, v3 in ASPECT_RATIOS[k1][1].items():
69 ar_criteria[k1][k2][k3] = v3
70 num_bucket += 1
71
72 self.bucket_probs = bucket_probs
73 self.bucket_bs = bucket_bs
74 self.bucket_id = bucket_id
75 self.hw_criteria = hw_criteria
76 self.t_criteria = t_criteria
77 self.ar_criteria = ar_criteria
78 self.num_bucket = num_bucket
79 get_logger().info('Number of buckets: %s', num_bucket)
80
81 def get_bucket_id(self, T, H, W, frame_interval=1, seed=None):
82 resolution = H * W

Callers

nothing calls this directly

Calls 1

get_loggerFunction · 0.90

Tested by

no test coverage detected