Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Questions About Training the SFace Model and Discrepancies in Model Size, Accuracy, and Output Dimensions #288

Open
sayyid-abolfazl opened this issue Mar 12, 2025 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@sayyid-abolfazl
Copy link

sayyid-abolfazl commented Mar 12, 2025

Hello and thank you for your amazing work,

I have some questions regarding the training process of the SFace model. I have been trying to train the model using the repository, and I have tested it on various datasets. However, I am facing some issues and discrepancies compared to the official model, and I would appreciate your guidance on how to resolve them. My ultimate goal is to first achieve the same accuracy as your pre-trained model and then train it on my custom dataset.

Here are the details of my observations and questions:

  1. Model Size Discrepancy:

    • The size of my trained SFace model is 5.1 MB, while the official model provided in the repository is 39 MB. Why is there such a large difference in model size?
  2. Accuracy Discrepancy:

    • The accuracy of my trained SFace model is significantly lower than the accuracy of your pre-trained model. What could be the reasons for this gap, and how can I improve the accuracy to match yours?
  3. Output Embedding Size Discrepancy:

    • My trained model produces an embedding size of 512, while I noticed that the official SFace model has an embedding size of 128. Why is there a difference, and how can I configure my training to produce an embedding size of 128 instead of 512?
  4. Training Details:
    Below is the configuration I used for training my model. Could you please review it and let me know if there are any parameters or settings that need to be adjusted to achieve results closer to your pre-trained model?

    {
        'SEED': 1337,
        'INPUT_SIZE': [112, 112],
        'EMBEDDING_SIZE': 512,
        'DROP_LAST': True,
        'WEIGHT_DECAY': 0.0005,
        'MOMENTUM': 0.9,
        'GPU_ID': [0],
        'DEVICE': device(type='cuda', index=0),
        'MULTI_GPU': False,
        'NUM_EPOCH': 125,
        'STAGES': [35, 65, 95, 205],
        'LR': 0.1,
        'BATCH_SIZE': 240,
        'DATA_ROOT': '../faces_emore/',
        'EVAL_PATH': '../eval/',
        'BACKBONE_NAME': 'MobileFaceNet',
        'HEAD_NAME': 'SFaceLoss',
        'TARGET': ['cfp_ff', 'cplfw', 'calfw', 'cfp_fp', 'vgg2_fp', 'lfw', 'agedb_30'],
        'BACKBONE_RESUME_ROOT': '',
        'HEAD_RESUME_ROOT': '',
        'WORK_PATH': 'face_empire'
    }

parser.add_argument('--param_s', default=64.0, type=float)
parser.add_argument('--param_k', default=80.0, type=float)
parser.add_argument('--param_a', default=0.87, type=float)
parser.add_argument('--param_b', default=1.22, type=float)


5. **Training Logs**:  
Below is a sample of my training logs for reference. If you notice anything unusual or suboptimal, please let me know:  

Epoch 8 Batch 185960 Speed: 797.15 samples/s intra_Loss -25.3453 (-26.1291) inter_Loss 16.8062 (18.1256) Wyi 0.4486 (0.4653) Wj 0.0001 (0.0001) Prec@1 77.917 (82.729)
Epoch 8 Batch 185980 Speed: 696.71 samples/s intra_Loss -26.5736 (-26.1947) inter_Loss 19.4150 (18.5150) Wyi 0.4811 (0.4683) Wj 0.0001 (0.0001) Prec@1 87.500 (82.583)
Epoch 8 Batch 186000 Speed: 709.95 samples/s intra_Loss -26.4986 (-26.2168) inter_Loss 18.4467 (18.5980) Wyi 0.4808 (0.4673) Wj 0.0001 (0.0001) Prec@1 86.250 (82.333)
Learning rate 0.100000
Perform Evaluation on ['cfp_ff', 'cplfw', 'calfw', 'cfp_fp', 'vgg2_fp', 'lfw', 'agedb_30'] , and Save Checkpoints...
(14000, 512)
[cfp_ff][186000]XNorm: 102.98364
[cfp_ff][186000]Accuracy-Flip: 0.98029+-0.00629
[cfp_ff][186000]Best-Threshold: 1.45500
(12000, 512)
[cplfw][186000]XNorm: 85.15097
[cplfw][186000]Accuracy-Flip: 0.78867+-0.02125
[cplfw][186000]Best-Threshold: 1.54200
(12000, 512)
[calfw][186000]XNorm: 103.92467
[calfw][186000]Accuracy-Flip: 0.90883+-0.01038
[calfw][186000]Best-Threshold: 1.49800
(14000, 512)
[cfp_fp][186000]XNorm: 86.52919
[cfp_fp][186000]Accuracy-Flip: 0.80686+-0.02192
[cfp_fp][186000]Best-Threshold: 1.68900
(10000, 512)
[vgg2_fp][186000]XNorm: 89.77735
[vgg2_fp][186000]Accuracy-Flip: 0.84040+-0.01292
[vgg2_fp][186000]Best-Threshold: 1.59500
(12000, 512)
[lfw][186000]XNorm: 104.07785
[lfw][186000]Accuracy-Flip: 0.98400+-0.00642
[lfw][186000]Best-Threshold: 1.43000
(12000, 512)
[agedb_30][186000]XNorm: 100.46037
[agedb_30][186000]Accuracy-Flip: 0.89783+-0.01895
[agedb_30][186000]Best-Threshold: 1.57000
highest_acc: [0.9847142857142857, 0.8046666666666666, 0.9238333333333332, 0.8068571428571429, 0.85, 0.9865, 0.9065000000000001]
Epoch 8 Batch 186020 Speed: 56.99 samples/s intra_Loss -26.4323 (-26.0712) inter_Loss 19.7517 (18.7060) Wyi 0.4774 (0.4650) Wj 0.0001 (0.0001) Prec@1 85.000 (82.271)



If there is a need for specific changes in the   
sface_torch/config.py
sface_torch/train_SFace_torch.py
sface_torch/backbone/model_mobilefacenet.py 
files, please advise. I would be very grateful.


Thank you so much for your time and assistance!
@fengyuentau fengyuentau added the help wanted Extra attention is needed label Mar 12, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants