Rotate capped training samples across iterations
This commit is contained in:
@@ -209,6 +209,48 @@ def test_region_cap_drops_only_repeats_and_preserves_every_unique_tile() -> None
|
||||
assert metadata["sampled_entries_by_region"]["flanders"] / len(paths) <= .65
|
||||
|
||||
|
||||
def test_region_cap_rotates_repeats_between_sampling_rounds() -> None:
|
||||
manifest = {"samples": [
|
||||
{"sample_slug": "fl", "split": "train", "region": "flanders", "context": "industrial"},
|
||||
{"sample_slug": "wa", "split": "train", "region": "wallonia", "context": "rural-town"},
|
||||
{"sample_slug": "br", "split": "train", "region": "brussels", "context": "dense-urban"},
|
||||
]}
|
||||
summary = {"tiles": [
|
||||
{"sample_slug": "fl", "split": "train", "label_count": 2, "image_path": f"/tmp/fl-{index}.png"}
|
||||
for index in range(4)
|
||||
] + [
|
||||
{"sample_slug": "wa", "split": "train", "label_count": 2, "image_path": f"/tmp/wa-{index}.png"}
|
||||
for index in range(2)
|
||||
] + [
|
||||
{"sample_slug": "br", "split": "train", "label_count": 2, "image_path": f"/tmp/br-{index}.png"}
|
||||
for index in range(2)
|
||||
]}
|
||||
assessment = {
|
||||
"status": "continue_training_loop",
|
||||
"gates": {"min_region_f1": .45, "min_region_precision": .5, "min_region_recall": .4,
|
||||
"max_pure_empty_false_positives": 0},
|
||||
"calibration": {"regions": {
|
||||
"flanders": {"f1": .2, "precision": .3, "recall": .2},
|
||||
"wallonia": {"f1": .6, "precision": .6, "recall": .6},
|
||||
"brussels": {"f1": .6, "precision": .6, "recall": .6},
|
||||
}},
|
||||
}
|
||||
|
||||
first, first_metadata = MODULE.build_sampling(
|
||||
summary=summary, manifest=manifest, assessment=assessment,
|
||||
positive_repeat=5, max_region_share=.65, sampling_round=1,
|
||||
)
|
||||
second, second_metadata = MODULE.build_sampling(
|
||||
summary=summary, manifest=manifest, assessment=assessment,
|
||||
positive_repeat=5, max_region_share=.65, sampling_round=2,
|
||||
)
|
||||
|
||||
assert first != second
|
||||
assert set(first) == set(second)
|
||||
assert first_metadata["sampling_round"] == 1
|
||||
assert second_metadata["sampling_round"] == 2
|
||||
|
||||
|
||||
def test_coastal_precision_failure_targets_port_and_dunes_negatives() -> None:
|
||||
manifest = {"samples": [
|
||||
{"sample_slug": "coastal-train", "split": "train", "region": "flanders", "context": "coastal-urban"},
|
||||
|
||||
Reference in New Issue
Block a user