File size: 887 Bytes
e2ce257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import math
import json


with open('bucket_categorization.json', 'r') as fp:
    bucket_data = json.load(fp)


print(len(bucket_data))
base_batch_size = 16
base_context_length = 1024 * 1024

all_data = 0
sampler_meta = []
for bucket, indices in bucket_data.items():
    resolution = bucket.split('x')
    height, width = int(resolution[0]), int(resolution[1])  
    batch_size = round(base_batch_size*base_context_length/(height*width))
    batch_size = min(batch_size, 128)
    num_batch = round(len(indices) / batch_size)
    for i in range(num_batch):
        current_indices = indices[i*batch_size: (i+1)*batch_size]
        if len(current_indices) == batch_size:
            all_data += batch_size
            sampler_meta.append(current_indices)
    
print(all_data)
print(len(sampler_meta))
with open('bucket_sampler.json', 'w') as fp:
    json.dump(sampler_meta, fp, indent=4)