-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
feat: log_matrix #209
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ 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. |
There was a problem hiding this 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
luxonis_ml/tracker/tracker.py
Outdated
"flat_array": matrix.flatten().tolist(), | ||
"shape": matrix.shape, | ||
} | ||
tmp_file_path = f"{name}.json" |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
luxonis_ml/tracker/tracker.py
Outdated
@@ -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" |
There was a problem hiding this comment.
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
luxonis_ml/tracker/tracker.py
Outdated
"shape": matrix.shape, | ||
} | ||
tmp_file_path = f"{name}.json" | ||
try: |
There was a problem hiding this comment.
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)
luxonis_ml/tracker/tracker.py
Outdated
@@ -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" |
There was a problem hiding this comment.
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
Add an option to log a matrix as an artifact.