Model builder (#29)
Co-authored-by: Ayush Chaurasia <ayush.chuararsia@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
c5cb76b356
commit
7b560f7861
27 changed files with 2622 additions and 407 deletions
|
|
@ -1,18 +1,40 @@
|
|||
from .general import Profile, WorkingDirectory, check_version, download, increment_path, save_yaml
|
||||
from .torch_utils import LOCAL_RANK, RANK, WORLD_SIZE, DDP_model, select_device, torch_distributed_zero_first
|
||||
import contextlib
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
from pathlib import Path
|
||||
|
||||
__all__ = [
|
||||
# general
|
||||
"increment_path",
|
||||
"save_yaml",
|
||||
"WorkingDirectory",
|
||||
"download",
|
||||
"check_version",
|
||||
"Profile",
|
||||
# torch
|
||||
"torch_distributed_zero_first",
|
||||
"LOCAL_RANK",
|
||||
"RANK",
|
||||
"WORLD_SIZE",
|
||||
"DDP_model",
|
||||
"select_device"]
|
||||
from .files import user_config_dir
|
||||
from .loggers import emojis, set_logging
|
||||
|
||||
# Constants
|
||||
|
||||
FILE = Path(__file__).resolve()
|
||||
ROOT = FILE.parents[2] # YOLOv5 root directory
|
||||
RANK = int(os.getenv('RANK', -1))
|
||||
DATASETS_DIR = ROOT.parent / 'datasets' # YOLOv5 datasets directory
|
||||
NUM_THREADS = min(8, max(1, os.cpu_count() - 1)) # number of YOLOv5 multiprocessing threads
|
||||
AUTOINSTALL = str(os.getenv('YOLOv5_AUTOINSTALL', True)).lower() == 'true' # global auto-install mode
|
||||
FONT = 'Arial.ttf' # https://ultralytics.com/assets/Arial.ttf
|
||||
|
||||
CONFIG_DIR = user_config_dir() # Ultralytics settings dir
|
||||
|
||||
set_logging() # run before defining LOGGER
|
||||
LOGGER = logging.getLogger("yolov5") # define globally
|
||||
if platform.system() == "Windows":
|
||||
for fn in LOGGER.info, LOGGER.warning:
|
||||
setattr(LOGGER, fn.__name__, lambda x: fn(emojis(x))) # emoji safe logging
|
||||
|
||||
|
||||
class TryExcept(contextlib.ContextDecorator):
|
||||
# YOLOv5 TryExcept class. Usage: @TryExcept() decorator or 'with TryExcept():' context manager
|
||||
def __init__(self, msg=''):
|
||||
self.msg = msg
|
||||
|
||||
def __enter__(self):
|
||||
pass
|
||||
|
||||
def __exit__(self, exc_type, value, traceback):
|
||||
if value:
|
||||
print(emojis(f'{self.msg}{value}'))
|
||||
return True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue