• 大小: 26KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-15
  • 语言: Python
  • 标签: python  机器学习  

资源简介

博客中的人脸聚类源码,安装完相应python库后可运行,请新建dataset用于存放原始图片 encode_file用于存放人脸特征文件

资源截图

代码片段和文件信息

from sklearn.cluster import DBSCAN
from imutils import build_montages
import numpy as np
import argparse
import pickle
import cv2
from sklearn.metrics import silhouette_score calinski_harabasz_score davies_bouldin_score  # 计算 轮廓系数,CH 指标,DBI
from sklearn.datasets import load_breast_cancer
from sklearn.decomposition import PCA
import matplotlib.pyplot as plt
from sklearn.manifold import TSNE
from mpl_toolkits.mplot3d import Axes3D

class oreration_encodefile():
    def __init__(self):
        pass
    def do_add_imgages_in_encodefile(selfsource_imagefile_path):
        ‘‘‘保留‘‘‘
        pass
    def do_add_encodefile_in_encodefile(selfsource_encodefile_pathobj_encodefile_path):
        all_encodings = []
        all_imagepath = []
        for eachfile in source_encodefile_path:
            data = pickle.loads(open(eachfile “rb“).read())
            data = np.array(data)
            encodings = [d[“encoding“] for d in data]
            imagespath = [d[‘imagePath‘] for d in data]
            all_encodings.extend(encodings)
            all_imagepath.extend(imagespath)

        d = [{“imagePath“: imgpath  “encoding“: enc}
             for imgpathenc in zip(all_imagepathall_encodings)]

        with open(obj_encodefile_path ‘wb‘) as fp:
            fp.write(pickle.dumps(d))

        # data_all = pickle.loads(open(source_encodefile_path “rb“).read())
        # data_temp = pickle.loads(open(obj_encodefile_path “rb“).read())
        # data_all = np.array(data_all)
        # data_temp = np.array(data_temp)
        # encodings = [d[“encoding“] for d in data_all]
        # imagespath = [d[‘imagePath‘] for d in data_all]
        # encoding_temp = [d[“encoding“] for d in data_temp]
        # imagespath_temp = [d[‘imagePath‘] for d in data_temp]
        # encodings.extend(encoding_temp)
        # imagespath.extend(imagespath_temp)
        pass


if __name__ == ‘__main__‘:
    inputfile_path_source = [‘./encode_file/addtest1_hog[2020_02_28-11_31_59].pickle‘‘./encode_file/addtest1_hog[2020_02_28-11_33_58].pickle‘]
    inputfile_path_obj = ‘./encode_file/me.pickle‘
    O = oreration_encodefile()
    O.do_add_encodefile_in_encodefile(inputfile_path_sourceinputfile_path_obj)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2020-03-16 17:37  FaceClustering\
     目录           0  2020-03-05 09:55  FaceClustering\.idea\
     文件         586  2020-03-05 09:54  FaceClustering\.idea\face-clustering.iml
     目录           0  2020-03-02 11:03  FaceClustering\.idea\inspectionProfiles\
     文件         174  2020-02-23 17:42  FaceClustering\.idea\inspectionProfiles\profiles_settings.xml
     文件         206  2020-03-02 16:18  FaceClustering\.idea\misc.xml
     文件         289  2020-02-23 17:42  FaceClustering\.idea\modules.xml
     文件        5988  2020-03-05 09:55  FaceClustering\.idea\workspace.xml
     目录           0  2020-03-05 12:51  FaceClustering\__pycache__\
     文件        7538  2020-03-05 12:51  FaceClustering\__pycache__\class_cluster.cpython-36.pyc
     文件        2612  2020-03-05 12:51  FaceClustering\__pycache__\class_encode.cpython-36.pyc
     文件        2283  2020-02-28 11:41  FaceClustering\add_encode_file.py
     文件        1238  2020-02-27 11:30  FaceClustering\check_img_size.py
     文件       10963  2020-03-04 16:52  FaceClustering\class_cluster.py
     文件        3910  2020-03-03 16:55  FaceClustering\class_encode.py
     文件        3888  2020-02-26 16:41  FaceClustering\cluster_faces.py
     文件        2265  2020-02-26 10:05  FaceClustering\data_visualization.py
     文件        2813  2020-02-26 11:04  FaceClustering\encode_faces.py
     文件         377  2020-02-24 09:42  FaceClustering\myfunc.py
     文件        3610  2020-02-24 12:00  FaceClustering\space.jpg
     文件        2961  2020-02-24 16:21  FaceClustering\temp.py
     文件        1062  2020-02-28 11:16  FaceClustering\testfile.py

评论

共有 条评论