Skip to content

Commit

Permalink
perf(transforms): smaller update images batch size
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulHax committed Feb 4, 2025
1 parent 4aca58a commit ee2e927
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1,023 deletions.
12 changes: 6 additions & 6 deletions src/nrtk_explorer/app/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
]


UPDATE_IMAGES_CHUNK_SIZE = 32
IMAGE_UPDATE_BATCH_SIZE = 16

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Expand Down Expand Up @@ -372,20 +372,20 @@ async def _update_images(self, dataset_ids, visible=False):

await self.update_transformed_images(dataset_ids, predictions_original_images)

async def _chunk_update_images(self, dataset_ids, visible=False):
async def _batch_process_images(self, dataset_ids, visible=False):
ids = list(dataset_ids)
for i in range(0, len(ids), UPDATE_IMAGES_CHUNK_SIZE):
chunk = ids[i : i + UPDATE_IMAGES_CHUNK_SIZE]
for i in range(0, len(ids), IMAGE_UPDATE_BATCH_SIZE):
chunk = ids[i : i + IMAGE_UPDATE_BATCH_SIZE]
await self._update_images(chunk, visible=visible)

async def _update_all_images(self, visible_images):
with self.state:
self.state.updating_images = True

await self._chunk_update_images(visible_images, visible=True)
await self._batch_process_images(visible_images, visible=True)

other_images = set(self.state.user_selected_ids) - set(visible_images)
await self._chunk_update_images(other_images, visible=False)
await self._batch_process_images(other_images, visible=False)

with self.state:
self.state.updating_images = False
Expand Down
17 changes: 0 additions & 17 deletions src/nrtk_explorer/library/assets/__init__.py

This file was deleted.

Loading

0 comments on commit ee2e927

Please sign in to comment.