refactor(detect): 可视化产出改为按类别分目录,与 generate_boxes 一致
原先按 split 和结果类型(ok/missed/extra/none)分目录,层级太深。改成 <类别>/<图名>.png,与 runs/boxes_shap 的结构一致。类别取真值里框最多的那个; 负样本没有真值框,按文件名前缀归类(<类别>_<序号> 是 prepare_label_studio 的命名), 认不出来放 background/。 split 与结果类型仍记在 index.csv 的列里,排序筛选即可。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
9439cbb56a
commit
36fff984b7
@@ -87,3 +87,24 @@ def test_load_dataset_reports_a_missing_directory(dataset):
|
||||
dataset.write_text(yaml.safe_dump(meta), encoding="utf-8")
|
||||
with pytest.raises(FileNotFoundError, match="不存在"):
|
||||
vd.load_dataset(dataset)
|
||||
|
||||
|
||||
# ---------------- 产出的目录结构 ----------------
|
||||
|
||||
|
||||
def test_class_dir_uses_the_dominant_ground_truth_class():
|
||||
classes = ["blackdot", "grease", "normal"]
|
||||
truth = [from_yolo(1, .5, .5, .2, .2), from_yolo(0, .1, .1, .1, .1), from_yolo(1, .8, .8, .1, .1)]
|
||||
assert vd.class_dir_for(truth, classes, "grease_0007") == "grease"
|
||||
|
||||
|
||||
def test_class_dir_falls_back_to_the_filename_prefix():
|
||||
"""负样本没有真值框,按 <类别>_<序号> 的命名归类。"""
|
||||
classes = ["blackdot", "grease", "normal"]
|
||||
assert vd.class_dir_for([], classes, "normal_1234") == "normal"
|
||||
|
||||
|
||||
def test_class_dir_falls_back_to_background_for_unknown_names():
|
||||
classes = ["blackdot", "grease", "normal"]
|
||||
assert vd.class_dir_for([], classes, "IMG_20260101") == "background"
|
||||
assert vd.class_dir_for([], classes, "nofix") == "background"
|
||||
|
||||
Reference in New Issue
Block a user