當前位置: 首頁>>代碼示例>>Python>>正文


Python facenet.store_revision_info方法代碼示例

本文整理匯總了Python中facenet.store_revision_info方法的典型用法代碼示例。如果您正苦於以下問題:Python facenet.store_revision_info方法的具體用法?Python facenet.store_revision_info怎麽用?Python facenet.store_revision_info使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在facenet的用法示例。


在下文中一共展示了facenet.store_revision_info方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: import facenet [as 別名]
# 或者: from facenet import store_revision_info [as 別名]
def main(args):
    output_dir = os.path.expanduser(args.output_dir)
  
    if not os.path.exists(output_dir):
        os.mkdir(output_dir)
  
    # Store some git revision info in a text file in the output directory
    src_path,_ = os.path.split(os.path.realpath(__file__))
    facenet.store_revision_info(src_path, output_dir, ' '.join(sys.argv))
    
    i = 0
    for f in args.tsv_files:
        for line in f:
            fields = line.split('\t')
            class_dir = fields[0]
            img_name = fields[1] + '-' + fields[4] + '.' + args.output_format
            img_string = fields[5]
            img_dec_string = base64.b64decode(img_string)
            img_data = np.fromstring(img_dec_string, dtype=np.uint8)
            img = cv2.imdecode(img_data, cv2.IMREAD_COLOR) #pylint: disable=maybe-no-member
            if args.size:
                img = misc.imresize(img, (args.size, args.size), interp='bilinear')
            full_class_dir = os.path.join(output_dir, class_dir)
            if not os.path.exists(full_class_dir):
                os.mkdir(full_class_dir)
            full_path = os.path.join(full_class_dir, img_name.replace('/','_'))
            cv2.imwrite(full_path, img) #pylint: disable=maybe-no-member
            print('%8d: %s' % (i, full_path))
            i += 1 
開發者ID:GaoangW,項目名稱:TNT,代碼行數:31,代碼來源:decode_msceleb_dataset.py

示例2: main

# 需要導入模塊: import facenet [as 別名]
# 或者: from facenet import store_revision_info [as 別名]
def main(args):
    output_dir = os.path.expanduser(args.output_dir)
  
    if not os.path.exists(output_dir):
        os.mkdir(output_dir)
  
    # Store some git revision info in a text file in the output directory
    src_path,_ = os.path.split(os.path.realpath(__file__))
    facenet.store_revision_info(src_path, output_dir, ' '.join(sys.argv))
    
    i = 0
    for f in args.tsv_files:
        for line in f:
            fields = line.split('\t')
            class_dir = fields[0]
            img_name = fields[1] + '-' + fields[4] + '.' + args.output_format
            img_string = fields[6]
            img_dec_string = base64.b64decode(img_string)
            img_data = np.fromstring(img_dec_string, dtype=np.uint8)
            img = cv2.imdecode(img_data, cv2.IMREAD_COLOR) #pylint: disable=maybe-no-member
            if args.size:
                img = misc.imresize(img, (args.size, args.size), interp='bilinear')

            full_class_dir = os.path.join(output_dir, class_dir)
            if not os.path.exists(full_class_dir):
                os.mkdir(full_class_dir)
            full_path = os.path.join(full_class_dir, img_name.replace('/','_'))
            cv2.imwrite(full_path, img) #pylint: disable=maybe-no-member
            print('%8d: %s' % (i, full_path))
            i += 1 
開發者ID:ucloud,項目名稱:uai-sdk,代碼行數:32,代碼來源:decode_msceleb_dataset.py

示例3: main

# 需要導入模塊: import facenet [as 別名]
# 或者: from facenet import store_revision_info [as 別名]
def main(args):
    funnel_cmd = 'funnelReal'
    funnel_model = 'people.train'

    output_dir = os.path.expanduser(args.output_dir)
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
    # Store some git revision info in a text file in the output directory
    src_path,_ = os.path.split(os.path.realpath(__file__))
    facenet.store_revision_info(src_path, output_dir, ' '.join(sys.argv))
    dataset = facenet.get_dataset(args.input_dir)
    np.random.shuffle(dataset)
    # Scale the image such that the face fills the frame when cropped to crop_size
    #scale = float(args.face_size) / args.image_size
    with TemporaryDirectory() as tmp_dir:
        for cls in dataset:
            output_class_dir = os.path.join(output_dir, cls.name)
            tmp_output_class_dir = os.path.join(tmp_dir, cls.name)
            if not os.path.exists(output_class_dir) and not os.path.exists(tmp_output_class_dir):
                print('Aligning class %s:' % cls.name)
                tmp_filenames = []
                if not os.path.exists(tmp_output_class_dir):
                    os.makedirs(tmp_output_class_dir)
                input_list_filename = os.path.join(tmp_dir, 'input_list.txt')
                output_list_filename = os.path.join(tmp_dir, 'output_list.txt')
                input_file = open(input_list_filename, 'w')
                output_file = open(output_list_filename,'w')
                for image_path in cls.image_paths:
                    filename = os.path.split(image_path)[1]
                    input_file.write(image_path+'\n')
                    output_filename = os.path.join(tmp_output_class_dir, filename)
                    output_file.write(output_filename+'\n')
                    tmp_filenames.append(output_filename)
                input_file.close()
                output_file.close()
                cmd = args.funnel_dir+funnel_cmd + ' ' + input_list_filename + ' ' + args.funnel_dir+funnel_model + ' ' + output_list_filename
                subprocess.call(cmd, shell=True)
                
                # Resize and crop images
                if not os.path.exists(output_class_dir):
                    os.makedirs(output_class_dir)
                scale = 1.0
                for tmp_filename in tmp_filenames:
                    img = misc.imread(tmp_filename)
                    img_scale = misc.imresize(img, scale)
                    sz1 = img.shape[1]/2
                    sz2 = args.image_size/2
                    img_crop = img_scale[int(sz1-sz2):int(sz1+sz2),int(sz1-sz2):int(sz1+sz2),:]
                    filename = os.path.splitext(os.path.split(tmp_filename)[1])[0]
                    output_filename = os.path.join(output_class_dir, filename+'.png')
                    print('Saving image %s' % output_filename)
                    misc.imsave(output_filename, img_crop)
                    
                # Remove tmp directory with images
                shutil.rmtree(tmp_output_class_dir) 
開發者ID:1024210879,項目名稱:facenet-demo,代碼行數:57,代碼來源:funnel_dataset.py


注:本文中的facenet.store_revision_info方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。