{"id":13747219,"url":"https://github.com/rcmalli/keras-vggface","last_synced_at":"2025-04-11T09:28:38.386Z","repository":{"id":12245474,"uuid":"71151117","full_name":"rcmalli/keras-vggface","owner":"rcmalli","description":"VGGFace implementation with Keras Framework","archived":false,"fork":false,"pushed_at":"2024-07-09T14:48:05.000Z","size":6176,"stargazers_count":948,"open_issues_count":42,"forks_count":420,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-04-03T14:59:09.399Z","etag":null,"topics":["keras","tensorflow","vggface"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rcmalli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"rcmalli","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"https://www.paypal.me/rcmalli/5"}},"created_at":"2016-10-17T15:07:40.000Z","updated_at":"2025-03-26T21:49:08.000Z","dependencies_parsed_at":"2023-01-13T16:51:15.314Z","dependency_job_id":"448df4a7-c379-4e3f-b1a5-df9f14f534f8","html_url":"https://github.com/rcmalli/keras-vggface","commit_stats":{"total_commits":70,"total_committers":8,"mean_commits":8.75,"dds":"0.11428571428571432","last_synced_commit":"bee35376e76e35d00aeec503f2f242611a97b38a"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcmalli%2Fkeras-vggface","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcmalli%2Fkeras-vggface/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcmalli%2Fkeras-vggface/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcmalli%2Fkeras-vggface/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rcmalli","download_url":"https://codeload.github.com/rcmalli/keras-vggface/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248367939,"owners_count":21092268,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["keras","tensorflow","vggface"],"created_at":"2024-08-03T06:01:20.640Z","updated_at":"2025-04-11T09:28:38.365Z","avatar_url":"https://github.com/rcmalli.png","language":"Python","funding_links":["https://github.com/sponsors/rcmalli","https://www.paypal.me/rcmalli/5"],"categories":["Python","Training"],"sub_categories":["Embeddings"],"readme":"# keras-vggface [![Build Status](https://travis-ci.org/rcmalli/keras-vggface.svg?branch=master)](https://travis-ci.org/rcmalli/keras-vggface) [![PyPI Status](https://badge.fury.io/py/keras-vggface.svg)](https://badge.fury.io/py/keras-vggface) [![PyPI Status](https://pepy.tech/badge/keras-vggface)](https://pepy.tech/project/keras-vggface)\n\nOxford VGGFace  Implementation using Keras Functional Framework v2+\n\n- Models are converted from original caffe networks.\n- It supports only Tensorflow backend.\n- You can also load only feature extraction layers with VGGFace(include_top=False) initiation.\n- When you use it for the first time , weights are downloaded and stored in ~/.keras/models/vggface folder.\n- If you don't know where to start check the [blog posts](https://github.com/rcmalli/keras-vggface#projects--blog-posts) that are using this library.\n\n~~~bash\n# Most Recent One (Suggested)\npip install git+https://github.com/rcmalli/keras-vggface.git\n# Release Version\npip install keras_vggface\n~~~\n\n\n### Library Versions\n\n- Keras v2.2.4\n- Tensorflow v1.14.0\n- **Warning: Theano backend is not supported/tested for now.**\n\n### Example Usage\n\n#### Available Models\n\n```python\n\nfrom keras_vggface.vggface import VGGFace\n\n# Based on VGG16 architecture -\u003e old paper(2015)\nvggface = VGGFace(model='vgg16') # or VGGFace() as default\n\n# Based on RESNET50 architecture -\u003e new paper(2017)\nvggface = VGGFace(model='resnet50')\n\n# Based on SENET50 architecture -\u003e new paper(2017)\nvggface = VGGFace(model='senet50')\n\n```\n\n\n#### Feature Extraction\n \n- Convolution Features\n\n    ```python\n    from keras.engine import  Model\n    from keras.layers import Input\n    from keras_vggface.vggface import VGGFace\n\n    # Convolution Features\n    vgg_features = VGGFace(include_top=False, input_shape=(224, 224, 3), pooling='avg') # pooling: None, avg or max\n\n    # After this point you can use your model to predict.\n    # ...\n\n    ```\n\n\n- Specific Layer Features\n\n    ```python\n    from keras.engine import  Model\n    from keras.layers import Input\n    from keras_vggface.vggface import VGGFace\n\n    # Layer Features\n    layer_name = 'layer_name' # edit this line\n    vgg_model = VGGFace() # pooling: None, avg or max\n    out = vgg_model.get_layer(layer_name).output\n    vgg_model_new = Model(vgg_model.input, out)\n\n    # After this point you can use your model to predict.\n    # ...\n\n    ```\n\n\n\n#### Finetuning\n\n- VGG16\n\n    ```python\n    from keras.engine import  Model\n    from keras.layers import Flatten, Dense, Input\n    from keras_vggface.vggface import VGGFace\n\n    #custom parameters\n    nb_class = 2\n    hidden_dim = 512\n\n    vgg_model = VGGFace(include_top=False, input_shape=(224, 224, 3))\n    last_layer = vgg_model.get_layer('pool5').output\n    x = Flatten(name='flatten')(last_layer)\n    x = Dense(hidden_dim, activation='relu', name='fc6')(x)\n    x = Dense(hidden_dim, activation='relu', name='fc7')(x)\n    out = Dense(nb_class, activation='softmax', name='fc8')(x)\n    custom_vgg_model = Model(vgg_model.input, out)\n\n    # Train your model as usual.\n    # ...\n    ```\n\n- RESNET50 or SENET50\n\n    ```python\n    from keras.engine import  Model\n    from keras.layers import Flatten, Dense, Input\n    from keras_vggface.vggface import VGGFace\n\n    #custom parameters\n    nb_class = 2\n\n    vgg_model = VGGFace(include_top=False, input_shape=(224, 224, 3))\n    last_layer = vgg_model.get_layer('avg_pool').output\n    x = Flatten(name='flatten')(last_layer)\n    out = Dense(nb_class, activation='softmax', name='classifier')(x)\n    custom_vgg_model = Model(vgg_model.input, out)\n\n    # Train your model as usual.\n    # ...\n    ```\n\n\n\n#### Prediction\n\n- Use `utils.preprocess_input(x, version=1)` for VGG16\n- Use `utils.preprocess_input(x, version=2)` for RESNET50 or SENET50\n\n\n    ```python\n    import numpy as np\n    from keras.preprocessing import image\n    from keras_vggface.vggface import VGGFace\n    from keras_vggface import utils\n\n    # tensorflow\n    model = VGGFace() # default : VGG16 , you can use model='resnet50' or 'senet50'\n\n    # Change the image path with yours.\n    img = image.load_img('../image/ajb.jpg', target_size=(224, 224))\n    x = image.img_to_array(img)\n    x = np.expand_dims(x, axis=0)\n    x = utils.preprocess_input(x, version=1) # or version=2\n    preds = model.predict(x)\n    print('Predicted:', utils.decode_predictions(preds))\n    ```\n\n\n### References\n\n- [Keras Framework](www.keras.io)\n\n- [Oxford VGGFace Website](http://www.robots.ox.ac.uk/~vgg/software/vgg_face/)\n\n- [Related Paper 1](http://www.robots.ox.ac.uk/~vgg/publications/2015/Parkhi15/parkhi15.pdf)\n\n- [Related Paper 2](http://www.robots.ox.ac.uk/~vgg/publications/2018/Cao18/cao18.pdf)\n\n### Licence \n\n- Check Oxford Webpage for the license of the original models.\n\n- The code that provided in this project is under MIT License.\n\n### Projects / Blog Posts\n\nIf you find this project useful, please include reference link in your work. You can create PR's to this document with your project/blog link.\n\n- [Live Face Identification with pre-trained VGGFace2 model](https://www.dlology.com/blog/live-face-identification-with-pre-trained-vggface2-model/)\n\n- [How to Perform Face Recognition With VGGFace2 in Keras](https://machinelearningmastery.com/how-to-perform-face-recognition-with-vggface2-convolutional-neural-network-in-keras/)\n\n- [An extremely small FaceRecog project for extreme beginners, and a few thoughts on the future](https://kevincodeidea.wordpress.com/2020/01/14/an-extremely-small-facerecog-project-for-extreme-beginners-and-a-few-thoughts-on-future-part-ii-transfer-learning-and-keras/)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcmalli%2Fkeras-vggface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frcmalli%2Fkeras-vggface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcmalli%2Fkeras-vggface/lists"}