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` и
|
Вероятности и доли валидируются в диапазоне `0…1`; `degrees`, `shear` и
|
||||||
`close_mosaic` не могут быть отрицательными. Режимы copy-paste: `flip`, `mixup`.
|
`close_mosaic` не могут быть отрицательными. Режимы copy-paste: `flip`, `mixup`.
|
||||||
Политики AutoAugment: `randaugment`, `autoaugment`, `augmix`. Если augmentation
|
Политики AutoAugment: `none` (отключено), `randaugment`, `autoaugment`, `augmix`. Если augmentation
|
||||||
выключена, эти kwargs вообще не передаются в Ultralytics.
|
выключена, эти kwargs вообще не передаются в Ultralytics. При `auto_augment="none"` параметр транслируется в `None` для Ultralytics.
|
||||||
|
|
||||||
## 10. Работа с датасетами
|
## 10. Работа с датасетами
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ from typing import Any, Literal
|
||||||
|
|
||||||
|
|
||||||
YoloTask = Literal["detect", "segment", "classify", "pose", "obb"]
|
YoloTask = Literal["detect", "segment", "classify", "pose", "obb"]
|
||||||
AutoAugmentPolicy = Literal["randaugment", "autoaugment", "augmix"]
|
AutoAugmentPolicy = Literal["none", "randaugment", "autoaugment", "augmix"]
|
||||||
CopyPasteMode = Literal["flip", "mixup"]
|
CopyPasteMode = Literal["flip", "mixup"]
|
||||||
SUPPORTED_TASKS: tuple[YoloTask, ...] = (
|
SUPPORTED_TASKS: tuple[YoloTask, ...] = (
|
||||||
"detect",
|
"detect",
|
||||||
|
|
@ -18,6 +18,7 @@ SUPPORTED_TASKS: tuple[YoloTask, ...] = (
|
||||||
"obb",
|
"obb",
|
||||||
)
|
)
|
||||||
SUPPORTED_AUTO_AUGMENT_POLICIES: tuple[AutoAugmentPolicy, ...] = (
|
SUPPORTED_AUTO_AUGMENT_POLICIES: tuple[AutoAugmentPolicy, ...] = (
|
||||||
|
"none",
|
||||||
"randaugment",
|
"randaugment",
|
||||||
"autoaugment",
|
"autoaugment",
|
||||||
"augmix",
|
"augmix",
|
||||||
|
|
@ -161,7 +162,7 @@ class AugmentationConfig:
|
||||||
"cutmix": self.cutmix,
|
"cutmix": self.cutmix,
|
||||||
"copy_paste": self.copy_paste,
|
"copy_paste": self.copy_paste,
|
||||||
"copy_paste_mode": self.copy_paste_mode,
|
"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,
|
"erasing": self.erasing,
|
||||||
"close_mosaic": self.close_mosaic,
|
"close_mosaic": self.close_mosaic,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -296,6 +296,7 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label for="auto-augment">AutoAugment политика (classify)</label>
|
<label for="auto-augment">AutoAugment политика (classify)</label>
|
||||||
<select id="auto-augment" name="auto-augment">
|
<select id="auto-augment" name="auto-augment">
|
||||||
|
<option value="none">Отключено</option>
|
||||||
<option value="randaugment">RandAugment</option>
|
<option value="randaugment">RandAugment</option>
|
||||||
<option value="autoaugment">AutoAugment</option>
|
<option value="autoaugment">AutoAugment</option>
|
||||||
<option value="augmix">AugMix</option>
|
<option value="augmix">AugMix</option>
|
||||||
|
|
|
||||||
|
|
@ -141,13 +141,15 @@ async function flushPromises() {
|
||||||
element('workers').value = '0';
|
element('workers').value = '0';
|
||||||
element('patience').value = '0';
|
element('patience').value = '0';
|
||||||
element('close-mosaic').value = '0';
|
element('close-mosaic').value = '0';
|
||||||
|
element('auto-augment').value = 'none';
|
||||||
element('config-form').listeners.input();
|
element('config-form').listeners.input();
|
||||||
const savedConfig = JSON.parse(storage.get('draft_config'));
|
const savedConfig = JSON.parse(storage.get('draft_config'));
|
||||||
assert.equal(savedConfig.workers, 0);
|
assert.equal(savedConfig.workers, 0);
|
||||||
assert.equal(savedConfig.patience, 0);
|
assert.equal(savedConfig.patience, 0);
|
||||||
assert.equal(savedConfig.augmentation.close_mosaic, 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];
|
const socket = FakeWebSocket.instances[0];
|
||||||
socket.onmessage({
|
socket.onmessage({
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,28 @@ def test_augmentation_kwargs_are_passed_to_ultralytics() -> None:
|
||||||
assert kwargs["auto_augment"] == "randaugment"
|
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"])
|
@pytest.mark.parametrize("field", ["mosaic", "fliplr", "erasing", "perspective"])
|
||||||
def test_augmentation_probabilities_are_validated(field: str) -> None:
|
def test_augmentation_probabilities_are_validated(field: str) -> None:
|
||||||
augmentation = AugmentationConfig(**{field: 1.1})
|
augmentation = AugmentationConfig(**{field: 1.1})
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue