retinaface icon indicating copy to clipboard operation
retinaface copied to clipboard

Validation accuracy & Mobilenet

Open JohannesTK opened this issue 3 years ago • 9 comments

Hi,

Thank you for the rewrite and very intuitive repo.

Have you reported validation accuracy for the Resnet50 and have you also implemented mobilenet?

Thanks, Johannes

JohannesTK avatar Sep 25 '20 14:09 JohannesTK

I did not.

It is not that hard to add the whole set of backbones from https://github.com/rwightman/pytorch-image-models/blob/master/results/results-imagenet.csv but I do not really need it right now, hence I cannot tell when this functionality will be added.

ternaus avatar Sep 29 '20 10:09 ternaus

Thanks for a quick response and well understood regards mobilenet.

Regards the Resnet50 val accuracy, is it the same as reported in https://github.com/biubug6/Pytorch_Retinaface#widerface-val-performance-in-single-scale-when-using-resnet50-as-backbone-net or do you have some numbers for that?

JohannesTK avatar Sep 29 '20 14:09 JohannesTK

I doubt it is the same since @ternaus did train his own model.

A validation accuracy (and other numbers) would be nice just to compare to the baseline retinaface.

tloki avatar Sep 22 '21 05:09 tloki

For information, there is also another project called FaceXLib with RetinaFace for detection.

FaceXlib

The Python package is available on PyPI:

pip install facexlib

As shown in the following code:

https://github.com/xinntao/facexlib/blob/45fee8e7885fc462d2d4c4eafb2650ff384b89c8/facexlib/detection/init.py#L8-L16

The model checkpoints are downloaded from here:

FaceXLib weights

https://github.com/xinntao/facexlib/releases/tag/v0.1.0

They use the same name convention as the original model checkpoints, so I wonder if these are direct copies without re-training. Edit: See my following post, the answer is yes.

https://github.com/biubug6/Pytorch_Retinaface#training

Original weights

woctezuma avatar Sep 22 '21 07:09 woctezuma

I have run the following code on a Google Colab machine:

!wget https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_mobilenet0.25_Final.pth
!wget https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth

!gdown --id 15zP8BP-5IvWXWZoYTNdvUJUiBqZ1hxu1
!gdown --id 14KX6VqF69MdSPk3Tr9PlDYbq7ArpdNUW
!sha256sum *.pth

This is the output:

2979b33ffafda5d74b6948cd7a5b9a7a62f62b949cef24e95fd15d2883a65220  detection_mobilenet0.25_Final.pth
6d1de9c2944f2ccddca5f5e010ea5ae64a39845a86311af6fdf30841b0a5a16d  detection_Resnet50_Final.pth
2979b33ffafda5d74b6948cd7a5b9a7a62f62b949cef24e95fd15d2883a65220  mobilenet0.25_Final.pth
6d1de9c2944f2ccddca5f5e010ea5ae64a39845a86311af6fdf30841b0a5a16d  Resnet50_Final.pth

So the model checkpoints should be the same.

--

If you don't have access to sha256sum on your system (maybe Windows), you can do it in Python:

# Reference: https://stackoverflow.com/a/44873382/376454

import hashlib

def sha256sum(filename):
    h  = hashlib.sha256()
    b  = bytearray(128*1024)
    mv = memoryview(b)
    with open(filename, 'rb', buffering=0) as f:
        for n in iter(lambda : f.readinto(mv), 0):
            h.update(mv[:n])
    return h.hexdigest()
import glob

for fname in glob.glob('*.pth'):
  print(f'{sha256sum(fname)} {fname}')

This is the output (same as above):

2979b33ffafda5d74b6948cd7a5b9a7a62f62b949cef24e95fd15d2883a65220 mobilenet0.25_Final.pth
6d1de9c2944f2ccddca5f5e010ea5ae64a39845a86311af6fdf30841b0a5a16d detection_Resnet50_Final.pth
2979b33ffafda5d74b6948cd7a5b9a7a62f62b949cef24e95fd15d2883a65220 detection_mobilenet0.25_Final.pth
6d1de9c2944f2ccddca5f5e010ea5ae64a39845a86311af6fdf30841b0a5a16d Resnet50_Final.pth

woctezuma avatar Sep 22 '21 07:09 woctezuma

How does this have anything to do with this repo? If I understood you right - your claim is that FaceXLib uses same weights as biubug6 (original retinaface repo?). On FaceXLib it is even stated (README) that they do use biubug6 model/code...

tloki avatar Sep 22 '21 08:09 tloki

How does this have anything to do with this repo?

It is additional information for users like myself who:

  • have used this repository in the past,
  • would like to have validation accuracy for the model checkpoints which they use.

FaceXLib is an alternative which:

  • did not exist when this repository was created,
  • is installable with pip and just as easy to use as this repository,
  • relies on the original weights, for which accuracy is documented.

woctezuma avatar Sep 22 '21 08:09 woctezuma

The reason I was actually interested in this repo was - NMS. biubug6 uses its own implementation, which is slow (it could somewhat easily be parallelized), and this one uses off-the shelf NMS which seems like a less of bottleneck. I'm mainly refereing to for loop which does NMS for every element in batch.

tloki avatar Sep 22 '21 08:09 tloki

I see. It looks like this repository relies on:

wile FaceXLib relies on:

I'm mainly referring to for loop which does NMS for every element in batch.

Maybe I misunderstood and you are referring to another part of the code than the one which I mentioned.

woctezuma avatar Sep 22 '21 08:09 woctezuma