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

feat: log_matrix #209

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

feat: log_matrix #209

wants to merge 5 commits into from

Conversation

JSabadin
Copy link
Contributor

Add an option to log a matrix as an artifact.

@JSabadin JSabadin requested a review from a team as a code owner November 22, 2024 05:12
@JSabadin JSabadin requested review from kozlov721, klemen1999, tersekmatija and conorsim and removed request for a team November 22, 2024 05:12
@github-actions github-actions bot added enhancement New feature or request tracker Changes affecting luxonis_ml.tracker subpackage labels Nov 22, 2024
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.30%. Comparing base (6bcbb11) to head (4ccf57e).
Report is 19 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #209      +/-   ##
==========================================
- Coverage   92.33%   92.30%   -0.03%     
==========================================
  Files          79       79              
  Lines        4161     4275     +114     
==========================================
+ Hits         3842     3946     +104     
- Misses        319      329      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@kozlov721 kozlov721 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just left a small comment

"flat_array": matrix.flatten().tolist(),
"shape": matrix.shape,
}
tmp_file_path = f"{name}.json"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the tempfile library for the file (just careful, you'll need to use NamedTemporaryFile otherwise it won't work in Windows)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, a random name would be saved in MLflow, as it would simply copy the local path.

@@ -500,6 +500,30 @@ def upload_artifact(
) # Stores details for retrying later
self.log_stored_logs_to_mlflow()

@rank_zero_only
def log_matrix(
self, matrix: np.ndarray, name: str = "confusion_matrix"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the defualt name value so it is more general and in the docstring don't mention confusion matrix in particular, just say any matrix

"shape": matrix.shape,
}
tmp_file_path = f"{name}.json"
try:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upload artifact is not possible for Tensorboard. If tensorboard tracker is active then let's log it as something else, maybe as a string (or if you find a better option)

@@ -500,6 +500,30 @@ def upload_artifact(
) # Stores details for retrying later
self.log_stored_logs_to_mlflow()

@rank_zero_only
def log_matrix(
self, matrix: np.ndarray, name: str = "confusion_matrix"
Copy link
Collaborator

@klemen1999 klemen1999 Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add step as a function parameter and when logging let's include step in the json name e.g. {name}_{step}.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tracker Changes affecting luxonis_ml.tracker subpackage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants