Jung-Jun-Uk / mixface

K-FACE Analysis Project on Pytorch
MIT License
10 stars 2 forks source link

Can I still use this code? #2

Open Cubis13 opened 4 months ago

Cubis13 commented 4 months ago
        test_dataset1 = BinDatasets(bin_path=bin_path, config=config)
        test_dataset2 = KFaceDatasets(data_path, test_idx_path, img_size, 
                                     acs, lux, eps, pose, mode='test', double=False)

Is there a reason why you made the test_dataset1 as a binary file as above? I'm trying to inference, but I can't find the binary file. Is there a preprocessing process for the k-face testset before running test.py ?

Jung-Jun-Uk commented 4 months ago

test_dataset1 is used when evaluating open benchmark face verification datasets such as lfw and cfpfp.

This dataset is in bin file format and can be downloaded from the link.

link: https://github.com/deepinsight/insightface/wiki/Dataset-Zoo

If you want to use only "KFace", enter --dataset "kface" like in the script below.

cd recognition

# example
python test.py --weights 'kface.mixface.1e-22m0.25.best.pt' --dataset 'kface' --data_cfg 'data/KFACE/kface.T4.yaml'
Cubis13 commented 3 months ago

Thanks! It was solved safely.

I ran the code to the default option you provided, but the performance on the Q4 dataset looks low.

The difference from the performance you presented is too big. Should I change th face detection model to resnet?

Cubis13 commented 3 months ago

What options should I choose for the best performance you've achieved?

Jung-Jun-Uk commented 3 months ago

If you have done face detection & alignment correctly, try changing the loss. Mixface is an old paper, and I recommend UNPG (Unified Negative Pair Generation toward Well-discriminative Feature Space for Face Recognition@BMVC'2022) or circle loss (Circle Loss: A Unified Perspective of Pair Similarity Optimization@CVPR'2020). These achieve higher performance more reliably.

Cubis13 commented 3 months ago

Thanks for the recommendation. I'm looking for a pretrained model that performs well for Asians.

I wonder that this model is different in performance from what is described for the Q4 test set. The detection model used the default value, mobileenet. Unlike retinaface, it does not remove lighting.

Cubis13 commented 3 months ago
# align_kfaces.py
def parser():   
    parser = argparse.ArgumentParser(description='KFACE detection and alignment')
    parser.add_argument('--ori_data_path', type=str, default='/mixface/datasets', help='raw KFACE path') # '/data/data_server/jju/datasets/FACE/kface-retinaface-112x112'
    parser.add_argument('--detected_data_path', type=str, default=/mixface/kface-test', help='output path')
    args = parser.parse_args()

# test.py
def parser():    
    parser = argparse.ArgumentParser(description='Face Test')
    parser.add_argument('--weights', type=str , default='/mixface/checkpoints/merge.mixface.1e-22m0.5.best.pt', help='pretrained weights path')
    parser.add_argument('--wname'  , type=str , default='best', help='pretrained weights name: best or last')
    parser.add_argument('--dataset'           , default='kface', help='kface/face/merge')
    parser.add_argument('--model'             , default='iresnet-34', help='iresnet-34')
    parser.add_argument('--head'              , default='mixface', help='e.g. arcface, sn-pair, ms-loss, mixface, etc.')
    parser.add_argument('--data_cfg', type=str, default='/mixface/recognition/data/KFACE/kface.T4.yaml', help='data yaml path')

    parser.add_argument('--workers'           , type=int, default=1) # 4
    parser.add_argument('--batch_size'        , type=int, default=512)

    parser.add_argument('--device', default='0', help='cuda device, i.e. 0 or 0,1,2,3 or cpu') 
    parser.add_argument('--project', default='runs', help='save to project/name')
    parser.add_argument('--name', default='exp', help='run test dir name')

    args = parser.parse_args()
    return args

Is anything wrong? I downloaded pre-trained model and ran it as follows to check the same performances as you.

Jung-Jun-Uk commented 3 months ago

Our pre-trained model? If so, there seems to be a problem with detection.

In the case of the detection model, it cannot detect low-light face images, so it uses the bounding box of L1.

Did you run our python align_kfaces.py?, If not

First, check whether the low light face image has been detected well.

Second, I recommend UNPG pretrained model Arc+UNPG [https://github.com/Jung-Jun-Uk/UNPG]

If you intend to use real applications, you need to find a detection model that can detect low-light faces.

Cubis13 commented 3 months ago

I used your python align_kfaces.py. but I got

The following is the detection result of Resnet50_Final.pth 19062421-S001-L1-E01-C1.jpg C1

What was the result of your experiment?