Add git info to training checkpoints (#9655)
* Add git status on train checkpoints * Update * Update * Update * Update * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update general.py Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> * Update general.py Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
9bc60349b6
commit
9286336cb4
3 files changed
+21
-2
No files matched your search
+18
-1
@@ -29,6 +29,7 @@ from typing import Optional
|
||||
from zipfile import ZipFile, is_zipfile
|
||||
|
||||
import cv2
|
||||
import git
|
||||
import IPython
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
@@ -344,6 +345,22 @@ def check_git_status(repo='ultralytics/yolov5', branch='master'):
|
||||
LOGGER.info(s)
|
||||
|
||||
|
||||
@WorkingDirectory(ROOT)
|
||||
def check_git(path='.'):
|
||||
# YOLOv5 git check, return git {remote, branch, commit}
|
||||
try:
|
||||
repo = git.Repo(path)
|
||||
remote = repo.remotes.origin.url.replace('.git', '') # i.e. 'https://github.com/ultralytics/yolov5'
|
||||
commit = repo.head.commit.hexsha # i.e. '3134699c73af83aac2a481435550b968d5792c0d'
|
||||
try:
|
||||
branch = repo.active_branch.name # i.e. 'main'
|
||||
except TypeError: # not on any branch
|
||||
branch = None # i.e. 'detached HEAD' state
|
||||
return {'remote': remote, 'branch': branch, 'commit': commit}
|
||||
except git.exc.InvalidGitRepositoryError: # path is not a git dir
|
||||
return {'remote': None, 'branch': None, 'commit': None}
|
||||
|
||||
|
||||
def check_python(minimum='3.7.0'):
|
||||
# Check current python version vs. required python version
|
||||
check_version(platform.python_version(), minimum, name='Python ', hard=True)
|
||||
@@ -1121,4 +1138,4 @@ def imshow(path, im):
|
||||
cv2.imread, cv2.imwrite, cv2.imshow = imread, imwrite, imshow # redefine
|
||||
|
||||
# Variables ------------------------------------------------------------------------------------------------------------
|
||||
NCOLS = 0 if is_docker() else shutil.get_terminal_size().columns # terminal window size for tqdm
|
||||
GIT = check_git() # repo, branch, commit
|
||||
Reference in new issue
Block a user