-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
184 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import os | ||
|
||
import datasets as ds | ||
import pytest | ||
|
||
|
||
@pytest.mark.skipif( | ||
condition=bool(os.environ.get("CI", False)), | ||
reason=( | ||
"Because this loading script downloads a large dataset, " | ||
"we will skip running it on CI." | ||
), | ||
) | ||
@pytest.mark.parametrize( | ||
argnames=( | ||
"dataset_year", | ||
"coco_task", | ||
"expected_num_train", | ||
"expected_num_validation", | ||
), | ||
argvalues=( | ||
(2014, "captions", 82783, 40504), | ||
(2017, "captions", 118287, 5000), | ||
), | ||
) | ||
def test_load_caption_dataset( | ||
dataset_path: str, | ||
dataset_year: int, | ||
coco_task: str, | ||
expected_num_train: int, | ||
expected_num_validation: int, | ||
repo_id: str, | ||
): | ||
dataset = ds.load_dataset( | ||
path=dataset_path, | ||
year=dataset_year, | ||
coco_task=coco_task, | ||
) | ||
assert isinstance(dataset, ds.DatasetDict) | ||
|
||
assert dataset["train"].num_rows == expected_num_train | ||
assert dataset["validation"].num_rows == expected_num_validation | ||
|
||
dataset.push_to_hub( | ||
repo_id=repo_id, | ||
config_name=f"year={dataset_year}_task={coco_task}", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
|
||
import datasets as ds | ||
import pytest | ||
|
||
|
||
@pytest.mark.skipif( | ||
condition=bool(os.environ.get("CI", False)), | ||
reason=( | ||
"Because this loading script downloads a large dataset, " | ||
"we will skip running it on CI." | ||
), | ||
) | ||
@pytest.mark.parametrize( | ||
argnames="decode_rle,", | ||
argvalues=( | ||
True, | ||
False, | ||
), | ||
) | ||
@pytest.mark.parametrize( | ||
argnames=( | ||
"dataset_year", | ||
"coco_task", | ||
"expected_num_train", | ||
"expected_num_validation", | ||
), | ||
argvalues=( | ||
(2014, "instances", 82081, 40137), | ||
(2017, "instances", 117266, 4952), | ||
), | ||
) | ||
def test_load_instances_dataset( | ||
dataset_path: str, | ||
dataset_year: int, | ||
coco_task: str, | ||
decode_rle: bool, | ||
expected_num_train: int, | ||
expected_num_validation: int, | ||
repo_id: str, | ||
): | ||
dataset = ds.load_dataset( | ||
path=dataset_path, | ||
year=dataset_year, | ||
coco_task=coco_task, | ||
decode_rle=decode_rle, | ||
) | ||
assert isinstance(dataset, ds.DatasetDict) | ||
|
||
assert dataset["train"].num_rows == expected_num_train | ||
assert dataset["validation"].num_rows == expected_num_validation | ||
|
||
dataset.push_to_hub( | ||
repo_id=repo_id, | ||
config_name=f"year={dataset_year}_task={coco_task}_decode-rle={decode_rle}", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
|
||
import datasets as ds | ||
import pytest | ||
|
||
|
||
@pytest.mark.skipif( | ||
condition=bool(os.environ.get("CI", False)), | ||
reason=( | ||
"Because this loading script downloads a large dataset, " | ||
"we will skip running it on CI." | ||
), | ||
) | ||
@pytest.mark.parametrize( | ||
argnames="decode_rle,", | ||
argvalues=( | ||
True, | ||
False, | ||
), | ||
) | ||
@pytest.mark.parametrize( | ||
argnames=( | ||
"dataset_year", | ||
"coco_task", | ||
"expected_num_train", | ||
"expected_num_validation", | ||
), | ||
argvalues=( | ||
(2014, "person-keypoints", 45174, 21634), | ||
(2017, "person-keypoints", 64115, 2693), | ||
), | ||
) | ||
def test_load_keypoints_dataset( | ||
dataset_path: str, | ||
dataset_year: int, | ||
coco_task: str, | ||
decode_rle: bool, | ||
expected_num_train: int, | ||
expected_num_validation: int, | ||
repo_id: str, | ||
): | ||
dataset = ds.load_dataset( | ||
path=dataset_path, | ||
year=dataset_year, | ||
coco_task=coco_task, | ||
decode_rle=decode_rle, | ||
) | ||
assert isinstance(dataset, ds.DatasetDict) | ||
|
||
assert dataset["train"].num_rows == expected_num_train | ||
assert dataset["validation"].num_rows == expected_num_validation | ||
|
||
dataset.push_to_hub( | ||
repo_id=repo_id, | ||
config_name=f"year={dataset_year}_task={coco_task}_decode-rle={decode_rle}", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,6 @@ | ||
import os | ||
|
||
import datasets as ds | ||
import pytest | ||
|
||
from MSCOCO import CATEGORIES, SUPER_CATEGORIES | ||
|
||
|
||
@pytest.fixture | ||
def dataset_path() -> str: | ||
return "MSCOCO.py" | ||
|
||
|
||
@pytest.mark.skipif( | ||
condition=bool(os.environ.get("CI", False)), | ||
reason=( | ||
"Because this loading script downloads a large dataset, " | ||
"we will skip running it on CI." | ||
), | ||
) | ||
@pytest.mark.parametrize( | ||
argnames="decode_rle,", | ||
argvalues=( | ||
True, | ||
False, | ||
), | ||
) | ||
@pytest.mark.parametrize( | ||
argnames=( | ||
"dataset_year", | ||
"coco_task", | ||
"expected_num_train", | ||
"expected_num_validation", | ||
), | ||
argvalues=( | ||
(2014, "captions", 82783, 40504), | ||
(2017, "captions", 118287, 5000), | ||
(2014, "instances", 82081, 40137), | ||
(2017, "instances", 117266, 4952), | ||
(2014, "person_keypoints", 45174, 21634), | ||
(2017, "person_keypoints", 64115, 2693), | ||
), | ||
) | ||
def test_load_dataset( | ||
dataset_path: str, | ||
dataset_year: int, | ||
coco_task: str, | ||
decode_rle: bool, | ||
expected_num_train: int, | ||
expected_num_validation: int, | ||
): | ||
dataset = ds.load_dataset( | ||
path=dataset_path, | ||
year=dataset_year, | ||
coco_task=coco_task, | ||
decode_rle=decode_rle, | ||
) | ||
assert dataset["train"].num_rows == expected_num_train | ||
assert dataset["validation"].num_rows == expected_num_validation | ||
|
||
|
||
def test_consts(): | ||
assert len(CATEGORIES) == 80 | ||
assert len(SUPER_CATEGORIES) == 12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def org_name() -> str: | ||
return "shunk031" | ||
|
||
|
||
@pytest.fixture | ||
def dataset_name() -> str: | ||
return "MSCOCO" | ||
|
||
|
||
@pytest.fixture | ||
def dataset_path(dataset_name: str) -> str: | ||
return f"{dataset_name}.py" | ||
|
||
|
||
@pytest.fixture | ||
def repo_id(org_name: str, dataset_name: str) -> str: | ||
return f"{org_name}/{dataset_name}" |