[高] ONNX 元数据缺少 names 时类别数退化为 1,会把 person 当 bird、飞机类别判为空

Open Beginner friendly
#9 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Start at windows/birdlock/core/models.py around lines 99 and 112-123: read how class_names is parsed from ONNX metadata and where num_classes is set. Inspect session.get_outputs()[0].shape and the detection output layout to derive class count from the channel dimension (C - 4 - 3 * num_keypoints) instead of trusting the parse. Done when a model without names reports the real class count, bird_class is 14, and airplane mode no longer shows the missing-class message; reproduce with a no-names ONNX at windows/models/BirdDetector.onnx.

Written by the indexing model from the issue text.

Description

位置:windows/birdlock/core/models.py:99、:112-123

现象:self.num_classes = len(self.class_names) or 1。若导出的 ONNX 没有可解析的 names 元数据(或当前只支持单引号的正则匹配失败),num_classes 变成 1。此时 bird_class 返回 0(COCO 的 person)而不是 14,airplane_class 返回 None,飞机模式会报「当前整机检测模型不包含飞机类别」,而模型输出通道实际是 84。

复现:用一个不带 names 元数据的 YOLO ONNX 替换 windows/models/BirdDetector.onnx,做一次鸟类分析并查看选中框的类别与飞机模式提示。

建议:从 session.get_outputs()[0].shape 推导类别数,或在 detect() 里用 nc = C - 4 - 3 * num_keypoints 判定 80 类回退,不要用解析结果直接决定回退值。

来源:2026-11-15 全仓只读审计,PR #7 未包含此项。 未在 Windows 实机复现,复现路径由代码审计推得。

Dominant language
Swift
Stars
2
Forks
2
Avg merge
2d 53m
Merged PRs (30d)
8

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cyandee/BirdLock

All issues in cyandee/BirdLock

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.