Rename dataset (#3)

pull/509/head
Han Chong 2025-01-30 21:26:44 +08:00 committed by GitHub
parent 5917521c34
commit d00d2f5822
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 71 additions and 71 deletions

View File

@ -5,10 +5,10 @@
from .image_net import ImageNet from .image_net import ImageNet
from .image_net_22k import ImageNet22k from .image_net_22k import ImageNet22k
from .image_ship_set_1 import ImageShipSet1 from .image_ship_id import ImageShipID
from .image_ship_set_1_extra import ImageShipSet1Extra from .image_ship_id_extra import ImageShipID_Extra
from .image_ship_set_1_20percent import ImageShipSet1_20P from .image_ship_id_20pct import ImageShipID_20P
from .image_ship_set_1_40percent import ImageShipSet1_40P from .image_ship_id_40pct import ImageShipID_40P
from .image_ship_set_1_60percent import ImageShipSet1_60P from .image_ship_id_60pct import ImageShipID_60P
from .image_ship_set_1_80percent import ImageShipSet1_80P from .image_ship_id_80pct import ImageShipID_80P
from .image_ship_set_2 import ImageShipSet2 from .image_ship_ood import ImageShipOOD

View File

@ -43,14 +43,14 @@ class _Split(Enum):
return class_id, actual_index return class_id, actual_index
class ImageShipSet1(ExtendedVisionDataset): class ImageShipID(ExtendedVisionDataset):
Target = Union[_Target] Target = Union[_Target]
Split = Union[_Split] Split = Union[_Split]
def __init__( def __init__(
self, self,
*, *,
split: "ImageShipSet1.Split", split: "ImageShipID.Split",
root: str, root: str,
extra: str, extra: str,
transforms: Optional[Callable] = None, transforms: Optional[Callable] = None,
@ -66,7 +66,7 @@ class ImageShipSet1(ExtendedVisionDataset):
self._class_names = None self._class_names = None
@property @property
def split(self) -> "ImageShipSet1.Split": def split(self) -> "ImageShipID.Split":
return self._split return self._split
def _get_extra_full_path(self, extra_path: str) -> str: def _get_extra_full_path(self, extra_path: str) -> str:
@ -176,7 +176,7 @@ class ImageShipSet1(ExtendedVisionDataset):
def _dump_entries(self) -> None: def _dump_entries(self) -> None:
split = self.split split = self.split
if split == ImageShipSet1.Split.TEST: if split == ImageShipID.Split.TEST:
dataset = None dataset = None
sample_count = split.length sample_count = split.length
max_class_id_length, max_class_name_length = 0, 0 max_class_id_length, max_class_name_length = 0, 0
@ -208,7 +208,7 @@ class ImageShipSet1(ExtendedVisionDataset):
) )
entries_array = np.empty(sample_count, dtype=dtype) entries_array = np.empty(sample_count, dtype=dtype)
if split == ImageShipSet1.Split.TEST: if split == ImageShipID.Split.TEST:
old_percent = -1 old_percent = -1
for index in range(sample_count): for index in range(sample_count):
percent = 100 * (index + 1) // sample_count percent = 100 * (index + 1) // sample_count
@ -242,7 +242,7 @@ class ImageShipSet1(ExtendedVisionDataset):
def _dump_class_ids_and_names(self) -> None: def _dump_class_ids_and_names(self) -> None:
split = self.split split = self.split
if split == ImageShipSet1.Split.TEST: if split == ImageShipID.Split.TEST:
return return
entries_array = self._load_extra(self._entries_path) entries_array = self._load_extra(self._entries_path)

View File

@ -43,14 +43,14 @@ class _Split(Enum):
return class_id, actual_index return class_id, actual_index
class ImageShipSet1_20P(ExtendedVisionDataset): class ImageShipID_20P(ExtendedVisionDataset):
Target = Union[_Target] Target = Union[_Target]
Split = Union[_Split] Split = Union[_Split]
def __init__( def __init__(
self, self,
*, *,
split: "ImageShipSet1_20P.Split", split: "ImageShipID_20P.Split",
root: str, root: str,
extra: str, extra: str,
transforms: Optional[Callable] = None, transforms: Optional[Callable] = None,
@ -66,7 +66,7 @@ class ImageShipSet1_20P(ExtendedVisionDataset):
self._class_names = None self._class_names = None
@property @property
def split(self) -> "ImageShipSet1_20P.Split": def split(self) -> "ImageShipID_20P.Split":
return self._split return self._split
def _get_extra_full_path(self, extra_path: str) -> str: def _get_extra_full_path(self, extra_path: str) -> str:
@ -176,7 +176,7 @@ class ImageShipSet1_20P(ExtendedVisionDataset):
def _dump_entries(self) -> None: def _dump_entries(self) -> None:
split = self.split split = self.split
if split == ImageShipSet1_20P.Split.TEST: if split == ImageShipID_20P.Split.TEST:
dataset = None dataset = None
sample_count = split.length sample_count = split.length
max_class_id_length, max_class_name_length = 0, 0 max_class_id_length, max_class_name_length = 0, 0
@ -208,7 +208,7 @@ class ImageShipSet1_20P(ExtendedVisionDataset):
) )
entries_array = np.empty(sample_count, dtype=dtype) entries_array = np.empty(sample_count, dtype=dtype)
if split == ImageShipSet1_20P.Split.TEST: if split == ImageShipID_20P.Split.TEST:
old_percent = -1 old_percent = -1
for index in range(sample_count): for index in range(sample_count):
percent = 100 * (index + 1) // sample_count percent = 100 * (index + 1) // sample_count
@ -242,7 +242,7 @@ class ImageShipSet1_20P(ExtendedVisionDataset):
def _dump_class_ids_and_names(self) -> None: def _dump_class_ids_and_names(self) -> None:
split = self.split split = self.split
if split == ImageShipSet1_20P.Split.TEST: if split == ImageShipID_20P.Split.TEST:
return return
entries_array = self._load_extra(self._entries_path) entries_array = self._load_extra(self._entries_path)

View File

@ -43,14 +43,14 @@ class _Split(Enum):
return class_id, actual_index return class_id, actual_index
class ImageShipSet1_40P(ExtendedVisionDataset): class ImageShipID_40P(ExtendedVisionDataset):
Target = Union[_Target] Target = Union[_Target]
Split = Union[_Split] Split = Union[_Split]
def __init__( def __init__(
self, self,
*, *,
split: "ImageShipSet1_40P.Split", split: "ImageShipID_40P.Split",
root: str, root: str,
extra: str, extra: str,
transforms: Optional[Callable] = None, transforms: Optional[Callable] = None,
@ -66,7 +66,7 @@ class ImageShipSet1_40P(ExtendedVisionDataset):
self._class_names = None self._class_names = None
@property @property
def split(self) -> "ImageShipSet1_40P.Split": def split(self) -> "ImageShipID_40P.Split":
return self._split return self._split
def _get_extra_full_path(self, extra_path: str) -> str: def _get_extra_full_path(self, extra_path: str) -> str:
@ -176,7 +176,7 @@ class ImageShipSet1_40P(ExtendedVisionDataset):
def _dump_entries(self) -> None: def _dump_entries(self) -> None:
split = self.split split = self.split
if split == ImageShipSet1_40P.Split.TEST: if split == ImageShipID_40P.Split.TEST:
dataset = None dataset = None
sample_count = split.length sample_count = split.length
max_class_id_length, max_class_name_length = 0, 0 max_class_id_length, max_class_name_length = 0, 0
@ -208,7 +208,7 @@ class ImageShipSet1_40P(ExtendedVisionDataset):
) )
entries_array = np.empty(sample_count, dtype=dtype) entries_array = np.empty(sample_count, dtype=dtype)
if split == ImageShipSet1_40P.Split.TEST: if split == ImageShipID_40P.Split.TEST:
old_percent = -1 old_percent = -1
for index in range(sample_count): for index in range(sample_count):
percent = 100 * (index + 1) // sample_count percent = 100 * (index + 1) // sample_count
@ -242,7 +242,7 @@ class ImageShipSet1_40P(ExtendedVisionDataset):
def _dump_class_ids_and_names(self) -> None: def _dump_class_ids_and_names(self) -> None:
split = self.split split = self.split
if split == ImageShipSet1_40P.Split.TEST: if split == ImageShipID_40P.Split.TEST:
return return
entries_array = self._load_extra(self._entries_path) entries_array = self._load_extra(self._entries_path)

View File

@ -43,14 +43,14 @@ class _Split(Enum):
return class_id, actual_index return class_id, actual_index
class ImageShipSet1_60P(ExtendedVisionDataset): class ImageShipID_60P(ExtendedVisionDataset):
Target = Union[_Target] Target = Union[_Target]
Split = Union[_Split] Split = Union[_Split]
def __init__( def __init__(
self, self,
*, *,
split: "ImageShipSet1_60P.Split", split: "ImageShipID_60P.Split",
root: str, root: str,
extra: str, extra: str,
transforms: Optional[Callable] = None, transforms: Optional[Callable] = None,
@ -66,7 +66,7 @@ class ImageShipSet1_60P(ExtendedVisionDataset):
self._class_names = None self._class_names = None
@property @property
def split(self) -> "ImageShipSet1_60P.Split": def split(self) -> "ImageShipID_60P.Split":
return self._split return self._split
def _get_extra_full_path(self, extra_path: str) -> str: def _get_extra_full_path(self, extra_path: str) -> str:
@ -176,7 +176,7 @@ class ImageShipSet1_60P(ExtendedVisionDataset):
def _dump_entries(self) -> None: def _dump_entries(self) -> None:
split = self.split split = self.split
if split == ImageShipSet1_60P.Split.TEST: if split == ImageShipID_60P.Split.TEST:
dataset = None dataset = None
sample_count = split.length sample_count = split.length
max_class_id_length, max_class_name_length = 0, 0 max_class_id_length, max_class_name_length = 0, 0
@ -208,7 +208,7 @@ class ImageShipSet1_60P(ExtendedVisionDataset):
) )
entries_array = np.empty(sample_count, dtype=dtype) entries_array = np.empty(sample_count, dtype=dtype)
if split == ImageShipSet1_60P.Split.TEST: if split == ImageShipID_60P.Split.TEST:
old_percent = -1 old_percent = -1
for index in range(sample_count): for index in range(sample_count):
percent = 100 * (index + 1) // sample_count percent = 100 * (index + 1) // sample_count
@ -242,7 +242,7 @@ class ImageShipSet1_60P(ExtendedVisionDataset):
def _dump_class_ids_and_names(self) -> None: def _dump_class_ids_and_names(self) -> None:
split = self.split split = self.split
if split == ImageShipSet1_60P.Split.TEST: if split == ImageShipID_60P.Split.TEST:
return return
entries_array = self._load_extra(self._entries_path) entries_array = self._load_extra(self._entries_path)

View File

@ -43,14 +43,14 @@ class _Split(Enum):
return class_id, actual_index return class_id, actual_index
class ImageShipSet1_80P(ExtendedVisionDataset): class ImageShipID_80P(ExtendedVisionDataset):
Target = Union[_Target] Target = Union[_Target]
Split = Union[_Split] Split = Union[_Split]
def __init__( def __init__(
self, self,
*, *,
split: "ImageShipSet1_80P.Split", split: "ImageShipID_80P.Split",
root: str, root: str,
extra: str, extra: str,
transforms: Optional[Callable] = None, transforms: Optional[Callable] = None,
@ -66,7 +66,7 @@ class ImageShipSet1_80P(ExtendedVisionDataset):
self._class_names = None self._class_names = None
@property @property
def split(self) -> "ImageShipSet1_80P.Split": def split(self) -> "ImageShipID_80P.Split":
return self._split return self._split
def _get_extra_full_path(self, extra_path: str) -> str: def _get_extra_full_path(self, extra_path: str) -> str:
@ -176,7 +176,7 @@ class ImageShipSet1_80P(ExtendedVisionDataset):
def _dump_entries(self) -> None: def _dump_entries(self) -> None:
split = self.split split = self.split
if split == ImageShipSet1_80P.Split.TEST: if split == ImageShipID_80P.Split.TEST:
dataset = None dataset = None
sample_count = split.length sample_count = split.length
max_class_id_length, max_class_name_length = 0, 0 max_class_id_length, max_class_name_length = 0, 0
@ -208,7 +208,7 @@ class ImageShipSet1_80P(ExtendedVisionDataset):
) )
entries_array = np.empty(sample_count, dtype=dtype) entries_array = np.empty(sample_count, dtype=dtype)
if split == ImageShipSet1_80P.Split.TEST: if split == ImageShipID_80P.Split.TEST:
old_percent = -1 old_percent = -1
for index in range(sample_count): for index in range(sample_count):
percent = 100 * (index + 1) // sample_count percent = 100 * (index + 1) // sample_count
@ -242,7 +242,7 @@ class ImageShipSet1_80P(ExtendedVisionDataset):
def _dump_class_ids_and_names(self) -> None: def _dump_class_ids_and_names(self) -> None:
split = self.split split = self.split
if split == ImageShipSet1_80P.Split.TEST: if split == ImageShipID_80P.Split.TEST:
return return
entries_array = self._load_extra(self._entries_path) entries_array = self._load_extra(self._entries_path)

View File

@ -43,14 +43,14 @@ class _Split(Enum):
return class_id, actual_index return class_id, actual_index
class ImageShipSet1Extra(ExtendedVisionDataset): class ImageShipID_Extra(ExtendedVisionDataset):
Target = Union[_Target] Target = Union[_Target]
Split = Union[_Split] Split = Union[_Split]
def __init__( def __init__(
self, self,
*, *,
split: "ImageShipSet1Extra.Split", split: "ImageShipID_Extra.Split",
root: str, root: str,
extra: str, extra: str,
transforms: Optional[Callable] = None, transforms: Optional[Callable] = None,
@ -66,7 +66,7 @@ class ImageShipSet1Extra(ExtendedVisionDataset):
self._class_names = None self._class_names = None
@property @property
def split(self) -> "ImageShipSet1Extra.Split": def split(self) -> "ImageShipID_Extra.Split":
return self._split return self._split
def _get_extra_full_path(self, extra_path: str) -> str: def _get_extra_full_path(self, extra_path: str) -> str:
@ -176,7 +176,7 @@ class ImageShipSet1Extra(ExtendedVisionDataset):
def _dump_entries(self) -> None: def _dump_entries(self) -> None:
split = self.split split = self.split
if split == ImageShipSet1Extra.Split.TEST: if split == ImageShipID_Extra.Split.TEST:
dataset = None dataset = None
sample_count = split.length sample_count = split.length
max_class_id_length, max_class_name_length = 0, 0 max_class_id_length, max_class_name_length = 0, 0
@ -208,7 +208,7 @@ class ImageShipSet1Extra(ExtendedVisionDataset):
) )
entries_array = np.empty(sample_count, dtype=dtype) entries_array = np.empty(sample_count, dtype=dtype)
if split == ImageShipSet1Extra.Split.TEST: if split == ImageShipID_Extra.Split.TEST:
old_percent = -1 old_percent = -1
for index in range(sample_count): for index in range(sample_count):
percent = 100 * (index + 1) // sample_count percent = 100 * (index + 1) // sample_count
@ -242,7 +242,7 @@ class ImageShipSet1Extra(ExtendedVisionDataset):
def _dump_class_ids_and_names(self) -> None: def _dump_class_ids_and_names(self) -> None:
split = self.split split = self.split
if split == ImageShipSet1Extra.Split.TEST: if split == ImageShipID_Extra.Split.TEST:
return return
entries_array = self._load_extra(self._entries_path) entries_array = self._load_extra(self._entries_path)

View File

@ -43,14 +43,14 @@ class _Split(Enum):
return class_id, actual_index return class_id, actual_index
class ImageShipSet2(ExtendedVisionDataset): class ImageShipOOD(ExtendedVisionDataset):
Target = Union[_Target] Target = Union[_Target]
Split = Union[_Split] Split = Union[_Split]
def __init__( def __init__(
self, self,
*, *,
split: "ImageShipSet2.Split", split: "ImageShipOOD.Split",
root: str, root: str,
extra: str, extra: str,
transforms: Optional[Callable] = None, transforms: Optional[Callable] = None,
@ -66,7 +66,7 @@ class ImageShipSet2(ExtendedVisionDataset):
self._class_names = None self._class_names = None
@property @property
def split(self) -> "ImageShipSet2.Split": def split(self) -> "ImageShipOOD.Split":
return self._split return self._split
def _get_extra_full_path(self, extra_path: str) -> str: def _get_extra_full_path(self, extra_path: str) -> str:
@ -176,7 +176,7 @@ class ImageShipSet2(ExtendedVisionDataset):
def _dump_entries(self) -> None: def _dump_entries(self) -> None:
split = self.split split = self.split
if split == ImageShipSet2.Split.TEST: if split == ImageShipOOD.Split.TEST:
dataset = None dataset = None
sample_count = split.length sample_count = split.length
max_class_id_length, max_class_name_length = 0, 0 max_class_id_length, max_class_name_length = 0, 0
@ -208,7 +208,7 @@ class ImageShipSet2(ExtendedVisionDataset):
) )
entries_array = np.empty(sample_count, dtype=dtype) entries_array = np.empty(sample_count, dtype=dtype)
if split == ImageShipSet2.Split.TEST: if split == ImageShipOOD.Split.TEST:
old_percent = -1 old_percent = -1
for index in range(sample_count): for index in range(sample_count):
percent = 100 * (index + 1) // sample_count percent = 100 * (index + 1) // sample_count
@ -242,7 +242,7 @@ class ImageShipSet2(ExtendedVisionDataset):
def _dump_class_ids_and_names(self) -> None: def _dump_class_ids_and_names(self) -> None:
split = self.split split = self.split
if split == ImageShipSet2.Split.TEST: if split == ImageShipOOD.Split.TEST:
return return
entries_array = self._load_extra(self._entries_path) entries_array = self._load_extra(self._entries_path)

View File

@ -10,7 +10,7 @@ from typing import Any, Callable, List, Optional, TypeVar
import torch import torch
from torch.utils.data import Sampler from torch.utils.data import Sampler
from .datasets import ImageNet, ImageNet22k, ImageShipSet1, ImageShipSet1Extra, ImageShipSet1_20P, ImageShipSet1_40P, ImageShipSet1_60P, ImageShipSet1_80P, ImageShipSet2 from .datasets import ImageNet, ImageNet22k, ImageShipID, ImageShipID_Extra, ImageShipID_20P, ImageShipID_40P, ImageShipID_60P, ImageShipID_80P, ImageShipOOD
from .samplers import EpochSampler, InfiniteSampler, ShardedInfiniteSampler from .samplers import EpochSampler, InfiniteSampler, ShardedInfiniteSampler
@ -58,34 +58,34 @@ def _parse_dataset_str(dataset_str: str):
kwargs["split"] = ImageNet.Split[kwargs["split"]] kwargs["split"] = ImageNet.Split[kwargs["split"]]
elif name == "ImageNet22k": elif name == "ImageNet22k":
class_ = ImageNet22k class_ = ImageNet22k
elif name == "ImageShipSet1": elif name == "ImageShipID":
class_ = ImageShipSet1 class_ = ImageShipID
if "split" in kwargs: if "split" in kwargs:
kwargs["split"] = ImageShipSet1.Split[kwargs["split"]] kwargs["split"] = ImageShipID.Split[kwargs["split"]]
elif name == "ImageShipSet1Extra": elif name == "ImageShipIDExtra":
class_ = ImageShipSet1Extra class_ = ImageShipID_Extra
if "split" in kwargs: if "split" in kwargs:
kwargs["split"] = ImageShipSet1Extra.Split[kwargs["split"]] kwargs["split"] = ImageShipID_Extra.Split[kwargs["split"]]
elif name == "ImageShipSet1_20P": elif name == "ImageShipID_20P":
class_ = ImageShipSet1_20P class_ = ImageShipID_20P
if "split" in kwargs: if "split" in kwargs:
kwargs["split"] = ImageShipSet1_20P.Split[kwargs["split"]] kwargs["split"] = ImageShipID_20P.Split[kwargs["split"]]
elif name == "ImageShipSet1_40P": elif name == "ImageShipID_40P":
class_ = ImageShipSet1_40P class_ = ImageShipID_40P
if "split" in kwargs: if "split" in kwargs:
kwargs["split"] = ImageShipSet1_40P.Split[kwargs["split"]] kwargs["split"] = ImageShipID_40P.Split[kwargs["split"]]
elif name == "ImageShipSet1_60P": elif name == "ImageShipID_60P":
class_ = ImageShipSet1_60P class_ = ImageShipID_60P
if "split" in kwargs: if "split" in kwargs:
kwargs["split"] = ImageShipSet1_60P.Split[kwargs["split"]] kwargs["split"] = ImageShipID_60P.Split[kwargs["split"]]
elif name == "ImageShipSet1_80P": elif name == "ImageShipID_80P":
class_ = ImageShipSet1_80P class_ = ImageShipID_80P
if "split" in kwargs: if "split" in kwargs:
kwargs["split"] = ImageShipSet1_80P.Split[kwargs["split"]] kwargs["split"] = ImageShipID_80P.Split[kwargs["split"]]
elif name == "ImageShipSet2": elif name == "ImageShipOOD":
class_ = ImageShipSet2 class_ = ImageShipOOD
if "split" in kwargs: if "split" in kwargs:
kwargs["split"] = ImageShipSet2.Split[kwargs["split"]] kwargs["split"] = ImageShipOOD.Split[kwargs["split"]]
else: else:
raise ValueError(f'Unsupported dataset "{name}"') raise ValueError(f'Unsupported dataset "{name}"')