Skip to content

Commit

Permalink
export selected dataset (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
almazgimaev authored Jul 20, 2023
1 parent 05ef828 commit ff8fcee
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div align="center" markdown>
<img src="https://user-images.githubusercontent.com/106374579/186665737-ec3da9cc-193f-43ee-85db-a6f802b2dfe4.png"/>

# Export images project to Supervisely Format
# Export images to Supervisely Format

<p align="center">
<a href="#Overview">Overview</a> •
Expand All @@ -19,13 +19,13 @@

# Overview

Download images project in [Supervisely JSON format](https://docs.supervise.ly/data-organization/00_ann_format_navi). It is possible to download both images and annotations or only annotations.
Download images project or dataset in [Supervisely JSON format](https://docs.supervise.ly/data-organization/00_ann_format_navi). It is possible to download both images and annotations or only annotations.


# How To Use
**Step 1**: Add app to your team from [Ecosystem](https://ecosystem.supervise.ly/apps/export-to-supervisely-format) if it is not there

**Step 2**: Open context menu of images project -> `Run App` -> `Download via app` -> `Export to Supervisely format`
**Step 2**: Open context menu of images project (or images dataset) -> `Run App` -> `Download via app` -> `Export to Supervisely format`

<img src="https://i.imgur.com/6JNfu3g.png" width="600px"/>

Expand Down
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"icon_background": "#FFFFFF",
"context_menu": {
"target": [
"images_project"
"images_project",
"images_dataset"
],
"context_root": "Download as"
},
Expand Down
14 changes: 12 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
TEAM_ID = int(os.environ['context.teamId'])
WORKSPACE_ID = int(os.environ['context.workspaceId'])
PROJECT_ID = int(os.environ['modal.state.slyProjectId'])
DATASET_ID = os.environ.get('modal.state.slyDatasetId', None)
if DATASET_ID is not None:
DATASET_ID = int(DATASET_ID)
task_id = int(os.environ["TASK_ID"])
mode = os.environ['modal.state.download']
replace_method = bool(util.strtobool(os.environ['modal.state.fixExtension']))
Expand Down Expand Up @@ -60,9 +63,16 @@ def init(data, state):
@my_app.callback("download_as_sly")
@sly.timeit
def download_as_sly(api: sly.Api, task_id, context, state, app_logger):
global TEAM_ID, PROJECT_ID, DATASET_ID, mode
if DATASET_ID is not None:
dataset_ids = [DATASET_ID]
dataset = api.dataset.get_info_by_id(DATASET_ID)
if PROJECT_ID is None:
PROJECT_ID = dataset.project_id
else:
datasets = api.dataset.get_list(PROJECT_ID)
dataset_ids = [dataset.id for dataset in datasets]
project = api.project.get_info_by_id(PROJECT_ID)
datasets = api.dataset.get_list(project.id)
dataset_ids = [dataset.id for dataset in datasets]
if mode == 'all':
download_json_plus_images(api, project, dataset_ids)
else:
Expand Down

0 comments on commit ff8fcee

Please sign in to comment.