Scope gitpyhon import in `check_git_info()` (#10221)
* Scope gitpyhon import in `check_git_info()` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>pull/10222/head
parent
6992dde4bd
commit
40bb8030f8
|
@ -40,7 +40,7 @@ from classify import val as validate
|
|||
from models.experimental import attempt_load
|
||||
from models.yolo import ClassificationModel, DetectionModel
|
||||
from utils.dataloaders import create_classification_dataloader
|
||||
from utils.general import (DATASETS_DIR, GIT, LOGGER, TQDM_BAR_FORMAT, WorkingDirectory, check_git_status,
|
||||
from utils.general import (DATASETS_DIR, LOGGER, TQDM_BAR_FORMAT, WorkingDirectory, check_git_info, check_git_status,
|
||||
check_requirements, colorstr, download, increment_path, init_seeds, print_args, yaml_save)
|
||||
from utils.loggers import GenericLogger
|
||||
from utils.plots import imshow_cls
|
||||
|
@ -50,6 +50,7 @@ from utils.torch_utils import (ModelEMA, model_info, reshape_classifier_output,
|
|||
LOCAL_RANK = int(os.getenv('LOCAL_RANK', -1)) # https://pytorch.org/docs/stable/elastic/run.html
|
||||
RANK = int(os.getenv('RANK', -1))
|
||||
WORLD_SIZE = int(os.getenv('WORLD_SIZE', 1))
|
||||
GIT_INFO = check_git_info()
|
||||
|
||||
|
||||
def train(opt, device):
|
||||
|
@ -237,7 +238,7 @@ def train(opt, device):
|
|||
'updates': ema.updates,
|
||||
'optimizer': None, # optimizer.state_dict(),
|
||||
'opt': vars(opt),
|
||||
'git': GIT, # {remote, branch, commit} if a git repo
|
||||
'git': GIT_INFO, # {remote, branch, commit} if a git repo
|
||||
'date': datetime.now().isoformat()}
|
||||
|
||||
# Save last, best and delete
|
||||
|
|
|
@ -46,9 +46,9 @@ from utils.autoanchor import check_anchors
|
|||
from utils.autobatch import check_train_batch_size
|
||||
from utils.callbacks import Callbacks
|
||||
from utils.downloads import attempt_download, is_url
|
||||
from utils.general import (GIT, LOGGER, TQDM_BAR_FORMAT, check_amp, check_dataset, check_file, check_git_status,
|
||||
check_img_size, check_requirements, check_suffix, check_yaml, colorstr, get_latest_run,
|
||||
increment_path, init_seeds, intersect_dicts, labels_to_class_weights,
|
||||
from utils.general import (LOGGER, TQDM_BAR_FORMAT, check_amp, check_dataset, check_file, check_git_info,
|
||||
check_git_status, check_img_size, check_requirements, check_suffix, check_yaml, colorstr,
|
||||
get_latest_run, increment_path, init_seeds, intersect_dicts, labels_to_class_weights,
|
||||
labels_to_image_weights, one_cycle, print_args, print_mutation, strip_optimizer, yaml_save)
|
||||
from utils.loggers import GenericLogger
|
||||
from utils.plots import plot_evolve, plot_labels
|
||||
|
@ -62,6 +62,7 @@ from utils.torch_utils import (EarlyStopping, ModelEMA, de_parallel, select_devi
|
|||
LOCAL_RANK = int(os.getenv('LOCAL_RANK', -1)) # https://pytorch.org/docs/stable/elastic/run.html
|
||||
RANK = int(os.getenv('RANK', -1))
|
||||
WORLD_SIZE = int(os.getenv('WORLD_SIZE', 1))
|
||||
GIT_INFO = check_git_info()
|
||||
|
||||
|
||||
def train(hyp, opt, device, callbacks): # hyp is path/to/hyp.yaml or hyp dictionary
|
||||
|
@ -390,7 +391,7 @@ def train(hyp, opt, device, callbacks): # hyp is path/to/hyp.yaml or hyp dictio
|
|||
'updates': ema.updates,
|
||||
'optimizer': optimizer.state_dict(),
|
||||
'opt': vars(opt),
|
||||
'git': GIT, # {remote, branch, commit} if a git repo
|
||||
'git': GIT_INFO, # {remote, branch, commit} if a git repo
|
||||
'date': datetime.now().isoformat()}
|
||||
|
||||
# Save last, best and delete
|
||||
|
|
9
train.py
9
train.py
|
@ -47,9 +47,9 @@ from utils.autobatch import check_train_batch_size
|
|||
from utils.callbacks import Callbacks
|
||||
from utils.dataloaders import create_dataloader
|
||||
from utils.downloads import attempt_download, is_url
|
||||
from utils.general import (GIT, LOGGER, TQDM_BAR_FORMAT, check_amp, check_dataset, check_file, check_git_status,
|
||||
check_img_size, check_requirements, check_suffix, check_yaml, colorstr, get_latest_run,
|
||||
increment_path, init_seeds, intersect_dicts, labels_to_class_weights,
|
||||
from utils.general import (LOGGER, TQDM_BAR_FORMAT, check_amp, check_dataset, check_file, check_git_info,
|
||||
check_git_status, check_img_size, check_requirements, check_suffix, check_yaml, colorstr,
|
||||
get_latest_run, increment_path, init_seeds, intersect_dicts, labels_to_class_weights,
|
||||
labels_to_image_weights, methods, one_cycle, print_args, print_mutation, strip_optimizer,
|
||||
yaml_save)
|
||||
from utils.loggers import Loggers
|
||||
|
@ -63,6 +63,7 @@ from utils.torch_utils import (EarlyStopping, ModelEMA, de_parallel, select_devi
|
|||
LOCAL_RANK = int(os.getenv('LOCAL_RANK', -1)) # https://pytorch.org/docs/stable/elastic/run.html
|
||||
RANK = int(os.getenv('RANK', -1))
|
||||
WORLD_SIZE = int(os.getenv('WORLD_SIZE', 1))
|
||||
GIT_INFO = check_git_info()
|
||||
|
||||
|
||||
def train(hyp, opt, device, callbacks): # hyp is path/to/hyp.yaml or hyp dictionary
|
||||
|
@ -376,7 +377,7 @@ def train(hyp, opt, device, callbacks): # hyp is path/to/hyp.yaml or hyp dictio
|
|||
'updates': ema.updates,
|
||||
'optimizer': optimizer.state_dict(),
|
||||
'opt': vars(opt),
|
||||
'git': GIT, # {remote, branch, commit} if a git repo
|
||||
'git': GIT_INFO, # {remote, branch, commit} if a git repo
|
||||
'date': datetime.now().isoformat()}
|
||||
|
||||
# Save last, best and delete
|
||||
|
|
|
@ -13,7 +13,6 @@ import os
|
|||
import platform
|
||||
import random
|
||||
import re
|
||||
import shutil
|
||||
import signal
|
||||
import sys
|
||||
import time
|
||||
|
@ -29,7 +28,6 @@ from typing import Optional
|
|||
from zipfile import ZipFile, is_zipfile
|
||||
|
||||
import cv2
|
||||
import git
|
||||
import IPython
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
@ -346,8 +344,10 @@ def check_git_status(repo='ultralytics/yolov5', branch='master'):
|
|||
|
||||
|
||||
@WorkingDirectory(ROOT)
|
||||
def check_git(path='.'):
|
||||
# YOLOv5 git check, return git {remote, branch, commit}
|
||||
def check_git_info(path='.'):
|
||||
# YOLOv5 git info check, return {remote, branch, commit}
|
||||
check_requirements('gitpython')
|
||||
import git
|
||||
try:
|
||||
repo = git.Repo(path)
|
||||
remote = repo.remotes.origin.url.replace('.git', '') # i.e. 'https://github.com/ultralytics/yolov5'
|
||||
|
@ -1138,4 +1138,3 @@ def imshow(path, im):
|
|||
cv2.imread, cv2.imwrite, cv2.imshow = imread, imwrite, imshow # redefine
|
||||
|
||||
# Variables ------------------------------------------------------------------------------------------------------------
|
||||
GIT = check_git() # repo, branch, commit
|
||||
|
|
Loading…
Reference in New Issue