for bdbox in bdboxes: font = cv2.FONT_HERSHEY_SIMPLEX output_image = cv2.rectangle( output_image, (int(bdbox[0] - bdbox[2] / 2), int(bdbox[1] - bdbox[3] / 2)), (int(bdbox[0] + bdbox[2] / 2), int(bdbox[1] + bdbox[3] / 2)), (200, 0, 0), 1) output_image = cv2.putText( output_image, bdbox[4], (int(bdbox[0] - bdbox[2] / 2), int(bdbox[1] - bdbox[3] / 2)), cv2.FONT_HERSHEY_SIMPLEX, 0.3, (0, 255, 0), 1) # output_image = np.multiply( output_image, 255 ) generate_image = FLAGS.save_dir + '/res.jpg' if not os.path.exists(FLAGS.save_dir): os.makedirs(FLAGS.save_dir) cv2.imwrite(generate_image, cv2.cvtColor(output_image, cv2.COLOR_RGB2BGR)) end_time = time.time() print('Use time: ', end_time - start_time) plt.imshow(output_image) plt.show() if __name__ == '__main__': tf.reset_default_graph() args = parse_args() FLAGS = read_config.read_config_file(args.conf) main(FLAGS)
from run_ova import compute_similarity_ova from run_wem import compute_similarity_wem from run_basic import compute_similarity_basic if __name__ == "__main__": start_time, start_resources = time.time(), resource.getrusage(resource.RUSAGE_SELF) signal.signal(signal.SIGINT, signal_handler) ####################################################################### PARAMETERS # Read configuration file for default options + set cmd line options main_dir = os.path.dirname(os.path.realpath(__file__)) custom, cfg, verbose, debug = parse_cmd_line() config_file = cfg if (cfg is not None) else os.path.join(main_dir, 'configuration.ini') n_iter, n_cores, n_locks, data_type, input_file, ground_truth_file, temp_folder, output_folder, annotation_params, classification_params, classifier_binary, task_params, cvg_step, cvg_criterion, cfg = read_config_file(config_file, *custom) # Set temporary and output folders base_name = time.strftime("%Y-%m-%d_%H-%M") output_folder = init_folder(os.path.join(output_folder, 'Outputs_%s'%base_name)) temp_folder = init_folder(temp_folder) # Save configuration for the experiment in the output folder with open(os.path.join(output_folder, 'exp_configuration.ini'), 'w') as f: cfg.write(f) # Read and parse data file n_samples, data, data_occurrences, index_to_label, label_to_index = parse_data(data_type, classification_params, input_file) os.environ['CLASSIFIER'] = classifier_binary # Additional parameters