facenet
Use davidsandberg/facenet for TensorFlow 1.x face recognition workflows: MTCNN alignment, embeddings, classification, LFW evaluation, training, and model export.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- facenet
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Use davidsandberg/facenet for TensorFlow 1.x face recognition workflows: MTCNN alignment, embeddings, classification, LFW evaluation, training, and model export.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/compatibility-and-install.md3.1 KB
- 参考文档references/repo-provenance.md2.8 KB
- 参考文档references/repo-routing-metadata.json328 B
- 参考文档references/troubleshooting.md2.9 KB
- 脚本scripts/check_facenet_environment.py2.9 KB
03 SKILL.md 正文
Facenet Repo Skill
Use this skill when a task involves David Sandberg's TensorFlow 1.x FaceNet repository: aligning face images with MTCNN, extracting embeddings, comparing faces, training an SVM classifier, evaluating on LFW pairs, training FaceNet models, or exporting checkpoints to frozen graphs.
First checks
- Treat Facenet as a source-style TensorFlow 1.x project, not a modern packaged library with console entry points.
- Prefer a Python environment that can import TensorFlow 1.x APIs (
tf.Session,tf.Graph,tf.train, andtf.contrib.slim). TensorFlow 2.x without compatibility shims is not enough. - Ensure Facenet modules are importable as modules such as
facenet,lfw,compare,classifier,train_softmax,train_tripletloss,freeze_graph,align.detect_face, andmodels.inception_resnet_v1. - Run
scripts/check_facenet_environment.pyto verify imports, TensorFlow version, and common dependency availability before planning a workflow. - Read
references/compatibility-and-install.mdwhen installing or debugging the old TensorFlow/Python dependency stack.
Install/inspect
For faithful historical execution, use the repository's documented TensorFlow 1.7/Python 2.7 or 3.5 environment. On modern hosts, use an isolated Python 3.7-era environment with a compatible TensorFlow 1.x build, NumPy/SciPy/scikit-learn/OpenCV/h5py/Pillow, and a compatible protobuf<3.20; do not install into the interpreter running the agent. Because this repo has no packaging metadata, make its source modules importable before running module-style commands. The root checker is the minimum read-only verification:
python scripts/check_facenet_environment.py --json
Route by task
- Dataset layout, image preprocessing, and MTCNN alignment: read
sub-skills/data-and-alignment/SKILL.mdfor class-folder datasets,pairs.txtbasics,prewhiten/crop/flip behavior, and alignment command construction. - Embeddings, comparison, classifiers, and clustering: read
sub-skills/embeddings-and-classification/SKILL.mdfor model-backed embedding extraction,compare, SVM classifier,.npyexports, DBSCAN, and contributed recognition examples. - LFW and verification metrics: read
sub-skills/evaluation/SKILL.mdforvalidate_on_lfw, pair-file validation, ROC/VAL/FAR/AUC/EER interpretation, and fixed-standardization warnings. - Training and model definitions: read
sub-skills/training/SKILL.mdfor softmax/triplet training commands, model definitions, loss functions, learning-rate schedules, logging, and checkpoint outputs. - Model files, checkpoints, and frozen graphs: read
sub-skills/model-export-and-checkpoints/SKILL.mdfor accepted model path formats,load_model, checkpoint selection, tensor names, andfreeze_graphworkflows.
Common Facenet objects and conventions
- A class-folder dataset is
data_dir/person_name/image.ext; labels are assigned by sorted directory order. - The main embedding tensor is usually
embeddings:0, input images areinput:0, and inference mode is controlled byphase_train:0. - A checkpoint model directory must contain exactly one
.metafile plus checkpoint state ormodel-*.ckpt-*files. - A frozen graph is a
.pbfile thatfacenet.load_modelimports directly. - Pretrained models named in the README commonly use image size
160; newer 2018 models require fixed image standardization for comparable LFW results.
Default handoff order
For a new end-to-end request, use this order unless the user already supplies validated artifacts:
- Run the environment checker and confirm TF1 imports.
- Validate the class-folder or LFW data layout.
- Inspect the checkpoint directory or frozen graph signature.
- Build the narrowest workflow command with the owning sub-skill helper.
- Run a bounded help/fixture/model smoke before any long, networked, or hardware-interactive job.
- Record output directories, model path, image size, standardization mode, batch size, and seed so later comparisons are reproducible.
If a request crosses multiple routes, keep each artifact explicit: raw data, aligned data, model/checkpoint, classifier pickle, embeddings, metrics, and logs should not be silently mixed.
Safety and scope
- Full training, LFW benchmarks, and pretrained comparison usually require external datasets or model downloads. Treat them as skip-network or skip-expensive unless the user supplies assets and approves runtime cost.
- Webcam recognition in contributed scripts needs a camera/display plus hard-coded model/classifier assumptions. Document it or adapt it carefully; do not start an infinite webcam loop as a smoke test.
- Do not use TensorFlow 2.x behavior to infer Facenet correctness without checking TF1 compatibility.
- The generated skill excludes the experimental VAE/generative branch and broad
tmp/experiments unless the user explicitly asks for those historical utilities.
References
references/repo-provenance.mdrecords the source commit, evidence paths, and generation baseline.references/repo-routing-metadata.jsonis structured metadata for managed repo-skill routing.references/troubleshooting.mdcovers cross-cutting install/import/model/data failures.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).