{"id":15621813,"url":"https://github.com/kagami/go-face","last_synced_at":"2025-05-15T12:04:21.154Z","repository":{"id":31732978,"uuid":"127785723","full_name":"Kagami/go-face","owner":"Kagami","description":":mag: Face recognition with Go","archived":false,"fork":false,"pushed_at":"2024-07-30T07:06:41.000Z","size":90,"stargazers_count":1149,"open_issues_count":45,"forks_count":175,"subscribers_count":33,"default_branch":"master","last_synced_at":"2025-05-15T12:04:15.254Z","etag":null,"topics":["dlib","face-recognition","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kagami.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"COPYING","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":{"custom":"https://www.blockchain.com/btc/payment_request?address=3LKKbbi34MHYRQSLV3ZiDGoKgUmCjhTumT\u0026message=Kagami+open+source+projects+support"}},"created_at":"2018-04-02T16:58:01.000Z","updated_at":"2025-05-13T11:57:28.000Z","dependencies_parsed_at":"2024-10-22T07:04:17.755Z","dependency_job_id":null,"html_url":"https://github.com/Kagami/go-face","commit_stats":{"total_commits":106,"total_committers":7,"mean_commits":"15.142857142857142","dds":0.1132075471698113,"last_synced_commit":"0c14797b4d0e0a8ff4e183ddbd93cab35a42f0f8"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kagami%2Fgo-face","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kagami%2Fgo-face/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kagami%2Fgo-face/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kagami%2Fgo-face/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kagami","download_url":"https://codeload.github.com/Kagami/go-face/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254337612,"owners_count":22054253,"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":["dlib","face-recognition","golang"],"created_at":"2024-10-03T09:51:57.560Z","updated_at":"2025-05-15T12:04:16.141Z","avatar_url":"https://github.com/Kagami.png","language":"Go","funding_links":["https://www.blockchain.com/btc/payment_request?address=3LKKbbi34MHYRQSLV3ZiDGoKgUmCjhTumT\u0026message=Kagami+open+source+projects+support"],"categories":[],"sub_categories":[],"readme":"# go-face [![Build Status](https://travis-ci.org/Kagami/go-face.svg?branch=master)](https://travis-ci.org/Kagami/go-face) [![GoDoc](https://godoc.org/github.com/Kagami/go-face?status.svg)](https://godoc.org/github.com/Kagami/go-face)\n\ngo-face implements face recognition for Go using [dlib](http://dlib.net), a\npopular machine learning toolkit. Read\n[Face recognition with Go](https://hackernoon.com/face-recognition-with-go-676a555b8a7e)\narticle for some background details if you're new to\n[FaceNet](https://arxiv.org/abs/1503.03832) concept.\n\n## Requirements\n\nTo compile go-face you need to have dlib (\u003e= 19.10) and libjpeg development\npackages installed.\n\n### Ubuntu 18.10+, Debian sid\n\nLatest versions of Ubuntu and Debian provide suitable dlib package so just run:\n\n```bash\n# Ubuntu\nsudo apt-get install libdlib-dev libblas-dev libatlas-base-dev liblapack-dev libjpeg-turbo8-dev\n# Debian\nsudo apt-get install libdlib-dev libblas-dev libatlas-base-dev liblapack-dev libjpeg62-turbo-dev\n```\n\n### macOS\n\nMake sure you have [Homebrew](https://brew.sh) installed.\n\n```bash\nbrew install dlib\n```\n\n### Windows\n\nMake sure you have [MSYS2](https://www.msys2.org) installed.\n\n1. Run `MSYS2 MSYS` shell from Start menu\n2. Run `pacman -Syu` and if it asks you to close the shell do that\n3. Run `pacman -Syu` again\n4. Run `pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-dlib`\n5.\n   1. If you already have Go and Git installed and available in PATH uncomment\n      `set MSYS2_PATH_TYPE=inherit` line in `msys2_shell.cmd` located in MSYS2\n      installation folder\n   2. Otherwise run `pacman -S mingw-w64-x86_64-go git`\n6. Run `MSYS2 MinGW 64-bit` shell from Start menu to compile and use go-face\n\n### Other systems\n\nTry to install dlib/libjpeg with package manager of your distribution or\n[compile from sources](http://dlib.net/compile.html). Note that go-face won't\nwork with old packages of dlib such as libdlib18. Alternatively create issue\nwith the name of your system and someone might help you with the installation\nprocess.\n\n## Models\n\nCurrently `shape_predictor_5_face_landmarks.dat`, `mmod_human_face_detector.dat` and\n`dlib_face_recognition_resnet_model_v1.dat` are required. You may download them\nfrom [go-face-testdata](https://github.com/Kagami/go-face-testdata) repo:\n\n```bash\nwget https://github.com/Kagami/go-face-testdata/raw/master/models/shape_predictor_5_face_landmarks.dat\nwget https://github.com/Kagami/go-face-testdata/raw/master/models/dlib_face_recognition_resnet_model_v1.dat\nwget https://github.com/Kagami/go-face-testdata/raw/master/models/mmod_human_face_detector.dat\n```\n\n## Usage\n\nTo use go-face in your Go code:\n\n```go\nimport \"github.com/Kagami/go-face\"\n```\n\nTo install go-face in your $GOPATH:\n\n```bash\ngo get github.com/Kagami/go-face\n```\n\nFor further details see [GoDoc documentation](https://godoc.org/github.com/Kagami/go-face).\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"path/filepath\"\n\n\t\"github.com/Kagami/go-face\"\n)\n\n// Path to directory with models and test images. Here it's assumed it\n// points to the \u003chttps://github.com/Kagami/go-face-testdata\u003e clone.\nconst dataDir = \"testdata\"\n\nvar (\n\tmodelsDir = filepath.Join(dataDir, \"models\")\n\timagesDir = filepath.Join(dataDir, \"images\")\n)\n\n// This example shows the basic usage of the package: create an\n// recognizer, recognize faces, classify them using few known ones.\nfunc main() {\n\t// Init the recognizer.\n\trec, err := face.NewRecognizer(modelsDir)\n\tif err != nil {\n\t\tlog.Fatalf(\"Can't init face recognizer: %v\", err)\n\t}\n\t// Free the resources when you're finished.\n\tdefer rec.Close()\n\n\t// Test image with 10 faces.\n\ttestImagePristin := filepath.Join(imagesDir, \"pristin.jpg\")\n\t// Recognize faces on that image.\n\tfaces, err := rec.RecognizeFile(testImagePristin)\n\tif err != nil {\n\t\tlog.Fatalf(\"Can't recognize: %v\", err)\n\t}\n\tif len(faces) != 10 {\n\t\tlog.Fatalf(\"Wrong number of faces\")\n\t}\n\n\t// Fill known samples. In the real world you would use a lot of images\n\t// for each person to get better classification results but in our\n\t// example we just get them from one big image.\n\tvar samples []face.Descriptor\n\tvar cats []int32\n\tfor i, f := range faces {\n\t\tsamples = append(samples, f.Descriptor)\n\t\t// Each face is unique on that image so goes to its own category.\n\t\tcats = append(cats, int32(i))\n\t}\n\t// Name the categories, i.e. people on the image.\n\tlabels := []string{\n\t\t\"Sungyeon\", \"Yehana\", \"Roa\", \"Eunwoo\", \"Xiyeon\",\n\t\t\"Kyulkyung\", \"Nayoung\", \"Rena\", \"Kyla\", \"Yuha\",\n\t}\n\t// Pass samples to the recognizer.\n\trec.SetSamples(samples, cats)\n\n\t// Now let's try to classify some not yet known image.\n\ttestImageNayoung := filepath.Join(imagesDir, \"nayoung.jpg\")\n\tnayoungFace, err := rec.RecognizeSingleFile(testImageNayoung)\n\tif err != nil {\n\t\tlog.Fatalf(\"Can't recognize: %v\", err)\n\t}\n\tif nayoungFace == nil {\n\t\tlog.Fatalf(\"Not a single face on the image\")\n\t}\n\tcatID := rec.Classify(nayoungFace.Descriptor)\n\tif catID \u003c 0 {\n\t\tlog.Fatalf(\"Can't classify\")\n\t}\n\t// Finally print the classified label. It should be \"Nayoung\".\n\tfmt.Println(labels[catID])\n}\n```\n\nRun with:\n\n```bash\nmkdir -p ~/go \u0026\u0026 cd ~/go  # Or cd to your $GOPATH\nmkdir -p src/go-face-example \u0026\u0026 cd src/go-face-example\ngit clone https://github.com/Kagami/go-face-testdata testdata\nedit main.go  # Paste example code\ngo get \u0026\u0026 go run main.go\n```\n\n## Test\n\nTo fetch test data and run tests:\n\n```bash\nmake test\n```\n\n## FAQ\n\n### How to improve recognition accuracy\n\nThere are few suggestions:\n\n* Try CNN recognizing\n* Try different tolerance values of `ClassifyThreshold`\n* Try different size/padding/jittering values of `NewRecognizerWithConfig`\n* Provide more samples of each category to `SetSamples` if possible\n* Implement better classify heuristics (see [classify.cc](classify.cc))\n* [Train](https://blog.dlib.net/2017/02/high-quality-face-recognition-with-deep.html) network (`dlib_face_recognition_resnet_model_v1.dat`) on your own test data\n\n## License\n\ngo-face is licensed under [CC0](COPYING).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkagami%2Fgo-face","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkagami%2Fgo-face","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkagami%2Fgo-face/lists"}