Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

How do I train vggface2 and get my own model? #2

Open
mingrongchen opened this issue May 31, 2019 · 19 comments
Open

How do I train vggface2 and get my own model? #2

mingrongchen opened this issue May 31, 2019 · 19 comments

Comments

@mingrongchen
Copy link

How do I train vggface2 and get my own pre model?

@av-savchenko
Copy link
Owner

Sorry for delay in answer. My notifications were not enebaled for this repository. I added an old code facerec_keras_train.py to train the baseline model on VGGFace2 dataset. This procedure is straightforward, that's why it was not presented in this repository initially.

@maria-zafar
Copy link

Hello Can you please specify the procedure for tuning age_gender model?

@av-savchenko
Copy link
Owner

Script age_gender_identity/age_gender_train.py is used to tune the age-gender model. I am not sure that it will work right now with the recent version of Keras. Nevertheless, it is necessary to prepare two folders (age and gender), each of them should contain train and val parts (see code). I simply used concatenation of IMDB-Wiki and Adience datasets. The former has some mistakes for small ages, so that I corrected them manually. The latter contains the age ranges only, so that I used the middle of this range as a ground truth label. Please see details in the paper

@maria-zafar
Copy link

Script age_gender_identity/age_gender_train.py is used to tune the age-gender model. I am not sure that it will work right now with the recent version of Keras. Nevertheless, it is necessary to prepare two folders (age and gender), each of them should contain train and val parts (see code). I simply used concatenation of IMDB-Wiki and Adience datasets. The former has some mistakes for small ages, so that I corrected them manually. The latter contains the age ranges only, so that I used the middle of this range as a ground truth label. Please see details in the paper

I am trying to do the same but it is showing errors with paths also the 2 folders you are talking about, age and gender must have images in them?

@av-savchenko
Copy link
Owner

av-savchenko commented Oct 6, 2021 via email

@maria-zafar
Copy link

Can you share your email where I can share the screenshots of error?

@av-savchenko
Copy link
Owner

It will be better if you could copy your screenshots directly here so that other users can take a look at this issues. It is possible to simply drag-n-drop any image into github tracker

@maria-zafar
Copy link

okay so this is what I am getting

image

@av-savchenko
Copy link
Owner

It simply means that there is no such folder. Check it by running something like !ls content/drive/MyDrive ... If you use Colab, I believe you need to run
from google.colab import drive
drive.mount('/content/gdrive/')

and then use absolute path /content/gdrive/My Drive/

@maria-zafar
Copy link

It simply means that there is no such folder. Check it by running something like !ls content/drive/MyDrive ... If you use Colab, I believe you need to run from google.colab import drive drive.mount('/content/gdrive/')

and then use absolute path /content/gdrive/My Drive/

the folder is already there if you notice the command right above %run you'll see I have given the path already

@maria-zafar
Copy link

image

@maria-zafar
Copy link

Any suggestions about how to fix this?

@av-savchenko
Copy link
Owner

This is exactly the compatibility issue. Try to change num_class to num_classes at lines 161 and 165.

@maria-zafar
Copy link

Yes this is working!

@maria-zafar
Copy link

Okay I have trained the model using age_gender_train.py and it saves models in the model folder in hdf5 extension however, for inference I have to use facial_analysis.py and in that it uses .pb so how do I create that?

@av-savchenko
Copy link
Owner

Just run the same age gender train with arguments --modelpath and path to your hdf5 file. It is still possible that there are some issues with compatibility because Tensorflow 2.x hides many pb-related methods. The same is true for facial_analysis. For example, tf.gfile.GFile should be renamed to tf.io.gfile.GFile

@maria-zafar
Copy link

yes it is constantly giving error on this. Any suggestions how to fix this tried changing versions, did with tfand keras oalone but it is not getting fixed

image

@av-savchenko
Copy link
Owner

av-savchenko commented Oct 8, 2021 via email

@maria-zafar
Copy link

Input class is located in tensorflow.keras ( https://www.tensorflow.org/api_docs/python/tf/keras/Input). However, this is a general part of the code. I wonder why you did not see the same error while training the model. пт, 8 окт. 2021 г. в 07:12, maria-zafar @.***>:

yes it is constantly giving error on this. Any suggestions how to fix this tried changing versions, did with tfand keras oalone but it is not getting fixed [image: image] https://user-images.githubusercontent.com/69984290/136497101-e03aadd0-f671-4d2c-b94f-7aed8d861e7c.png — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#2 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFZQMVHVDIQMND7SP4A25JDUFZVRNANCNFSM4HRTWV7Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
-- С уважением, А.В. Савченко

Basically it gives an error when the function convert_to_tf() is called in age-gender-train.py. So at first I was training without giving modelpath and it saved the models in .hdf5 only but with path I guess it shall save the model in .pb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants