From d56c3fb8fe6f1d446ecb0e4c049fe9b0c172f3f0 Mon Sep 17 00:00:00 2001 From: Stefan Klut Date: Fri, 1 Dec 2023 17:01:45 +0100 Subject: [PATCH] symlink -> link, move dataset_dict_loader --- core/preprocess.py | 2 +- datasets/dataset.py | 4 +++- datasets/preprocess.py | 2 +- page_xml/output_pageXML.py | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/preprocess.py b/core/preprocess.py index 7503ae9..663eff6 100644 --- a/core/preprocess.py +++ b/core/preprocess.py @@ -66,7 +66,7 @@ def preprocess_datasets( train_output_dir = None if train is not None: train = clean_input_paths(train) - if not all(missing := path.exists() for path in train): + if not all((missing := path).exists() for path in train): raise FileNotFoundError(f"Train File/Folder not found: {missing} does not exist") train_output_dir = output_dir.joinpath("train") diff --git a/datasets/dataset.py b/datasets/dataset.py index 32cc12f..6a2430a 100644 --- a/datasets/dataset.py +++ b/datasets/dataset.py @@ -221,7 +221,9 @@ def register_dataset(path: str | Path, name: str, ignore_label: int = 255) -> Me data = convert_to_paths(path, info["data"]) classes = info["classes"] - DatasetCatalog.register(name=name, func=lambda data=data: dataset_dict_loader(data)) + list_of_dicts = dataset_dict_loader(data) + + DatasetCatalog.register(name=name, func=lambda: list_of_dicts) MetadataCatalog[name] = metadata_from_classes(classes, ignore_label) return MetadataCatalog.get(name) diff --git a/datasets/preprocess.py b/datasets/preprocess.py index 4735bf0..f092aab 100644 --- a/datasets/preprocess.py +++ b/datasets/preprocess.py @@ -314,7 +314,7 @@ def save_image( image_dir.mkdir(parents=True, exist_ok=True) if self.resize_mode == "none": - copy_mode(image_path, out_image_path, mode="symlink") + copy_mode(image_path, out_image_path, mode="link") else: image = load_image_array_from_path(image_path) diff --git a/page_xml/output_pageXML.py b/page_xml/output_pageXML.py index ec93357..9a08ed4 100644 --- a/page_xml/output_pageXML.py +++ b/page_xml/output_pageXML.py @@ -116,7 +116,7 @@ def link_image(self, image_path: Path): raise TypeError("Output dir is None") image_output_path = self.output_dir.joinpath(image_path.name) - copy_mode(image_path, image_output_path, mode="symlink") + copy_mode(image_path, image_output_path, mode="link") def generate_single_page( self,