Skip to content

Commit

Permalink
added progress to saving cache and retreiving from cache
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaiPetukhov committed Feb 27, 2024
1 parent 3bb0f2e commit 69a471e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions train/src/dataset_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def download_project(api: sly.Api, project_info: sly.ProjectInfo, dataset_infos:
# clean project dir
if os.path.exists(g.project_dir):
sly.fs.clean_dir(g.project_dir)

# TODO Check if to_download is empty

# download
with progress(message="Downloading input data...", total=total) as pbar:
sly.download(
Expand All @@ -63,10 +66,12 @@ def download_project(api: sly.Api, project_info: sly.ProjectInfo, dataset_infos:
dataset_name = dataset_infos_dict[dataset_id].name
dataset_dir = os.path.join(g.project_dir, project_info.name, dataset_name)
cache_dataset_dir = os.path.join(g.cache_dir, str(project_info.id), str(dataset_id))
sly.fs.copy_dir_recursively(dataset_dir, cache_dataset_dir)
with progress(message="Saving data to cache...") as pbar:
sly.fs.copy_dir_recursively(dataset_dir, cache_dataset_dir, progress_cb=pbar.update)
# copy cached datasets
for dataset_id in cached:
dataset_name = dataset_infos_dict[dataset_id].name
cache_dataset_dir = os.path.join(g.cache_dir, str(project_info.id), str(dataset_id))
dataset_dir = os.path.join(g.project_dir, project_info.name, dataset_name)
sly.fs.copy_dir_recursively(cache_dataset_dir, dataset_dir)
with progress(message="Retreiving data from cache...") as pbar:
sly.fs.copy_dir_recursively(cache_dataset_dir, dataset_dir, progress_cb=pbar.update)
2 changes: 2 additions & 0 deletions train/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ def select_input_data():
)
select_data_button.loading = True
dataset_selector.disable()
use_cache_text.disable()
classes_table.read_project_from_id(project_id)
select_data_button.loading = False
select_data_button.hide()
Expand All @@ -618,6 +619,7 @@ def reselect_input_data():
reselect_data_button.hide()
select_done.hide()
dataset_selector.enable()
use_cache_text.enable()
curr_step = stepper.get_active_step()
curr_step -= 1
stepper.set_active_step(curr_step)
Expand Down

0 comments on commit 69a471e

Please sign in to comment.