-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from supervisely-ecosystem/download-async
Improved Images Downloading
- Loading branch information
Showing
8 changed files
with
92 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,25 @@ | ||
{ | ||
"name": "Convert Supervisely to YOLO v5 format", | ||
"type": "app", | ||
"version": "2.0.0", | ||
"categories": [ | ||
"images", | ||
"export" | ||
], | ||
"description": "Transform project to YOLO v5 format and prepares tar archive for download", | ||
"docker_image": "supervisely/import-export:6.73.162", | ||
"instance_version": "6.11.8", | ||
"main_script": "src/convert_sly_to_yolov5.py", | ||
"modal_template": "src/modal.html", | ||
"modal_template_state": { | ||
"processShapes": "skip" | ||
}, | ||
"gui_template": "src/gui.html", | ||
"task_location": "workspace_tasks", | ||
"isolate": true, | ||
"headless": true, | ||
"icon": "https://i.imgur.com/pz3eSzx.png", | ||
"icon_background": "#FFFFFF", | ||
"context_menu": { | ||
"target": [ | ||
"images_project" | ||
], | ||
"context_root": "Download as" | ||
}, | ||
"poster": "https://user-images.githubusercontent.com/106374579/183683758-89476d80-de3f-424f-9bfa-f1562703a168.png" | ||
} | ||
"name": "Convert Supervisely to YOLO v5 format", | ||
"type": "app", | ||
"version": "2.0.0", | ||
"categories": ["images", "export"], | ||
"description": "Transform project to YOLO v5 format and prepares tar archive for download", | ||
"docker_image": "supervisely/import-export:6.73.256", | ||
"instance_version": "6.12.12", | ||
"main_script": "src/convert_sly_to_yolov5.py", | ||
"modal_template": "src/modal.html", | ||
"modal_template_state": { | ||
"processShapes": "skip" | ||
}, | ||
"gui_template": "src/gui.html", | ||
"task_location": "workspace_tasks", | ||
"isolate": true, | ||
"headless": true, | ||
"icon": "https://i.imgur.com/pz3eSzx.png", | ||
"icon_background": "#FFFFFF", | ||
"context_menu": { | ||
"target": ["images_project"], | ||
"context_root": "Download as" | ||
}, | ||
"poster": "https://user-images.githubusercontent.com/106374579/183683758-89476d80-de3f-424f-9bfa-f1562703a168.png" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
supervisely==6.73.162 | ||
supervisely==6.73.256 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
TEAM_ID = 448 | ||
WORKSPACE_ID = 690 | ||
PROJECT_ID = 35637 | ||
# TEAM_ID = 448 | ||
# WORKSPACE_ID = 690 | ||
# PROJECT_ID = 35637 | ||
|
||
TEAM_ID = 431 | ||
WORKSPACE_ID = 1019 | ||
PROJECT_ID = 40721 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,28 @@ | ||
import supervisely as sly | ||
|
||
|
||
def check_compatibility(func): | ||
def wrapper(self, *args, **kwargs): | ||
if self.is_compatible is None: | ||
try: | ||
self.is_compatible = self.check_instance_ver_compatibility() | ||
except Exception as e: | ||
sly.logger.error( | ||
"Can not check compatibility with Supervisely instance. " | ||
f"Workflow features will be disabled. Error: {repr(e)}" | ||
) | ||
self.is_compatible = False | ||
if not self.is_compatible: | ||
return | ||
return func(self, *args, **kwargs) | ||
|
||
return wrapper | ||
|
||
|
||
class Workflow: | ||
def __init__(self, api: sly.Api, min_instance_version: str = None): | ||
self.is_compatible = None | ||
self.api = api | ||
self._min_instance_version = ( | ||
"6.9.31" if min_instance_version is None else min_instance_version | ||
) | ||
|
||
def check_instance_ver_compatibility(self): | ||
if not self.api.is_version_supported(self._min_instance_version): | ||
sly.logger.info( | ||
f"Supervisely instance version {self.api.instance_version} does not support workflow features." | ||
) | ||
if not sly.is_community(): | ||
sly.logger.info( | ||
f"To use them, please update your instance to version {self._min_instance_version} or higher." | ||
) | ||
return False | ||
return True | ||
|
||
@check_compatibility | ||
def add_input(self, project_id: int): | ||
self.api.app.workflow.add_input_project(project_id) | ||
sly.logger.debug(f"Workflow: Input project - {project_id}") | ||
|
||
@check_compatibility | ||
def add_output(self, file_info: sly.api.file_api.FileInfo): | ||
try: | ||
meta = { | ||
"customRelationSettings": { | ||
"icon": { | ||
"icon": "zmdi-archive", | ||
"color": "#33c94c", | ||
"backgroundColor": "#d9f7e4", | ||
}, | ||
"title": f"<h4>{file_info.name}</h4>", | ||
"mainLink": { | ||
"url": f"/files/{file_info.id}/true/?teamId={file_info.team_id}", | ||
"title": "Download", | ||
}, | ||
} | ||
def add_input(api: sly.Api, project_id: int): | ||
api.app.workflow.add_input_project(project_id) | ||
sly.logger.debug(f"Workflow: Input project - {project_id}") | ||
|
||
|
||
def add_output(api: sly.Api, file_info: sly.api.file_api.FileInfo): | ||
try: | ||
meta = { | ||
"customRelationSettings": { | ||
"icon": { | ||
"icon": "zmdi-archive", | ||
"color": "#33c94c", | ||
"backgroundColor": "#d9f7e4", | ||
}, | ||
"title": f"<h4>{file_info.name}</h4>", | ||
"mainLink": { | ||
"url": f"/files/{file_info.id}/true/?teamId={file_info.team_id}", | ||
"title": "Download", | ||
}, | ||
} | ||
self.api.app.workflow.add_output_file(file_info, meta=meta) | ||
sly.logger.debug(f"Workflow: Output file - {file_info.id if file_info else None}") | ||
except Exception as e: | ||
sly.logger.debug(f"Workflow: Can not add output file. Error: {repr(e)}") | ||
} | ||
api.app.workflow.add_output_file(file_info, meta=meta) | ||
sly.logger.debug(f"Workflow: Output file - {file_info.id if file_info else None}") | ||
except Exception as e: | ||
sly.logger.debug(f"Workflow: Can not add output file. Error: {repr(e)}") |