-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFormat_matching_butd.py
More file actions
27 lines (23 loc) · 898 Bytes
/
Format_matching_butd.py
File metadata and controls
27 lines (23 loc) · 898 Bytes
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
import numpy as np
import json
import pickle as pkl
from tqdm import tqdm
import nltk
from nltk.corpus import wordnet
import cv2
import os
from itertools import chain
from tqdm import tqdm
dicts_butd = pkl.load(open('butd_idx_label_pruned.pkl', 'rb'))
for i, img_idx in enumerate(tqdm(dicts_butd)):
rel_list = []
for i in range(len(dicts_butd[img_idx]['pred_attri'])):
rel_list.append([i,i])
dicts_butd[img_idx]['pred_rel_inds'] = rel_list
dicts_butd[img_idx]['rel_inds'] = dicts_butd[img_idx]['pred_attri']
del dicts_butd[img_idx]['pred_attri']
for i in range(len(dicts_butd[img_idx]['pred_boxes'])):
for j in range(len(dicts_butd[img_idx]['pred_boxes'][i])):
dicts_butd[img_idx]['pred_boxes'][i][j] = float(dicts_butd[img_idx]['pred_boxes'][i][j])
pickle_out = open("butd_idx_label_pruned_addrel.pkl","wb")
pkl.dump(dicts_butd, pickle_out)