{"id":18903788,"url":"https://github.com/bububa/facenet","last_synced_at":"2025-04-15T03:33:46.468Z","repository":{"id":59979493,"uuid":"415495987","full_name":"bububa/facenet","owner":"bububa","description":"face detction/recognization golang lib using tensorflow facenet","archived":false,"fork":false,"pushed_at":"2021-10-15T13:05:17.000Z","size":20451,"stargazers_count":4,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-19T05:46:26.447Z","etag":null,"topics":["deep","face-detection","face-recognition","facenet","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bububa.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}},"created_at":"2021-10-10T05:36:34.000Z","updated_at":"2024-01-17T07:36:32.000Z","dependencies_parsed_at":"2022-09-25T12:11:45.508Z","dependency_job_id":null,"html_url":"https://github.com/bububa/facenet","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Ffacenet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Ffacenet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Ffacenet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Ffacenet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bububa","download_url":"https://codeload.github.com/bububa/facenet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223657830,"owners_count":17181024,"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":["deep","face-detection","face-recognition","facenet","tensorflow"],"created_at":"2024-11-08T09:06:27.691Z","updated_at":"2024-11-08T09:06:28.381Z","avatar_url":"https://github.com/bububa.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Golang lib for detect/recognize by tensorflow facenet\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/bububa/facenet.svg)](https://pkg.go.dev/github.com/bububa/facenet)\n[![Go](https://github.com/bububa/facenet/actions/workflows/go.yml/badge.svg)](https://github.com/bububa/facenet/actions/workflows/go.yml)\n[![goreleaser](https://github.com/bububa/facenet/actions/workflows/goreleaser.yml/badge.svg)](https://github.com/bububa/facenet/actions/workflows/goreleaser.yml)\n[![GitHub go.mod Go version of a Go module](https://img.shields.io/github/go-mod/go-version/bububa/facenet.svg)](https://github.com/bububa/facenet)\n[![GoReportCard](https://goreportcard.com/badge/github.com/bububa/facenet)](https://goreportcard.com/report/github.com/bububa/facenet)\n[![GitHub license](https://img.shields.io/github/license/bububa/facenet.svg)](https://github.com/bububa/facenet/blob/master/LICENSE)\n[![GitHub release](https://img.shields.io/github/release/bububa/facenet.svg)](https://GitHub.com/bububa/facenet/releases/)\n\n## Prerequest\n\n1. libtensorfow 1.x\n   Follow the instruction [Install TensorFlow for C](https://www.tensorflow.org/install/lang_c#macos)\n2. facenet tenorflow saved_model [Google Drive](https://drive.google.com/drive/folders/1SV59OmZRrYBC1n-5r52rb0H4BtoRNDZ3?usp=sharing)\n3. build the executable\n4. download font(optional) [Google Drive](https://drive.google.com/drive/folders/1h1ezExfKkZuHQqdAurZTvYSxQeef1I7m?usp=sharing)\n\n```bash\n# generated to ./bin/facenet\nmake facenet\n```\n\n## Demo\n\n![demo screen capture](https://github.com/bububa/facenet/blob/main/cmd/camera/demo.gif?raw=true)\n\n## Install\n\ngo get -u github.com/bububa/facenet\n\n## Usage\n\n### Train faces\n\n```bash\n./bin/facenet -model=./models/facenet -db=./models/people.db -train={image folder for training} -output={fold path for output thumbs(optional)}\n```\n\nthe train folder include folders which name is the label with images inside\n\n### Update distinct labels\n\n```bash\n./bin/facenet -model=./models/facenet -db=./models/people.db -update={labels for update seperated by comma} -output={fold path for output thumbs(optional)}\n```\n\n### Delete distinct labels from people model\n\n```bash\n./bin/facenet -model=./models/facenet -db=./models/people.db -delete={labels for delete seperated by comma} -output={fold path for output thumbs(optional)}\n```\n\n### Detect faces for image\n\n```bash\n./bin/facenet -model=./models/facenet -db=./models/people.db -detect={the image file path for detecting} -font={font folder for output image(optional)} -output={fold path for output thumbs(optional)}\n```\n\n## Camera \u0026 Server\n\n### Requirements\n\n- [libjpeg-turbo](https://www.libjpeg-turbo.org/) (use `-tags jpeg` to build without `CGo`)\n- On Linux/RPi native Go [V4L](https://github.com/korandiz/v4l) implementation is used to capture images.\n\n### Use Opencv4\n\n```bash\nmake cvcamera\n```\n\n### On linux/Pi\n\n```bash\n# use native Go V4L implementation is used to capture images\nmake linux_camera\n```\n\n### Use image/jpeg instead of libjpeg-turbo\n\nuse jpeg build tag to build with native Go `image/jpeg` instead of `libjpeg-turbo`\n\n```bash\ngo build -o=./bin/cvcamera -tags=cv4,jpeg ./cmd/camera\n```\n\n### Usage as Server\n\n```\nUsage of camera:\n  -bind string\n\tBind address (default \":56000\")\n  -delay int\n\tDelay between frames, in milliseconds (default 10)\n  -width float\n\tFrame width (default 640)\n  -height float\n\tFrame height (default 480)\n  -index int\n\tCamera index\n  -model string\n    saved_mode path\n  -db string\n    classifier db\n```\n\n## User as lib\n\n```golang\nimport (\n    \"log\"\n\n\t\"github.com/llgcode/draw2d\"\n\n    \"github.com/bububa/facenet\"\n)\n\nfunc main() {\n    estimator, err := facenet.New(\n        facenet.WithModel(\"./models/facenet\"),\n        facenet.WithDB(\"./models/people.db\"),\n        facenet.WithFontPath(\"./font\"),\n    )\n    if err != nil {\n       log.Fatalln(err)\n    }\n\terr = estimator.SetFont(\u0026draw2d.FontData{\n\t\tName: \"NotoSansCJKsc\",\n\t\t//Name:   \"Roboto\",\n\t\tFamily: draw2d.FontFamilySans,\n\t\tStyle:  draw2d.FontStyleNormal,\n\t}, 9)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n    // Delete labels\n    {\n        labels := []string{\"xxx\", \"yyy\"}\n        for _, label := range labels {\n            if deleted := estimator.DeletePerson(label); deleted {\n                log.Printf(\"[INFO] person: %s deleted\\n\", label)\n                continue\n            }\n            log.Printf(\"[WRN] person: %s not found\\n\", label)\n        }\n        err := estimator.SaveDB(\"./models/people.db\")\n        if err != nil {\n            log.Fatalln(err)\n        }\n    }\n\n    // Detect faces\n    {\n        img, _ := loadImage(imgPath)\n        minSize := 20\n\t\tmarkers, err := instance.DetectFaces(img, minSize)\n\t\tif err != nil {\n\t\t\tlog.Fatalln(err)\n\t\t}\n\t\tfor _, marker := range markers.Markers() {\n\t\t\tif marker.Error() != nil {\n\t\t\t\tlog.Printf(\"label: %s, %v\\n\", marker.Label(), marker.Error())\n\t\t\t} else {\n\t\t\t\tlog.Printf(\"label: %s, distance:%f\\n\", marker.Label(), marker.Distance())\n\t\t\t}\n\t\t}\n\t\tif outputPath != \"\" {\n            txtColor := \"#FFF\"\n            successColor := \"#4CAF50\"\n            failedColor := \"#F44336\"\n            strokeWidth := 2\n            successMarkerOnly := false\n\t\t\tmarkerImg := estimator.DrawMarkers(markers, txtColor, successColor, failedColor, 2, successMarkerOnly)\n\t\t\tif err := saveImage(markerImg, outputPath); err != nil {\n\t\t\t\tlog.Fatalln(err)\n\t\t\t}\n\t\t}\n    }\n\n    // Training\n    // check cmd/facenet\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbububa%2Ffacenet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbububa%2Ffacenet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbububa%2Ffacenet/lists"}