hist_maker = SP_histogram(splits, None, scale_levels, nwords) fp.close() for filename, im_data in data.iteritems(): im_data['histogram'] = hist_maker.create_histogram( im_data['locs'], im_data['membership'], amax(im_data['locs'], 0) + 1) print filename return data, hist_maker if __name__ == "__main__": np.set_printoptions(precision=3, edgeitems=None) opts = ioutil.load_command_line( sys.argv[1:], keys=['input_data', 'nwords', 'image_dir', 'output_dir'], flag_keys=['make_hists', 'do_search', 'both']) if opts.has_key('make_hists'): data, hist_maker = create_histograms(opts['input_data'], int(opts['nwords'])) fp = open(opts['output_data'], 'w') pickle.dump(data, fp) fp.close() elif opts.has_key('do_search'): fp = open(opts['input'], 'r') data = pickle.load(fp) hist_maker = SP_histogram(array((2, 2)), None, 1, int(opts['nwords'])) result, filenames = search(data, hist_maker) filenames = [ope(filename)[0] + ".png" for filename in filenames] # pdb.set_trace() if not os.path.exists(opts['output_dir']):
os.remove(out_files[i].name) def blad(a, b): print b for v in a: c = open(v, 'r').readlines() print c if __name__ == "__main__": print sys.argv if sys.argv[1] == "--detector": import ioutil opts = ioutil.load_command_line( sys.argv[1:], keys=['csv_filename', 'detector', 'config']) command = ['python', opts['detector'], '--config', opts['config']] tmp_filenames = [] scene_list = ioutil.ext_filter(opts['scene_path'], ['.xml']) for ovlp in [0.5]: for alg_type in ['UNION', 'INTERSECTION']: com = copy.copy(command) com.extend([ '--nms_alg', alg_type, '--overlap', str(ovlp), '--alg_name', alg_type[0:5] + str(ovlp) ]) fp = tempfile.NamedTemporaryFile(mode='w', delete=False) tmp_filenames.append(fp.name) fp.close() merge_func = lambda filenames: ioutil.merge_csv_files(
os.remove(in_files[i].name) os.remove(out_files[i].name) def blad(a,b): print b for v in a: c = open(v,'r').readlines() print c if __name__=="__main__": print sys.argv if sys.argv[1] == "--detector": import ioutil opts = ioutil.load_command_line(sys.argv[1:], keys = ['csv_filename', 'detector', 'config']) command = ['python', opts['detector'], '--config', opts['config']] tmp_filenames = [] scene_list = ioutil.ext_filter(opts['scene_path'],['.xml']) for ovlp in [0.5]: for alg_type in ['UNION', 'INTERSECTION']: com = copy.copy(command) com.extend(['--nms_alg',alg_type,'--overlap',str(ovlp), '--alg_name', alg_type[0:5]+str(ovlp)]) fp = tempfile.NamedTemporaryFile(mode='w', delete = False) tmp_filenames.append(fp.name) fp.close() merge_func = lambda filenames: ioutil.merge_csv_files(filenames, tmp_filenames[-1]) multi_process(com,'--scene_list', '--csv_filename', scene_list,