Skip to content

Commit

Permalink
replace tinytimer
Browse files Browse the repository at this point in the history
  • Loading branch information
vorozhkog committed Nov 29, 2024
1 parent 6448cd9 commit 988f887
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion local.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TEAM_ID = 431
WORKSPACE_ID = 1019
PROJECT_ID = 41703
PROJECT_ID = 40721

# options: "images" "annotations"
modal.state.selectedOutput="images"
Expand Down
1 change: 1 addition & 0 deletions src/convert_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import List
import uuid


def prepare_meta(meta: sly.ProjectMeta):
new_classes = []
for cls in meta.obj_classes:
Expand Down
15 changes: 12 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import convert_geometry
import functions as f
import workflow as w
from tinytimer import Timer
import time

# region constants
USER_NAME = "Supervisely"
Expand Down Expand Up @@ -43,6 +43,16 @@
)


class Timer:
def __enter__(self):
self.start = time.perf_counter()
return self

def __exit__(self, exc_type, exc_val, exc_tb):
self.end = time.perf_counter()
self.elapsed = self.end - self.start


def export_to_coco(api: sly.Api) -> None:
project = api.project.get_info_by_id(project_id)
project_meta = sly.ProjectMeta.from_json(api.project.get_meta(project_id))
Expand Down Expand Up @@ -90,10 +100,9 @@ def export_to_coco(api: sly.Api) -> None:
image_ids = [image_info.id for image_info in images]
paths = [os.path.join(dataset_path, image_info.name) for image_info in images]
if api.server_address.startswith("https://"):
semaphore = asyncio.Semaphore(100)
semaphore = asyncio.Semaphore(10)
else:
semaphore = None
# api._get_default_semaphore()

with Timer() as t:
coro = api.image.download_paths_async(image_ids, paths, semaphore)
Expand Down

0 comments on commit 988f887

Please sign in to comment.