From 870e0ea52e9e1b0c44d7eed694953f0268bc7655 Mon Sep 17 00:00:00 2001 From: GoldenAnpu Date: Tue, 17 Dec 2024 19:29:37 +0100 Subject: [PATCH] Improved Project Downloading --- config.json | 54 ++++++++++++++++++++------------------------ dev_requirements.txt | 2 +- local.env | 6 ++--- src/main.py | 5 ++-- 4 files changed, 31 insertions(+), 36 deletions(-) diff --git a/config.json b/config.json index 35a9a19..6f7629e 100644 --- a/config.json +++ b/config.json @@ -1,31 +1,25 @@ { - "name": "Export to Supervisely format", - "type": "app", - "version": "2.0.0", - "categories": [ - "images", - "export" - ], - "description": "images and JSON annotations", - "docker_image": "supervisely/import-export:6.73.162", - "instance_version": "6.11.8", - "main_script": "src/main.py", - "modal_template": "src/modal.html", - "modal_template_state": { - "download": "all", - "fixExtension": false - }, - "task_location": "workspace_tasks", - "isolate": true, - "headless": true, - "icon": "https://i.imgur.com/1hqGMyg.png", - "icon_background": "#FFFFFF", - "context_menu": { - "target": [ - "images_project", - "images_dataset" - ], - "context_root": "Download as" - }, - "poster": "https://user-images.githubusercontent.com/106374579/186665737-ec3da9cc-193f-43ee-85db-a6f802b2dfe4.png" -} \ No newline at end of file + "name": "Export to Supervisely format", + "type": "app", + "version": "2.0.0", + "categories": ["images", "export"], + "description": "images and JSON annotations", + "docker_image": "supervisely/import-export:6.73.256", + "instance_version": "6.12.12", + "main_script": "src/main.py", + "modal_template": "src/modal.html", + "modal_template_state": { + "download": "all", + "fixExtension": false + }, + "task_location": "workspace_tasks", + "isolate": true, + "headless": true, + "icon": "https://i.imgur.com/1hqGMyg.png", + "icon_background": "#FFFFFF", + "context_menu": { + "target": ["images_project", "images_dataset"], + "context_root": "Download as" + }, + "poster": "https://user-images.githubusercontent.com/106374579/186665737-ec3da9cc-193f-43ee-85db-a6f802b2dfe4.png" +} diff --git a/dev_requirements.txt b/dev_requirements.txt index 5d6a7a6..5aadc50 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1 +1 @@ -supervisely==6.73.162 \ No newline at end of file +supervisely==6.73.256 \ No newline at end of file diff --git a/local.env b/local.env index d2be3f1..8b85c38 100644 --- a/local.env +++ b/local.env @@ -1,6 +1,6 @@ -TEAM_ID = 448 -WORKSPACE_ID = 690 -PROJECT_ID = 35637 +TEAM_ID = 84010 +WORKSPACE_ID = 98037 +PROJECT_ID = 329689 modal.state.download=all modal.state.fixExtension=true # DATASET_ID = \ No newline at end of file diff --git a/src/main.py b/src/main.py index f156729..ebfafd3 100644 --- a/src/main.py +++ b/src/main.py @@ -1,6 +1,7 @@ import os from distutils import util +from supervisely.project.download import download_async_or_sync import supervisely as sly from dotenv import load_dotenv from supervisely.api.module_api import ApiField @@ -121,16 +122,16 @@ def download(project: sly.Project) -> str: sly.logger.info(f"Starting download of project {project.name} to {download_dir}...") - sly.Project.download( + download_async_or_sync( api, project_id, dest_dir=download_dir, dataset_ids=dataset_ids, log_progress=True, - batch_size=batch_size, save_image_meta=True, save_images=save_images, ) + meta_path = os.path.join(download_dir, "meta.json") meta = sly.ProjectMeta.from_json(sly.json.load_json_file(meta_path)) if any(obj_cls.geometry_type == sly.Cuboid2d for obj_cls in meta.obj_classes):