def convert_file(net, filename, output, cfg): assert os.path.isfile( filename), 'Please provide a path to an existing image!' pyramid = True if len(cfg.TEST.SCALES) > 1 else False cls_dets, _ = detect(net, filename, visualization_folder=output, visualize=True, pyramid=pyramid)
if args.cfg is not None: cfg_from_file(args.cfg) # Print config file cfg_print(cfg) # Loading the network cfg.GPU_ID = args.gpu_id caffe.set_mode_gpu() caffe.set_device(args.gpu_id) assert os.path.isfile( args.prototxt), 'Please provide a valid path for the prototxt!' assert os.path.isfile( args.model), 'Please provide a valid path for the caffemodel!' print('Loading the network...', end="") net = caffe.Net(args.prototxt, args.model, caffe.TEST) net.name = 'SSH' print('Done!') # Read image assert os.path.isfile( args.im_path), 'Please provide a path to an existing image!' pyramid = True if len(cfg.TEST.SCALES) > 1 else False # Perform detection cls_dets, _ = detect(net, args.im_path, visualization_folder=args.out_path, visualize=True, pyramid=pyramid)
# Load the external config if args.cfg is not None: cfg_from_file(args.cfg) # Print config file cfg_print(cfg) # Loading the network cfg.GPU_ID = args.gpu_id caffe.set_mode_gpu() caffe.set_device(args.gpu_id) assert os.path.isfile(args.prototxt),'Please provide a valid path for the prototxt!' assert os.path.isfile(args.model),'Please provide a valid path for the caffemodel!' print('Loading the network...', end="") net = caffe.Net(args.prototxt, args.model, caffe.TEST) net.name = 'SSH' print('Done!') # Read image assert os.path.isfile(args.im_path),'Please provide a path to an existing image!' pyramid = True if len(cfg.TEST.SCALES)>1 else False # Perform detection cls_dets,_ = detect(net,args.im_path,visualization_folder=args.out_path,visualize=True,pyramid=pyramid)
assert os.path.exists( args.trudir), 'Please provide a valid path for ground truth dir' alltrueface = 0 alldetectface = 0 alldetectfaceright = 0 start = time.time() #processing start for imgfile in os.listdir(args.imdir): # Face cut list images = [] groundtruth = [] im = cv2.imread(os.path.join(args.imdir, imgfile)) print('Detecting File {0}'.format(imgfile)) cls_dets, _ = detect(net, im, visualization_folder=args.out_path, visualize=False, pyramid=pyramid) xmlfile = os.path.join(args.trudir, (imgfile.split('.')[0] + '.xml')) tree = ET.parse(xmlfile) root = tree.getroot() for obj in root.findall('object'): objname = obj.find('name').text bbox = obj.find('bndbox') xmin = int(bbox.find('xmin').text) xmax = int(bbox.find('xmax').text) ymin = int(bbox.find('ymin').text) ymax = int(bbox.find('ymax').text) groundtruth.append((objname, [xmin, xmax, ymin, ymax])) ''' #visulize detection results