api-and-architecture
Inspect and modify tf-faster-rcnn model, backbone, RPN/proposal, bbox/blob, and roidb APIs from source without running training or inference.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- api-and-architecture
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Inspect and modify tf-faster-rcnn model, backbone, RPN/proposal, bbox/blob, and roidb APIs from source without running training or inference.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md9.8 KB
- 参考文档references/architecture-notes.md6.8 KB
- 参考文档references/troubleshooting.md4.6 KB
- 脚本scripts/inspect_source_api.py15.1 KB
03 SKILL.md 正文
tf-faster-rcnn API and architecture
Use this sub-skill when a Researcher needs to inspect or modify the repository internals around Network.create_architecture, VGG/ResNet/MobileNet backbones, RPN/proposal layers, bbox transforms, image blob preprocessing, roidb/minibatch structure, or safe extension points for anchors and new backbones.
Do not use this sub-skill as proof that a TensorFlow graph, demo, training job, or evaluation job runs on the current host. Full graph execution depends on the legacy TensorFlow 1.x, Cython/CUDA/NMS, checkpoint, and dataset setup; route that work to installation-and-configuration, inference-and-demo, or training-and-evaluation.
Verified source facts to preserve
The production inspection environment verified these source-level facts with CPU/static checks and a TensorFlow 1.15 CPU inspection substitute:
- Backbone constructors:
vgg16(),resnetv1(num_layers=50), andmobilenetv1(). - All three backbones inherit
Network.create_architecture(mode, num_classes, tag=None, anchor_scales=(8,16,32), anchor_ratios=(0.5,1,2)). cfg.USE_GPU_NMSdefaults toTrue,cfg.TEST.MODEdefaults tonms, and default anchor scales/ratios are[8,16,32]and[0.5,1,2].- Default scale/ratio anchor generation yields
(9, 4)anchors. - Source-level utility/dataset checks passed, but full CUDA native build, demo, train, test, and benchmark AP were not verified.
Operating procedure
-
Start from a source checkout and run the bundled source inspector without importing repo modules:
python scripts/inspect_source_api.py --repo-root <repo-root> --format textUse
--strictwhen you need the script to fail on missing required files or signature drift. -
Read API reference for signatures, shapes, and utility contracts.
-
Read architecture notes before changing graph flow, anchors, RPN/proposal behavior, or a backbone.
-
Read troubleshooting when signatures match but graph construction, roidb minibatches, NMS imports, or bbox shapes fail.
-
If the task requires installation, native extension build, TensorFlow session execution, demo commands, training commands, datasets, or checkpoints, stop and route to the appropriate sibling sub-skill.
Common modification patterns
Change anchor scales or ratios
- Prefer passing
anchor_scalesandanchor_ratiostocreate_architectureinstead of hard-coding values in lower layers. - The values are stored on the
Networkinstance, consumed by_anchor_component, passed togenerate_anchors_pre, and determineself._num_anchors. self._num_anchorscontrols RPN classification channels (A * 2), bbox channels (A * 4), anchor target shapes, proposal layer slicing, and proposal target contracts.- After changing anchors, run the source inspector and check every RPN/proposal shape path in architecture notes.
Add or adapt a backbone
A compatible backbone subclass should:
- Inherit
Networkand callNetwork.__init__(self). - Set
_feat_stride,_feat_compress, and_scopein__init__. - Implement
_image_to_head(self, is_training, reuse=None)and storeself._layers['head']. - Implement
_head_to_tail(self, pool5, is_training, reuse=None)and return the feature vector used by region classification. - Implement
get_variables_to_restore(self, variables, var_keep_dic)andfix_variables(self, sess, pretrained_model)if ImageNet/pretrained weights need RGB/BGR or FC/conv conversion. - Wire the new class into CLI/model-selection code only after architecture inspection; command workflows belong to
inference-and-demoortraining-and-evaluation.
Inspect roidb and minibatch inputs
RoIDataLayer.forward()returns blobs fromget_minibatch:data,gt_boxes, andim_info.datais an NHWC float32 blob with pixel means subtracted; the repo assumes a single-image minibatch for core train/test paths.gt_boxesis shaped(N, 5)with(x1, y1, x2, y2, class)after image scaling.im_infois[height, width, scale]for the prepared blob.
Boundaries and omissions
- This sub-skill intentionally performs AST/source inspection only. It does not import
tensorflow, build Cython/CUDA extensions, download checkpoints, open datasets, or run demo/train/test code. - Full backend setup and
gpu_nms/cpu_nmsbuild issues belong toinstallation-and-configuration. - User-facing demo/inference command construction belongs to
inference-and-demo. - Train/test/reval command construction and benchmark caveats belong to
training-and-evaluation.
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).