classification-workflows
Use ImageAI ImageNet and custom image classification inference workflows with PyTorch model weights.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- classification-workflows
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Use ImageAI ImageNet and custom image classification inference workflows with PyTorch model weights.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md9.6 KB
- 参考文档references/troubleshooting.md7.1 KB
- 参考文档references/workflows.md7.7 KB
- 脚本scripts/classify_image.py9.6 KB
03 SKILL.md 正文
Classification Workflows
Use this sub-skill when the task is to classify still images with ImageAI's PyTorch classification APIs:
- ImageNet classification with
ImageClassificationand built-in ImageNet class labels. - Custom classification inference with
CustomImageClassification, an ImageAI-trained.pt/.pthmodel, and the matching JSON class mapping. - CPU-forced classification,
result_countselection, file/numpy/PIL image inputs, and the returned label/probability arrays.
Do not use this sub-skill for custom model training or dataset preparation; route those requests to custom-training-and-data. Do not use it for object detection or video detection; route those to the detection sub-skills.
Runtime references
- API reference: verified class names, call order, method signatures, model type mapping, input forms, return shapes, and model extension behavior.
- Workflows: ImageNet and custom classification recipes, asset prerequisites, CPU-only commands, validation steps, and in-process examples.
- Troubleshooting: classification-specific recovery for missing dependencies, TensorFlow
.h5files, mismatched model type/weights, bad JSON mappings, image input errors, and warning noise. - Helper script: parameterized CLI wrapper around
ImageClassificationandCustomImageClassificationthat prints JSON and never downloads weights.
For package-wide installation, backend, and model-asset policy, also check the root skill's installation and model assets notes.
Quick routing checklist
- Ask whether the user has ImageNet release weights or a custom ImageAI-trained classifier. ImageNet mode needs only the model file; custom mode also needs the JSON class mapping produced during training.
- Match
--model-typeor the setter method to the architecture used by the weights:mobilenetv2,resnet50,inceptionv3, ordensenet121. - Reject TensorFlow-era
.h5weights for ImageAI 3.x. Use.ptor.pth; for.h5, explain the ImageAI 2.1.6-or-earlier compatibility path instead of trying to load it. - Call the model type setter,
setModelPath(...), customsetJsonPath(...)when needed, optionaluseCPU(), thenloadModel()beforeclassifyImage(...). - Treat outputs as two parallel arrays:
labels: list[str]andprobabilities: list[float]in descending score order.
Safe helper use
Use the bundled helper for command-line classification when the user supplies local asset paths:
python scripts/classify_image.py \
--mode imagenet \
--model-type resnet50 \
--model-path /path/to/resnet50-weights.pth \
--image /path/to/image.jpg \
--result-count 5 \
--cpu
For custom classification, add --json-path /path/to/model_classes.json and keep --model-type aligned with the architecture used during training. The helper accepts image files only; in-process API usage can pass str paths, numpy.ndarray, or PIL.Image.Image objects as described in the API reference.
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).