import os from collections import defaultdict import supervisely_lib as sly app: sly.AppService = sly.AppService() api = app.public_api owner_id = int(os.environ['context.userId']) team_id = int(os.environ['context.teamId']) workspace_id = int(os.environ['context.workspaceId']) project_id = int(os.environ['modal.state.slyProjectId']) project = None meta: sly.ProjectMeta = None CNT_GRID_COLUMNS = 3 gallery = { "content": { "projectMeta": sly.ProjectMeta().to_json(), "annotations": {}, "layout": [[] for i in range(CNT_GRID_COLUMNS)] }, "previewOptions": { "enableZoom": True, "resizeOnZoom": True }, "options": { "enableZoom": False, "syncViews": False, "showPreview": True, "selectable": True }
import os import supervisely_lib as sly from supervisely_lib.io.fs import mkdir my_app = sly.AppService() api: sly.Api = my_app.public_api task_id = os.environ["TASK_ID"] user_id = os.environ["context.userId"] team_id = int(os.environ['context.teamId']) workspace_id = int(os.environ['context.workspaceId']) project_id = int(os.environ['context.projectId']) user = api.user.get_info_by_id(user_id) project = api.project.get_info_by_id(project_id) meta_json = api.project.get_meta(project_id) meta = sly.ProjectMeta.from_json(meta_json) storage_dir = os.path.join(my_app.data_dir, "storage_dir") coco_base_dir = os.path.join(storage_dir, project.name) sly_base_dir = os.path.join(storage_dir, "sly_base_dir") mkdir(storage_dir, True) mkdir(coco_base_dir) mkdir(sly_base_dir) isObjectDetection = True isStuffSegmentation = False # isKeypointDetection = False
import os from urllib.parse import urlparse, urljoin import htmllistparse import requests import time import supervisely_lib as sly from slugify import slugify from functools import reduce my_app = sly.AppService(ignore_task_id=True) TEAM_ID = int(os.environ['context.teamId']) WORKSPACE_ID = int(os.environ['context.workspaceId']) listing = [] @my_app.callback("preview_remote") @sly.timeit def preview_remote(api: sly.Api, task_id, context, state, app_logger): global listing api.task.set_field(task_id, "data.previewError", "") try: remote_dir = state["remoteDir"] parts = urlparse(remote_dir) project_name = parts.path.rstrip("/") if project_name not in ["", "/"]: project_name = sly.fs.get_file_name(project_name) # last directory name from path else: project_name = ""