LabelClsDataInfoListing(
data_location,
sub_dir,
label_suffix=".json",
image_suffixes=None,
)
Bases: DataInfoListing
Lists all consistent clsdata in one folder and returns a list of data infos
Init method of LabelClsDataInfoListing
Source code in niceml/data/datainfolistings/clsdatainfolisting.py
| def __init__(
self,
data_location: Union[dict, LocationConfig],
sub_dir: str,
label_suffix: str = ".json",
image_suffixes: Optional[List[str]] = None,
):
"""Init method of LabelClsDataInfoListing"""
self.sub_dir = sub_dir
self.data_location = data_location
self.label_suffix = label_suffix
self.image_suffixes = image_suffixes or [".png", ".jpg", ".jpeg"]
|
Functions
list
Lists all data infos
Source code in niceml/data/datainfolistings/clsdatainfolisting.py
| def list(self, data_description: DataDescription) -> List[ClsDataInfo]:
"""Lists all data infos"""
output_data_description: OutputVectorDataDescription = check_instance(
data_description, OutputVectorDataDescription
)
if len(self.sub_dir) > 0:
location = join_location_w_path(self.data_location, self.sub_dir)
else:
location = self.data_location
class_names = output_data_description.get_output_entry_names()
class_count = len(class_names)
data_info_list = list_data(
class_count=class_count,
class_names=class_names,
location=location,
label_suffix=self.label_suffix,
image_suffixes=self.image_suffixes,
use_empty_images=False,
)
new_data_info_list = []
cur_data_info: ObjDetDataInfo
for cur_data_info in data_info_list:
cur_cls_names = list({x.class_name for x in cur_data_info.labels})
cur_class_indexes = output_data_description.get_index_for_name(
cur_cls_names
)
new_data_info = ClsDataInfo(
identifier=cur_data_info.get_identifier(),
image_location=cur_data_info.image_location,
class_name=cur_cls_names,
class_idx=cur_class_indexes,
)
new_data_info_list.append(new_data_info)
return new_data_info_list
|