Skip to content

Commit

Permalink
fix: add default values when loading lr metadata from json (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
frederik-encord authored Mar 21, 2023
1 parent 292bfaa commit 4155120
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/encord_active/lib/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,21 @@ def __load_label_row_meta(self, subset_size: Optional[int]):
label_row_meta_file_path = self.file_structure.label_row_meta
if not label_row_meta_file_path.exists():
raise FileNotFoundError(f"Expected file `label_row_meta.json` at {label_row_meta_file_path.parent}")

def populate_defaults(lr_dict: dict):
img_dir = self.file_structure.label_row_structure(lr_dict["label_hash"]).images_dir
image_pth = next((i.as_posix() for i in img_dir.iterdir() if i.is_file()), None) or ""

return {
"data_link": image_pth,
"dataset_title": "",
"is_shadow_data": False,
"number_of_frames": 1,
**lr_dict,
}

self.label_row_metas = {
lr_hash: LabelRowMetadata.from_dict(lr_meta)
lr_hash: LabelRowMetadata.from_dict(populate_defaults(lr_meta))
for lr_hash, lr_meta in itertools.islice(
json.loads(label_row_meta_file_path.read_text(encoding="utf-8")).items(), subset_size
)
Expand Down

0 comments on commit 4155120

Please sign in to comment.