{"id":14977282,"url":"https://github.com/joonb14/jhface","last_synced_at":"2025-09-13T01:48:16.360Z","repository":{"id":51096483,"uuid":"346634343","full_name":"joonb14/JHFace","owner":"joonb14","description":"Face Recognition training and testing framework with tensorflow 2.0 based on the  well implemented arcface-tf2. Changes are added to provide tensorflow lite conversion, and provide additional backbones, loss functions.","archived":false,"fork":false,"pushed_at":"2023-02-22T01:49:23.000Z","size":37906,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-01T10:51:09.475Z","etag":null,"topics":["arcface","arcface-loss","arcface-tf2","arcface-tflite","cosface","cosface-loss","cosface-tflite","efficientnet-lite","face-recognition","face-recognition-python","face-recognition-tensorflow","ipynb","mobilenetv3","python","tensorflow-lite","tensorflow2","tensorflowlite","tf2","tflite"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joonb14.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2021-03-11T08:42:19.000Z","updated_at":"2024-11-07T02:11:08.000Z","dependencies_parsed_at":"2024-09-11T12:32:57.315Z","dependency_job_id":"25c467dd-fc73-4d50-babb-7c1fe5215cc7","html_url":"https://github.com/joonb14/JHFace","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joonb14%2FJHFace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joonb14%2FJHFace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joonb14%2FJHFace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joonb14%2FJHFace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joonb14","download_url":"https://codeload.github.com/joonb14/JHFace/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238590593,"owners_count":19497351,"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":["arcface","arcface-loss","arcface-tf2","arcface-tflite","cosface","cosface-loss","cosface-tflite","efficientnet-lite","face-recognition","face-recognition-python","face-recognition-tensorflow","ipynb","mobilenetv3","python","tensorflow-lite","tensorflow2","tensorflowlite","tf2","tflite"],"created_at":"2024-09-24T13:55:24.176Z","updated_at":"2025-02-13T03:31:59.576Z","avatar_url":"https://github.com/joonb14.png","language":"Jupyter Notebook","readme":"# JHFace\n\nThis project is based on the well implemented [arcface-tf2](https://github.com/peteryuX/arcface-tf2).\nThe things that rise error when converting the model to tflite was changed.\n\n### Training the Model\nFor preparing data, follow the instructions provided in  [data-preparing](https://github.com/peteryuX/arcface-tf2#data-preparing)\nThen checkout the [TensorFlow ArcFace.ipynb](https://github.com/joonb14/JHFace/blob/main/TensorFlow%20ArcFace.ipynb).\n\n##### Backbones w/ ImageNet pretrained weights:\n\nNasNet case, because of this [issue](https://github.com/keras-team/keras-applications/issues/78), we manually download the weight file and explicitly load it in [models.py](https://github.com/joonb14/JHFace/blob/main/models.py) file. We tried to provide pretrained weights for the MobileNet and EfficientNet models. However the official Keras implementations of the [MobileNetV3 has built in preprocessing layers inside the model](https://github.com/tensorflow/tensorflow/pull/47808#pullrequestreview-612848161). Also this accounts to [EfficientNet as well](https://github.com/tensorflow/tensorflow/pull/48276). So for the EfficientNet and EfficientNetLite, we used [Weights Transfer.ipynb](https://github.com/joonb14/JHFace/blob/main/Weights%20Transfer.ipynb) for extracting pretrained weights. To use the pretrained weights for NasNet, EfficientNet, EfficientNetLite **please download the weights using this [link](https://drive.google.com/file/d/1EriCfISIfeRAOso1DRRuQD8TFd_as35n/view?usp=sharing).** Then unzip it inside the path/to/JHFace/weights/ directory. All of the pretrained weights are provided by(or extracted from) [tf.keras.applications](https://www.tensorflow.org/api_docs/python/tf/keras/applications)\n\n* MobileNet\n* MobileNetV2\n* InceptionResNetV2\n* InceptionV3\n* ResNet50\n* ResNet50V2\n* ResNet101V2\n* NASNetLarge\n* NASNetMobile\n* Xception\n* MobileNetV3Large\n* MobileNetV3Small\n* EfficientNetLite0 ~ Lite6\n* EfficientNetB0 ~ B7\n\n##### Backbones w/o ImageNet pretrained weights:\n\n\nWe implemented MnasNet models looking at the [official code](https://github.com/tensorflow/tpu/blob/master/models/official/mnasnet/mnasnet_model.py). If there's a bug, please tell us through the github issue page!\n\n* MnasNetA1\n* MnasNetB1\n* MnasNetSmall\n\n##### Loss Function\n\n* [ArcFace](https://openaccess.thecvf.com/content_CVPR_2019/html/Deng_ArcFace_Additive_Angular_Margin_Loss_for_Deep_Face_Recognition_CVPR_2019_paper.html)\n* [CosFace](https://openaccess.thecvf.com/content_cvpr_2018/html/Wang_CosFace_Large_Margin_CVPR_2018_paper.html)\n* [SphereFace](https://openaccess.thecvf.com/content_cvpr_2017/papers/Liu_SphereFace_Deep_Hypersphere_CVPR_2017_paper.pdf)\n##### Configuration\nin the [TensorFlow ArcFace.ipynb](https://github.com/joonb14/JHFace/blob/main/TensorFlow%20ArcFace.ipynb), we provided simple configuration values. To change the model backbone, just change the backbone_type parameter. To change the loss function, just change the head_type parameter.\n```python\n### MS1M dataset\n\nbatch_size = 128 # Initially 128\ninput_size = 112\nembd_shape = 512\nhead_type = 'ArcHead' # 'ArcHead', 'CosHead', 'SphereHead'\n# Backbones w/ pretrained weights:\n#     MobileNet, MobileNetV2, InceptionResNetV2, InceptionV3, ResNet50, ResNet50V2, ResNet101V2, NASNetLarge, NASNetMobile, Xception, MobileNetV3Large, MobileNetV3Small, EfficientNetLite0~6, EfficientNetB0~7\n# Backbones w/o pretrained weights:\n#      MnasNetA1, MnasNetB1, MnasNetSmall \nbackbone_type = 'EfficientNetLite0' \nw_decay=5e-4\nnum_classes = 85742 \ndataset_len = 5822653 \nif head_type == 'SphereHead':\n    base_lr = 0.01 \n    margin = 1.35\n    logist_scale = 30.0 \nelif head_type == 'CosHead':\n    base_lr = 0.01 \n    margin=0.35\n    logist_scale=64\nelif head_type == 'ArcHead':\n    base_lr = 0.01 \n    margin=0.5\n    logist_scale=64\nelse:\n    base_lr = 0.01 # initially 0.01\nepochs = 20\nsave_steps = 1000\ntrain_size = int(0.8 * dataset_len)\nprint(train_size)\nsteps_per_epoch = train_size // batch_size\nprint(steps_per_epoch)\nval_size = dataset_len - train_size\nprint(val_size)\nvalidation_steps = val_size // batch_size\nprint(validation_steps)\nsteps = 1\nis_ccrop=False\nbinary_img=True\nis_Adam = False\n```\n\n## Converting the Model to TensorFlow Lite\n\ncheckout the [TFLite conversion.ipynb](https://github.com/joonb14/arcface-tflite/blob/main/TFLite%20conversion.ipynb).\nInt8 quantization is supported, we checked with MobileNetV2 and EfficientNet-lite0.\n\n## For Face Verification\nWe downloaded the testing dataset from [here.](https://github.com/peteryuX/arcface-tf2#testing-dataset)\nWith the data use the [verification.ipynb](https://github.com/joonb14/JHFace/blob/main/verification.ipynb) for verification test.\n\n## For Face Identificaiton\n\ncheckout the [Face Identification with Centroid Vector.ipynb](https://github.com/joonb14/JHFace/blob/main/Face%20Identification%20with%20Centroid%20Vector.ipynb).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoonb14%2Fjhface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoonb14%2Fjhface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoonb14%2Fjhface/lists"}