Exemple #1
0
        for cls_ind, cls in enumerate(self.classes):
            if cls == '__background__':
                continue
            print 'Writing {} results file'.format(cls)
            filename = os.path.join(path, self._image_set + '_' + cls + comp_id + '.txt')
            with open(filename, 'wt') as f:
                for im_ind, index in enumerate(self.image_index):
                    dets = all_boxes[cls_ind][im_ind]
                    if dets == []:
                        f.write('{:s} {:.3f} {:.1f} {:.1f} {:.1f} {:.1f}\n'.format(index, 0, 0, 0, 0, 0))
                        continue 
                    for k in xrange(dets.shape[0]):
                        f.write('{:s} {:.3f} {:.1f} {:.1f} {:.1f} {:.1f}\n'.
                                format(index, dets[k, -1],
                                       dets[k, 0], dets[k, 1],
                                       dets[k, 2], dets[k, 3]))
        return comp_id


    def evaluate_detections(self, all_boxes, output_dir):
        comp_id = self._write_results_file(all_boxes)

if __name__ == '__main__':
    #d = datasets.eshops('all')
    d = datasets.eshops('alza_test')
    #d._load_annotation('xaa-433')
    #print d.image_path_from_index('xaa-433')
    res = d.roidb
    print res
    #from IPython import embed; embed()
if __name__ == "__main__":
    args = parse_args()

    print("Called with args:")
    print(args)

    if args.cfg_file is not None:
        cfg_from_file(args.cfg_file)
    if args.set_cfgs is not None:
        cfg_from_list(args.set_cfgs)

    print("Using config:")
    pprint.pprint(cfg)

    while not os.path.exists(args.caffemodel) and args.wait:
        print("Waiting for {} to exist...".format(args.caffemodel))
        time.sleep(10)

    caffe.set_mode_gpu()
    caffe.set_device(args.gpu_id)
    net = caffe.Net(args.prototxt, args.caffemodel, caffe.TEST)
    net.name = os.path.splitext(os.path.basename(args.caffemodel))[0]

    imdb = datasets.eshops(args.imdb_name)
    # imdb = get_imdb(args.imdb_name)
    # imdb = datasets.eshops('alza_test')
    # imdb = datasets.eshops('czc100')
    imdb.competition_mode(args.comp_mode)

    test_net(net, imdb)
Exemple #3
0
def calculate_iou(box1, box2):
    axmin, aymin, axmax, aymax = box1
    bxmin, bymin, bxmax, bymax = box2
    dx = int(min(axmax, bxmax)) - int(max(axmin, bxmin))
    dy = int(min(aymax, bymax)) - int(max(aymin, bymin))
    S12 = max(dx*dy, 0)
    S1 = area(box1)
    S2 = area(box2)
    iou = (S12*1.0)/(S1+S2-S12)
    return iou

imdb = sys.argv[1]
run = sys.argv[2]

d = datasets.eshops(imdb)

gt = [ x['boxes'].tolist() for x in d.gt_roidb()]

#gt = {}
#for index in d._image_index:
    #gt[index] = d._load_annotation(index)['boxes']

n = len(gt)

classes = ('name', 'price', 'main_image')

IOU_THRESHOLD = 0.5

correct = {}
img_cnt = {}