This repository has been archived by the owner on Dec 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Coco cat training and evaluation (#129)
* Add coco-cat * add coco-cat training pipeline * Move download out of COCO dataloader * change batch size * Change training epoch * update coco yaml * Add train and eval pipeline for coco-cat and synthetic * Add training and evaluation pipeline for Synthetic COCO-cat * remove unnecessary pipelines * revoke previous gcs path * change num of classes * Add Model_Performance_Statistics notebook * add some note * Add USim data training and evaluation pipeline * Add some notes * Modify link * Fix linting issues * Clean up notebook * change session in notebook * update notebook * remove single training pipelines and notebook * Add archive method * make unarchived function private * Add UTs for coco dataloader * fix linting issue Co-authored-by: Bowen Li <[email protected]>
- Loading branch information
1 parent
60a66fc
commit 9357af4
Showing
3 changed files
with
169 additions
and
9 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
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,46 @@ | ||
import os | ||
import tempfile | ||
from pathlib import Path | ||
from unittest.mock import patch | ||
|
||
from pytest import raises | ||
|
||
from datasetinsights.datasets.coco import CocoDetection | ||
from datasetinsights.datasets.exceptions import DatasetNotFoundError | ||
|
||
|
||
def test__is_dataset_files_present(): | ||
with tempfile.TemporaryDirectory() as tmp: | ||
with open(os.path.join(tmp, "coco.json"), "x"): | ||
with open(os.path.join(tmp, "coco.jpg"), "x"): | ||
assert CocoDetection._is_dataset_files_present(tmp) | ||
|
||
with tempfile.TemporaryDirectory() as tmp: | ||
assert not CocoDetection._is_dataset_files_present(tmp) | ||
|
||
|
||
@patch("datasetinsights.datasets.CocoDetection._unarchive_data") | ||
def test__preprocess_dataset(mock_unarchive): | ||
tmp_dir = tempfile.TemporaryDirectory() | ||
tmp_name = tmp_dir.name | ||
split = "train" | ||
|
||
# test no dataset found | ||
with raises(DatasetNotFoundError): | ||
CocoDetection._preprocess_dataset(tmp_name, split) | ||
|
||
# test dataset already exists | ||
with open(os.path.join(tmp_name, "coco.json"), "x"): | ||
with open(os.path.join(tmp_name, "coco.jpg"), "x"): | ||
return_value = CocoDetection._preprocess_dataset(tmp_name, split) | ||
assert return_value == tmp_name | ||
|
||
# test whether it can unarchive data | ||
archive_img_file = Path(tmp_name) / f"{split}2017.zip" | ||
archive_ann_file = Path(tmp_name) / "annotations_trainval2017.zip" | ||
with open(archive_img_file, "x"): | ||
with open(archive_ann_file, "x"): | ||
CocoDetection._preprocess_dataset(tmp_name, split) | ||
assert mock_unarchive.call_count == 2 | ||
|
||
tmp_dir.cleanup() |