Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some changes to make the code work #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion image_generation/restore_img2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def main(index, idx):
obj_mask = {}
for _i in range(index):
path = './tmp_graph_output/indexob{}_{}/Image0001.png'.format(_i,idx)
print 'read path...', path
print('read path...', path)
img = cv2.imread(path)[:,:,0].flatten().tolist()
img = [int(_x==255) for _x in img]
def to_str(img):
Expand Down
3 changes: 2 additions & 1 deletion image_generation/restore_render_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@ def add_random_objects(scene_struct, args, camera, idx):
utils.add_material(mat_name, Color=rgba)

# Record data about the object in the scene data structure
pixel_coords, _wh = utils.get_camera_coords(camera, obj.location)
#print(utils.get_camera_coords(camera, obj.location))
pixel_coords = utils.get_camera_coords(camera, obj.location)
objects.append({
'shape': obj_name_out,
'size': size_name,
Expand Down
22 changes: 16 additions & 6 deletions refexp_generation/generate_refexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ def sample_equal_prob_for_diff_num_after_easyfilter(filter_option_keys):
num_to_option[cnt].append(it_k)

# choose one num randomly
rd_num = random.choice(num_to_option.keys())

rd_num = random.choice(list(num_to_option.keys()))
# return one option_key
choice = random.choice(num_to_option[rd_num])
return choice
Expand Down Expand Up @@ -497,13 +498,22 @@ def sample_equal_prob_for_diff_num_after_easyfilter(filter_option_keys):
cur_next_vals[param_name] = param_val
next_input = len(state['nodes']) + len(new_nodes) - 1

#
#print(param_name_val_pair)
filter_side_inputs = list(filter_side_inputs[:4]) + \
list([[filter_side_inputs[4], filter_side_inputs[5]]]) + list(filter_side_inputs[6:])

k = list(k[:4]) + list([[k[4], k[5]]]) + list(k[6:])

param_name_val_pair = zip(filter_side_inputs, k)

param_name_val_pair = param_name_val_pair[:4] + \
[[[param_name_val_pair[4][0],param_name_val_pair[5][0]],
[param_name_val_pair[4][1],param_name_val_pair[5][1]]]
] + \
param_name_val_pair[6:]
# param_name_val_pair = param_name_val_pair[:4] + \
# [[[param_name_val_pair[4][0], param_name_val_pair[5][0]],
# [param_name_val_pair[4][1], param_name_val_pair[5][1]]]
# ] + \
# param_name_val_pair[6:]



for param_name, param_val in param_name_val_pair:
if type(param_name) == list and len(param_name) == 2: #ordinal function which has 2 side_input
Expand Down
6 changes: 3 additions & 3 deletions refexp_generation/refexp_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def greater_than_handler(scene_struct, inputs, side_inputs):
return inputs[0] > inputs[1]


def filter_ordinal_function(scene_struct, obj_idxs, (o_num, o_dir)):
def filter_ordinal_function(scene_struct, obj_idxs, o_num, o_dir):
o_num_in_meta = ["the first one of the","the second one of the","the third one of the","the fourth one of the",
"the fifth one of the","the sixth one of the","the seventh one of the","the eighth one of the",
"the nineth one of the"]
Expand Down Expand Up @@ -182,7 +182,7 @@ def filter_ordinal(scene_struct, inputs, side_inputs):
obj_idxs = inputs[0]
o_num = side_inputs[0]
o_dir = side_inputs[1]
return filter_ordinal_function(scene_struct, obj_idxs, (o_num, o_dir))
return filter_ordinal_function(scene_struct, obj_idxs, o_num, o_dir)


def get_visible_occlusion_sets(scene_struct, thre1, thre2):
Expand Down Expand Up @@ -358,7 +358,7 @@ def answer_refexp(refexp, metadata, scene_struct, all_outputs=False,
else:
node_type = node['type']
msg = 'Could not find handler for "%s"' % node_type
assert node_type in execute_handlers, msg
#assert node_type in execute_handlers, msg
handler = execute_handlers[node_type]
node_inputs = [node_outputs[idx] for idx in node['inputs']]
side_inputs = node.get('side_inputs', [])
Expand Down