Skip to content

Commit

Permalink
added logger to whatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoLisin committed Nov 7, 2023
1 parent 048b25c commit 4b24d61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions train/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,7 @@ def on_results_file_changed(filepath, pbar):
watch_file,
on_results_file_changed,
progress_bar_epochs(message="Epochs:", total=n_epochs_input.get_value()),
logger=sly.logger,
)
# train model and upload best checkpoints to team files
device = 0 if torch.cuda.is_available() else "cpu"
Expand Down
6 changes: 6 additions & 0 deletions train/src/metrics_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def __init__(self, watch_file, call_func_on_change=None, *args, **kwargs):
self.call_func_on_change = call_func_on_change
self.args = args
self.kwargs = kwargs
self.logger = kwargs.get("logger", None)

# Look for changes
def look(self):
Expand All @@ -28,10 +29,15 @@ def look(self):

# Keep watching in a loop
def watch(self):
from time import sleep

while self.running:
try:
# Look for changes
self.look()
sleep(1)
if self.logger is not None:
self.logger.debug("Watcher is still looking")
except KeyboardInterrupt:
print("\nDone")
break
Expand Down

0 comments on commit 4b24d61

Please sign in to comment.