1996scarlet/ArcFace-Multiplex-Recognition

Args in file facemodel.py

ThanhNhann opened this issue · 5 comments

Args in file facemodel.py

The first thing I want to declare is that this project is based on InsightFace.
I am sorry that I have not updated readme yet.
The args parser function is defined as def start_up_init(train_mode=False) in helper.py

def start_up_init(train_mode=False):
    parser = argparse.ArgumentParser(description='Arc Face Online Test')

    # =================== General ARGS ====================
    if not train_mode:
        parser.add_argument('ip_address', type=str,
                            help='相机的IP地址或测试用视频文件名')
    parser.add_argument('--face_recognize_threshold', type=float,
                        help='可疑人员识别阈值', default=0.95)
    parser.add_argument('--max_face_number', type=int,
                        help='同时检测的最大人脸数量', default=8)
    parser.add_argument('--max_frame_rate', type=int,
                        help='最大FPS', default=25)
    parser.add_argument('--image-size', default='112,112',
                        help='输入特征提取网络的图片大小')
    parser.add_argument('--dangerous_threshold', type=int,
                        help='1/2报警窗口长度', default=16)
    parser.add_argument('--model', default='./model-r100-ii/model,0',
                        help='特征提取网络预训练模型路径')
    parser.add_argument('--gpu', default=0, type=int,
                        help='GPU设备ID,-1代表使用CPU')
    parser.add_argument('--det', default=0, type=int,
                        help='设置为1代表使用R+O网络进行检测, 0代表使用P+R+O进行检测')
    parser.add_argument('--flip', default=1, type=int,
                        help='是否在训练时进行左右翻转相加操作')
    parser.add_argument('--threshold', default=1.24, type=float,
                        help='空间向量距离阈值')
    parser.add_argument('-v', '--video_mode', action="store_true",
                        help='设置从视频读取帧数据', default=False)
    parser.add_argument('-c', '--cv_test_mode', action="store_true",
                        help='设置本地预览', default=False)
    parser.add_argument('--mtcnn_minsize', type=int,
                        help='mtcnn最小检测框的尺寸(越小检测精度越高)', default=50)
    parser.add_argument('--mtcnn_factor', type=float,
                        help='mtcnn图像缩放系数(关联图像金字塔层数,越大检测精度越高)', default=0.709)
    parser.add_argument('--mtcnn_threshold', type=float, nargs='+',
                        help='mtcnn三层阈值', default=[0.6, 0.7, 0.92])

    return parser.parse_args()

And the entrance of this system is mikomiko.py

To launch this system you'll need node-js and python3.7.

In this system we use Node-js as the websocket server to transfer image data from python client to webpage client.

I will update the project in the next few days. Thank you for your interest in this project.

Thank you for your explain, it's very helpful for me. In this project, will you use a search algorithm to compare an image input with the dataset?
And one more question is in the function def start_up_init(train_mode=False) in helper.py: how to unstantd the argument in each element parser.add_argument().

In this system we have to load 3 models
1、Pre-trained MTCNN model for face detection (provided by others)
2、Pre-trained ArcFace model for face embedding (provided by others)
3、Pre-trained MLP model for face recognition (provided use train.py)

Once we have detected a face, put it into ArcFace model to get 512 dims embedding vector
Then put the vector into MLP model to get prediction result

async def embedding_loop(preload):
    # =================== FR MODEL ====================
    mlp, class_names = read_pkl_model('./model-mlp/mlp.pkl')
    preload.gpu = -1
    embedding = face_embedding.EmbeddingModel(preload)
    while True:
        img = suspicion_face_queue.get()
        dt = time.strftime('%m-%d %H:%M:%S')

        predict = mlp.predict_proba([embedding.get_one_feature(img)])
        prob = predict.max(1)[0]

        result_queue.put((img, dt, prob, class_names[predict.argmax(1)[0]]))

=========

Some argument have been deprecated, I will tell you the currently availables:

ip_address we use a web camera interface to get the frame. You can change the code to use a local video as the input.
--max_face_number the max number of face that you want MTCNN to detect
--max_frame_rate the gap time to get frame is based on this argument.(see mikomiko.py line 165)
--image-size input image size of ArcFace.
--model the path of ArcFace Model
--gpu choose the Device ID of gpu to use, -1 for use cpu
--flip whether to do flip in the MLP train process
--mtcnn_minsize ,--mtcnn_factor,--mtcnn_threshold are arguments for MTCNN, for the minisize of face to detect, the pyramids of image to factor and the threshold for P-NET R-NET O-NET

The system can be CPU real-time (upload image with max_frame_rate), but it cost nearly 3GB memory.
Use GPU can reduce the lantency to only 0.2s. (change args.fill_number to 6 at mikomiko.py line 185)

Thank you very much, I hope to see the next update soon 💯

@1996scarlet 用webcam试了一下,我有一张照片和stalin的相似度高达99%:)