def __init__(self, track_groundtruth_file): frameids, infos = util.read_imagelist(track_groundtruth_file) frameids = map(int, frameids) self.objectset = {} self.id_objects_map = {} for i in xrange(len(frameids)): groundbox = GroundBox(frameids[i], infos[i]) if frameids[i] not in self.objectset: self.objectset[frameids[i]] = [] self.objectset[frameids[i]].append(groundbox) if groundbox.trackid not in self.id_objects_map: self.id_objects_map[groundbox.trackid] = [] self.id_objects_map[groundbox.trackid].append(groundbox)
def process(args): images, labels = util.read_imagelist(args.image_list) net = caffeutil.get_net_test(args.prototxt, args.model, gpu=args.gpu) scores = caffeutil.batch_process_images(net, images, output_layers=args.result_layer, resize=args.size, batch_size=args.batch_size, mean=args.mean, scale=args.scale, return_format='origin') # Write the result in bag. if not os.path.exists(args.output_dir): os.makedirs(args.output_dir) print 'result:',args.output_dir scoreoutfile = open(args.scorefile + '.npz', 'wb') pickle.dump(images, scoreoutfile, True) pickle.dump(scores, scoreoutfile, True) pickle.dump(labels, scoreoutfile, True) scoreoutfile.close()
def read_label_name(filename): labelfile = filename labels = [] sm_num = [] if filename is None: for i in range(200): labels.append('label' + str(i)) sm_num.append(2) else: labels, o_sm_num = util.read_imagelist(filename) o_sm_num = util.format_labels_todigits(o_sm_num) for sn in o_sm_num: if len(sn) == 0: sm_num.append(2) else: sm_num.append(sn[0]) return labels, sm_num
import argparse parser = argparse.ArgumentParser() parser.add_argument('dataset_id') parser.add_argument('--origin', action='store_true') args = parser.parse_args() dataset_num = args.dataset_id print 'dataset_num: ', dataset_num if args.origin: track_file = 'origin_track_n' + dataset_num + '.log' else: track_file = 'track_n' + dataset_num + '.txt' tracksystem = GroundBoxSystem(track_file) ground_file = '12groundtruth/n' + dataset_num + '.txt' groundsystem = GroundBoxSystem(ground_file) pictures, _ = util.read_imagelist('images_all/n' + dataset_num + '.list') trackframes = tracksystem.objectset.keys() trackframes = sorted(trackframes) trackids = tracksystem.id_objects_map.keys() # In[38]: mcount, scount = 0, 0 keepd_ground_box = set() location_count = 0 location_set = [] track_data = [] track_data_index = AutoListMap() track_data_location_index = {}