以下链接是个人关于insightFace所有见解,如有错误欢迎大家指出,我会第一时间纠正,如有兴趣可以加微信:17575010159 相互讨论技术。 人脸识别0-00:insightFace目录:https://blog.csdn.net/weixin_43013761/article/details/99646731: 这是本人项目的源码:https://github.com/944284742/1.FaceRecognition 其中script目录下的文件为本人编写,主要用于适应自己的项目,可以查看该目录下的redeme文件。
人脸数据清洗在我们对人脸进行分类之后,其中肯定还包含了很多噪音,我们需要再次对数据进行清洗,本人自己编写的清洗代码如下: script\dataset_clean.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from __future__ import print_function
import os
import sys
curr_path = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.join(curr_path, "../python"))
import mxnet as mx
import random
import argparse
import cv2
import time
import shutil
import copy
import traceback
import numpy as np
import sklearn
from mxnet import ndarray as nd
from sklearn.cluster import DBSCAN
try:
import multiprocessing
except ImportError:
multiprocessing = None
class Model():
def __init__(self,image_size, args):
prefix, epoch = args.model.split(',')
sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, int(epoch))
all_layers = sym.get_internals()
self.model = mx.mod.Module(symbol=sym, context=mx.gpu())
self.model.bind(data_shapes=[('data', (1, 3, image_size[0], image_size[1]))])
self.model.set_params(arg_params, aux_params)
def predict(self,img):
img = nd.array(img)
img = nd.transpose(img, axes=(2, 0, 1)).astype('float32')
img = nd.expand_dims(img, axis=0)
#print(img.shape)
db = mx.io.DataBatch(data=(img,))
self.model.forward(db, is_train=False)
net_out = self.model.get_outputs()
embedding = net_out[0].asnumpy()
embedding = sklearn.preprocessing.normalize(embedding)
return embedding
def imgs_detect(args,embeddings):
#print(imgpaths)
#print(embeddings.shape)
#print('-'*50)
if args.detect_mode==1:
"""
emb_mean = np.mean(embeddings, axis=0, keepdims=True)
emb_mean = sklearn.preprocessing.normalize(emb_mean)
sim = np.dot(embeddings, emb_mean.T)
#print(sim.shape)
sim = sim.flatten()
#print(sim.flatten())
x = np.argsort(sim)
for ix in range(len(x)):
_idx = x[ix]
_sim = sim[_idx]
#if ix
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?