Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 13 additions & 23 deletions tests/sparseml/pytorch/datasets/detection/test_voc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import logging
from urllib.error import URLError

import pytest
import torch
Expand All @@ -32,40 +33,29 @@ def _validate_voc(dataset: Dataset, size: int):
assert len(item[1]) == 2


@pytest.mark.skipif(
os.getenv("NM_ML_SKIP_PYTORCH_TESTS", False),
reason="Skipping pytorch tests",
)
@pytest.mark.skipif(
version.parse(torch.__version__) < version.parse("1.2"),
reason="Must install pytorch version 1.2 or greater",
)
@pytest.mark.skipif(
os.getenv("NM_ML_SKIP_DATASET_TESTS", False),
reason="Skipping dataset tests",
)
def test_voc_detection():
train_dataset = VOCDetectionDataset(train=True)
_validate_voc(train_dataset, 300)
try:
train_dataset = VOCDetectionDataset(train=True)
_validate_voc(train_dataset, 300)

val_dataset = VOCDetectionDataset(train=False)
_validate_voc(val_dataset, 300)
val_dataset = VOCDetectionDataset(train=False)
_validate_voc(val_dataset, 300)

reg_dataset = DatasetRegistry.create("voc_det", train=False)
_validate_voc(reg_dataset, 300)
reg_dataset = DatasetRegistry.create("voc_det", train=False)
_validate_voc(reg_dataset, 300)
except URLError as err:
# handle case for VOC server being down,
# we should not fail our tests on an upstream we can't control
logging.warning(f"Skipped VOC tests because of URLError: {err}")


@pytest.mark.skipif(
os.getenv("NM_ML_SKIP_PYTORCH_TESTS", False),
reason="Skipping pytorch tests",
)
@pytest.mark.skipif(
version.parse(torch.__version__) < version.parse("1.2"),
reason="Must install pytorch version 1.2 or greater",
)
@pytest.mark.skipif(
os.getenv("NM_ML_SKIP_DATASET_TESTS", False),
reason="Skipping dataset tests",
)
def test_voc_segmentation():
pass