list_data(
class_count,
class_names,
location,
label_suffix,
image_suffixes,
use_empty_images,
)
Lists all consistent objdetdata in one folder and returns datainfolist
Source code in niceml/data/datainfolistings/objdetdatainfolisting.py
| def list_data(
class_count: int,
class_names: List[str],
location: Union[dict, LocationConfig],
label_suffix: str,
image_suffixes: List[str],
use_empty_images: bool,
) -> List[ObjDetDataInfo]:
"""Lists all consistent objdetdata in one folder and returns datainfolist"""
with open_location(location) as (data_fs, data_path):
all_files = list_dir(data_path, file_system=data_fs)
label_file_set = set(
splitext(x)[0] for x in all_files if splitext(x)[1] == label_suffix
)
image_files = [
file
for file in all_files
if splitext(file)[1] in image_suffixes
and splitext(file)[0] in label_file_set
]
data_info_list: List[ObjDetDataInfo] = []
for cur_img_file in image_files:
data = read_json(
join(data_path, splitext(cur_img_file)[0]) + label_suffix,
file_system=data_fs,
)
image_label: ObjDetImageLabel = ObjDetImageLabel(**data)
# pylint: disable=use-dict-literal
labels = [
ObjDetInstanceLabel(
**{
**asdict(lbl),
**dict(class_index=class_names.index(lbl.class_name)),
}
)
for lbl in image_label.labels
if lbl.class_name in class_names
]
if use_empty_images or len(labels) > 0:
cur_data_info = ObjDetDataInfo(
image_location=join_location_w_path(location, cur_img_file),
class_count_in_dataset=class_count,
labels=labels,
)
data_info_list.append(cur_data_info)
return data_info_list
|