GoFaceTrainer - Facial Recognition Model in Go
Step-By-Step Tutorial:
- STEP 2 - Running Machine Box Locally:
- Pull the machinebox/facebox Docker image:
docker pull machinebox/facebox
- Run the Docker image, mapping port 8080 on the container to your desired port on your machine (I have chosen port 8080 for my machine port as well), passing your Machine Box API key from step 1 as the
MB_KEY
environment variable (example command below). Note that you can override the container's serving port (default 8080) with the MB_PORT
environment variable
- On your browser, head over to http://localhost:[mapped-port] and verify you can see the Machine Box console/UI
$ docker run -p 8080:8080 -e "MB_KEY=$MB_KEY" machinebox/facebox
[INFO] starting...
Welcome to Facebox by Machine Box
(facebox 3d8ecd86)
Visit the console to see what this box can do:
http://localhost:8080
If you have any questions or feedback, get in touch:
https://machinebox.io/contact
Report bugs and issues:
https://github.com/machinebox/issues
Tell us what you build on Twitter @machineboxio
[INFO] box ready
- STEP 3 - Sample Your Face:
- Run the Go program in this directory with arguments as below. Note that you must create the output directory before running the command if it does not exist
go run main.go sample [CAMERA_ID] [FACE_ALGO] [N_SAMPLES] [OUTPUT_DIR]
Note before the example line below I ran mkdir out
to create the output directory I'm using
Example:go run main.go sample 0 face_algos/haarcascade_frontalface_default.xml 10 out
- STEP 4 - Train Your Facebox Instance With Your Face Samples:
- Run the Go program in this directory with arguments as follows:
go run main.go train [FACEBOX_URL] [FACES_SRC_DIR] [PERSON_NAME/EXPRESSION_NAME]
Example: go run main.go train http://localhost:8080 out Adriano
go run main.go run [CAMERA_ID] [FACEBOX_URL] [FACE_ALGO]
Example:go run main.go run 0 http://localhost:8080 face_algos/haarcascade_frontalface_default.xml
You are done! hopefully your model is accurate enough. If not, you can always try adding more images by repeating steps 3 and 4
I hope you have enjoyed, issues and PRs are welcome!
Credit given where credit is due:
This project was inspired by packagemain's video: "Face Detection in Go using OpenCV and MachineBox". I highly recommend watching his videos and subscribing if you are a Go enthusiast!