From 4855d9fa2e0cfda3734a59e2f21a75b2bcd907c1 Mon Sep 17 00:00:00 2001 From: Antoine DESRUET Date: Fri, 10 Jun 2022 14:52:23 +0200 Subject: [PATCH] fix: load image from local --- setup.py | 2 +- src/CVAT/utils.py | 8 +++++++- src/main.py | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 80def23..4835aff 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="CVAT wrapper", - version="0.0.12", + version="0.0.13", author="antwxne", author_email="antoine.desruet@epitech.eu", description="Python wrapper for CVAT API", diff --git a/src/CVAT/utils.py b/src/CVAT/utils.py index 54a6b84..9f48169 100644 --- a/src/CVAT/utils.py +++ b/src/CVAT/utils.py @@ -68,7 +68,13 @@ def image_content_from_kili_prediction(prediction: list[dict], directory: str) - """ paths: list[str] = [] current_files: list[str] = get_files_from_path(directory) - files_without_extension: list[str] = [file.split(".")[0] for file in current_files] + files_without_extension: list[str] = [ ] + for file in current_files: + splitted:list[str] = file.split(".") + if splitted[0] != "": + files_without_extension.append(splitted[0]) + else: + files_without_extension.append("." + splitted[1]) print(f'all files {files_without_extension}', file=sys.stderr) for elem in tqdm(prediction, unit="Image"): path: str = f'{directory}/{elem["externalId"]}' diff --git a/src/main.py b/src/main.py index 9b59c75..ba44ef7 100644 --- a/src/main.py +++ b/src/main.py @@ -16,7 +16,7 @@ if __name__ == "__main__": # API.create_user("oui", "oui@gmail.com", "kgjhagkjlhlaegkj", "aaa", "aaaa") prediction_json: list[dict] = CVAT.get_json_from_file("./foodvisor_valid_12_2021_Fromages_gmd_predictions.json") - directory: str = "data/Images/Fromages" + directory: str = "./data/Images/Fromages" # interface: dict = CVAT.get_json_from_file("../interface_foodvisor.json") images_path: list[str] = image_content_from_kili_prediction(prediction_json, directory) # project_id: int = API.create_project("TEST_API2", interface=interface)