fix Rand augment off
This commit is contained in:
parent
7e71102f86
commit
27d012256e
5 changed files with 31 additions and 5 deletions
|
|
@ -352,8 +352,8 @@ auto_augment=randaugment
|
|||
|
||||
Вероятности и доли валидируются в диапазоне `0…1`; `degrees`, `shear` и
|
||||
`close_mosaic` не могут быть отрицательными. Режимы copy-paste: `flip`, `mixup`.
|
||||
Политики AutoAugment: `randaugment`, `autoaugment`, `augmix`. Если augmentation
|
||||
выключена, эти kwargs вообще не передаются в Ultralytics.
|
||||
Политики AutoAugment: `none` (отключено), `randaugment`, `autoaugment`, `augmix`. Если augmentation
|
||||
выключена, эти kwargs вообще не передаются в Ultralytics. При `auto_augment="none"` параметр транслируется в `None` для Ultralytics.
|
||||
|
||||
## 10. Работа с датасетами
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from typing import Any, Literal
|
|||
|
||||
|
||||
YoloTask = Literal["detect", "segment", "classify", "pose", "obb"]
|
||||
AutoAugmentPolicy = Literal["randaugment", "autoaugment", "augmix"]
|
||||
AutoAugmentPolicy = Literal["none", "randaugment", "autoaugment", "augmix"]
|
||||
CopyPasteMode = Literal["flip", "mixup"]
|
||||
SUPPORTED_TASKS: tuple[YoloTask, ...] = (
|
||||
"detect",
|
||||
|
|
@ -18,6 +18,7 @@ SUPPORTED_TASKS: tuple[YoloTask, ...] = (
|
|||
"obb",
|
||||
)
|
||||
SUPPORTED_AUTO_AUGMENT_POLICIES: tuple[AutoAugmentPolicy, ...] = (
|
||||
"none",
|
||||
"randaugment",
|
||||
"autoaugment",
|
||||
"augmix",
|
||||
|
|
@ -161,7 +162,7 @@ class AugmentationConfig:
|
|||
"cutmix": self.cutmix,
|
||||
"copy_paste": self.copy_paste,
|
||||
"copy_paste_mode": self.copy_paste_mode,
|
||||
"auto_augment": self.auto_augment,
|
||||
"auto_augment": None if self.auto_augment == "none" else self.auto_augment,
|
||||
"erasing": self.erasing,
|
||||
"close_mosaic": self.close_mosaic,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -296,6 +296,7 @@
|
|||
<div class="field">
|
||||
<label for="auto-augment">AutoAugment политика (classify)</label>
|
||||
<select id="auto-augment" name="auto-augment">
|
||||
<option value="none">Отключено</option>
|
||||
<option value="randaugment">RandAugment</option>
|
||||
<option value="autoaugment">AutoAugment</option>
|
||||
<option value="augmix">AugMix</option>
|
||||
|
|
|
|||
|
|
@ -141,13 +141,15 @@ async function flushPromises() {
|
|||
element('workers').value = '0';
|
||||
element('patience').value = '0';
|
||||
element('close-mosaic').value = '0';
|
||||
element('auto-augment').value = 'none';
|
||||
element('config-form').listeners.input();
|
||||
const savedConfig = JSON.parse(storage.get('draft_config'));
|
||||
assert.equal(savedConfig.workers, 0);
|
||||
assert.equal(savedConfig.patience, 0);
|
||||
assert.equal(savedConfig.augmentation.close_mosaic, 0);
|
||||
assert.equal(savedConfig.augmentation.auto_augment, 'none');
|
||||
|
||||
assert.equal(FakeWebSocket.instances.length, 1);
|
||||
assert.equal(FakeWebSocket.instances.length, 2);
|
||||
const socket = FakeWebSocket.instances[0];
|
||||
socket.onmessage({
|
||||
data: JSON.stringify({
|
||||
|
|
|
|||
|
|
@ -42,6 +42,28 @@ def test_augmentation_kwargs_are_passed_to_ultralytics() -> None:
|
|||
assert kwargs["auto_augment"] == "randaugment"
|
||||
|
||||
|
||||
def test_auto_augment_none_policy() -> None:
|
||||
config = TrainingConfig(
|
||||
dataset="dataset.yaml",
|
||||
model="model.pt",
|
||||
augmentation=AugmentationConfig(auto_augment="none"),
|
||||
)
|
||||
|
||||
kwargs = config.train_kwargs()
|
||||
assert kwargs["auto_augment"] is None
|
||||
|
||||
|
||||
def test_invalid_auto_augment_policy() -> None:
|
||||
config = TrainingConfig(
|
||||
dataset="dataset.yaml",
|
||||
model="model.pt",
|
||||
augmentation=AugmentationConfig(auto_augment="invalid_policy"), # type: ignore[arg-type]
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="Неизвестная политика AutoAugment"):
|
||||
config.validate()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("field", ["mosaic", "fliplr", "erasing", "perspective"])
|
||||
def test_augmentation_probabilities_are_validated(field: str) -> None:
|
||||
augmentation = AugmentationConfig(**{field: 1.1})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue