test_roidb = roidb_read['test_roidb'] N_train = len(train_roidb) N_test = len(test_roidb) saver = tf.train.Saver() with tf.Session() as sess: init = tf.global_variables_initializer() sess.run(init) saver.restore(sess, model_path) pred_roidb = [] for roidb_id in range(N_test): if (roidb_id + 1) % 10 == 0: print(roidb_id + 1) roidb_use = test_roidb[roidb_id] if len(roidb_use['rela_gt']) == 0: pred_roidb.append({}) continue pred_rela, pred_rela_score = vnet.test_predicate(sess, roidb_use) pred_roidb_temp = { 'pred_rela': pred_rela, 'pred_rela_score': pred_rela_score, 'sub_box_dete': roidb_use['sub_box_gt'], 'obj_box_dete': roidb_use['obj_box_gt'], 'sub_dete': roidb_use['sub_gt'], 'obj_dete': roidb_use['obj_gt'] } pred_roidb.append(pred_roidb_temp) roidb = {} roidb['pred_roidb'] = pred_roidb np.savez(save_path, roidb=roidb)
saver = tf.train.Saver() with tf.Session() as sess: init = tf.global_variables_initializer() sess.run(init) saver.restore(sess, model_path) pred_roidb = [] sub_roidb = [] obj_roidb = [] for roidb_id in range(N_test): if (roidb_id+1)%10 == 0: print(roidb_id + 1) roidb_use = test_roidb[roidb_id] if len(roidb_use['rela_gt']) == 0: pred_roidb.append({}) continue pred_rela, pred_rela_score, pred_sub , pred_obj = vnet.test_predicate(sess, roidb_use) pred_roidb_temp = {'pred_rela': pred_rela, 'pred_rela_score': pred_rela_score, 'sub_box_dete': roidb_use['sub_box_gt'], 'obj_box_dete': roidb_use['obj_box_gt'], 'sub_dete': roidb_use['sub_gt'], 'obj_dete': roidb_use['obj_gt'] , 'original_pred': roidb_use['rela_gt']} pred_roidb.append(pred_roidb_temp) sub_roidb.append(pred_sub) obj_roidb.append(pred_obj) roidb = {} roidb['pred_roidb'] = pred_roidb roidb['subVec'] = sub_roidb roidb['objVec'] = obj_roidb np.savez(save_path, roidb=roidb)