Import YOLOv5 dataloader (#94)

Co-authored-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:
Ayush Chaurasia 2022-12-26 06:00:01 +05:30 committed by GitHub
parent ae05d44877
commit 16e3c08883
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 1761 additions and 23 deletions

View file

@ -6,13 +6,15 @@ import sys
import threading
from pathlib import Path
import cv2
import IPython
import pandas as pd
# Constants
FILE = Path(__file__).resolve()
ROOT = FILE.parents[2] # YOLO
RANK = int(os.getenv('RANK', -1))
DATASETS_DIR = ROOT.parent / 'datasets' # YOLOv5 datasets directory
DATASETS_DIR = Path(os.getenv('YOLOv5_DATASETS_DIR', ROOT.parent / 'datasets')) # global 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
@ -20,6 +22,14 @@ VERBOSE = str(os.getenv('YOLOv5_VERBOSE', True)).lower() == 'true' # global ver
TQDM_BAR_FORMAT = '{l_bar}{bar:10}{r_bar}' # tqdm bar format
LOGGING_NAME = 'yolov5'
# Settings
# torch.set_printoptions(linewidth=320, precision=5, profile='long')
# np.set_printoptions(linewidth=320, formatter={'float_kind': '{:11.5g}'.format}) # format short g, %precision=5
pd.options.display.max_columns = 10
cv2.setNumThreads(0) # prevent OpenCV from multithreading (incompatible with PyTorch DataLoader)
os.environ['NUMEXPR_MAX_THREADS'] = str(NUM_THREADS) # NumExpr max threads
os.environ['OMP_NUM_THREADS'] = '1' if platform.system() == 'darwin' else str(NUM_THREADS) # OpenMP (PyTorch and SciPy)
def is_colab():
# Is environment a Google Colab instance?