Hazqeel09 / ellzaf_ml

Bridging Research and Practice with PyTorch
MIT License
62 stars 5 forks source link

embeddings #1

Closed wh1t3tea closed 7 months ago

wh1t3tea commented 7 months ago

I have problems with using GhostFaceNetsV2 as feature extractor. As I see it doesn't provide 512 vector if use num_classes=None. image image Can you help me with that?

Hazqeel09 commented 7 months ago

Have you tried with num_classes=0 instead?

khursani8 commented 7 months ago

I don't think related to num_classes this model embeddings is 8192 if you want before classifier embeddings can add below code, and do any pooling technique you prefer

model.classifier = nn.Identity()

which will output 960 and not 512

khursani8 commented 7 months ago

https://colab.research.google.com/drive/1mWQiNdiaI41PI3YTNIAfeewQJd3Zsw7U?usp=sharing image

Hazqeel09 commented 7 months ago

Thank you @khursani8. @wh1t3tea please confirm if his method fix your problem

wh1t3tea commented 7 months ago

Yeah, it works fine, but i have a question about .mean(-1), is it correct to squeeze dims like that? I'm begginer and see this for the first time.

khursani8 commented 7 months ago

Yeah, it works fine, but i have a question about .mean(-1), is it correct to squeeze dims like that? I'm begginer and see this for the first time.

Yes and No, Reason for squeeze like that because it not pretrained weight and just random weight, so just for example only Usually people use pooling https://www.kaggle.com/code/debarshichanda/pytorch-arcface-gem-pooling-starter

Or can read more on retrieval paper

https://amaarora.github.io/posts/2020-08-30-gempool.html

wh1t3tea commented 7 months ago

Thanks a lot! now it looks reasonable for me

Hazqeel09 commented 7 months ago

@wh1t3tea i have reread the paper and go through the paper code again. i've fixed the implementation and will release it in the next 12 hours

wh1t3tea commented 7 months ago

@Hazqeel09, It's would be great! haven't found any other pytorch implementations of this model, so you are doing great job. Thanks!

wh1t3tea commented 7 months ago

Now it works good image

khursani8 commented 7 months ago

Ohh sorry @wh1t3tea , i did not read the paper and assume the implementation correct. Since I usually use embeddings before classifier

Hazqeel09 commented 7 months ago

it's okay @khursani8, the mistake was on my side. at that time, i'm still trying to do these implementations sksksk

thank you for trying to help and joining the discussion

Hazqeel09 commented 7 months ago

@wh1t3tea i've released 1.4.7 to fix the implementation, kindly try the latest version