Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small refactoring to load from ckpt #203

Merged
merged 4 commits into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions crabs/detection_tracking/detection_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,6 @@ def slurm_logs_as_artifacts(logger, slurm_job_id):
)


def log_data_augm_as_artifacts(logger, data_module):
"""Log data augmentation transforms as artifacts in MLflow."""
for transform_str in ["train_transform", "test_val_transform"]:
logger.experiment.log_text(
text=str(getattr(data_module, f"_get_{transform_str}")()),
artifact_file=f"{transform_str}.txt",
run_id=logger.run_id,
)


def get_checkpoint_type(checkpoint_path: Optional[str]) -> Optional[str]:
"""Get checkpoint type (full or weights) from the checkpoint path."""
checkpoint = torch.load(checkpoint_path) # fails if path doesn't exist
Expand All @@ -274,3 +264,13 @@ def get_checkpoint_type(checkpoint_path: Optional[str]) -> Optional[str]:
)

return checkpoint_type


def log_data_augm_as_artifacts(logger, data_module):
"""Log data augmentation transforms as artifacts in MLflow."""
for transform_str in ["train_transform", "test_val_transform"]:
logger.experiment.log_text(
text=str(getattr(data_module, f"_get_{transform_str}")()),
artifact_file=f"{transform_str}.txt",
run_id=logger.run_id,
)