-
Notifications
You must be signed in to change notification settings - Fork 54
/
combine_layouts.py
32 lines (24 loc) · 1.14 KB
/
combine_layouts.py
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 os
import json
import argparse
from tqdm import tqdm
def combine_layouts(seperate_layouts_dir):
"""
Combining seperate layouts into one json.
Args:
seperate_layouts_dir (str): Directory to save seperate layouts json files generated by bestfit_generator.py
"""
combined_layouts = []
for item in tqdm(os.listdir(seperate_layouts_dir),desc='Combining seperate layouts'):
abs_path = os.path.join(seperate_layouts_dir,item)
json_file = json.load(open(abs_path))
combined_layouts.append(json_file)
return combined_layouts
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--seperate_layouts_dir', default="./generated_layouts/seperate", type=str, help="directory to save seperate layouts")
parser.add_argument('--save_path', default="./generated_layouts/combined_layouts.json", type=str, help='save path for combined generated layouts')
args = parser.parse_args()
combined_layouts = combine_layouts(seperate_layouts_dir=args.seperate_layouts_dir)
with open(args.save_path,'w') as f:
f.write(json.dumps(combined_layouts,indent=4))