{"id":33251156,"url":"https://github.com/4uiiurz1/keras-arcface","last_synced_at":"2025-11-21T17:01:48.565Z","repository":{"id":132917836,"uuid":"181879647","full_name":"4uiiurz1/keras-arcface","owner":"4uiiurz1","description":"Keras implementation of ArcFace, CosFace, and SphereFace","archived":false,"fork":false,"pushed_at":"2022-05-09T02:02:47.000Z","size":453,"stargazers_count":281,"open_issues_count":20,"forks_count":65,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-06-29T09:35:12.739Z","etag":null,"topics":["arcface","deep-learning","keras"],"latest_commit_sha":null,"homepage":"","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/4uiiurz1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-04-17T11:43:15.000Z","updated_at":"2024-06-18T05:45:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"f26b071b-3eb0-4f1e-85bd-52a0ed950783","html_url":"https://github.com/4uiiurz1/keras-arcface","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/4uiiurz1/keras-arcface","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4uiiurz1%2Fkeras-arcface","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4uiiurz1%2Fkeras-arcface/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4uiiurz1%2Fkeras-arcface/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4uiiurz1%2Fkeras-arcface/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/4uiiurz1","download_url":"https://codeload.github.com/4uiiurz1/keras-arcface/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4uiiurz1%2Fkeras-arcface/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285655011,"owners_count":27209077,"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","status":"online","status_checked_at":"2025-11-21T02:00:06.175Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","deep-learning","keras"],"created_at":"2025-11-17T00:00:29.716Z","updated_at":"2025-11-21T17:01:48.559Z","avatar_url":"https://github.com/4uiiurz1.png","language":"Python","funding_links":[],"categories":["2 目标检测"],"sub_categories":[],"readme":"# Keras implementation of ArcFace, CosFace, and SphereFace\nThis repository contains code for **ArcFace**, **CosFace**, and **SphereFace** based on [ArcFace: Additive Angular Margin Loss for Deep Face Recognition](https://arxiv.org/abs/1801.07698) implemented in Keras.\n\n## Requirements\n- Python 3.6\n- Keras 2.2.4\n\n## Usage\n### Train\n```python\ninput = Input(shape=(28, 28, 1))\nlabel = Input(shape=(10,))\n\nx = Conv2D(32, kernel_size=(3, 3), activation='relu')(input)\nx = MaxPooling2D(pool_size=(2, 2))(x)\nx = Conv2D(64, kernel_size=(3, 3), activation='relu')(x)\nx = MaxPooling2D(pool_size=(2, 2))(x)\n\nx = BatchNormalization()(x)\nx = Dropout(0.5)(x)\nx = Flatten()(x)\nx = Dense(512, kernel_initializer='he_normal')(x)\nx = BatchNormalization()(x)\noutput = ArcFace(num_classes=10)([x, label])\n\nmodel = Model([input, label], output)\n\nmodel.compile(loss='categorical_crossentropy',\n              optimizer=Adam(),\n              metrics=['accuracy'])\n\nmodel.fit([x_train, y_train],\n          y_train,\n          batch_size=batch_size,\n          epochs=epochs,\n          verbose=1,\n          validation_data=([x_test, y_test], y_test),\n          callbacks=[ModelCheckpoint('model.hdf5',\n                     verbose=1, save_best_only=True)])\n```\n\n### Test\n```python\nmodel.load_weights('model.hdf5')\nmodel = Model(inputs=model.input[0], outputs=model.layers[-3].output)\nembedded_features = model.predict(x_test, verbose=1)\nembedded_features /= np.linalg.norm(embedded_features, axis=1, keepdims=True)\n```\n\n## Training\n### MNIST\nArcFace:\n```\npython train.py --arch vgg8_arcface\n```\nCosFace:\n```\npython train.py --arch vgg8_cosface\n```\nSphereFace:\n```\npython train.py --arch vgg8_sphereface\n```\n\n## Results\n### MNIST\n![softmax](figures/mnist_vgg8_3d.png)\n![arcface](figures/mnist_vgg8_arcface_3d.png)\n![cosface](figures/mnist_vgg8_cosface_3d.png)\n![sphereface](figures/mnist_vgg8_sphereface_3d.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4uiiurz1%2Fkeras-arcface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F4uiiurz1%2Fkeras-arcface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4uiiurz1%2Fkeras-arcface/lists"}