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:
@ -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?
|
||||
|
@ -2,13 +2,13 @@
|
||||
# Default training settings and hyperparameters for medium-augmentation COCO training
|
||||
|
||||
# Task and Mode
|
||||
task: "classify" # choices=['detect', 'segment', 'classify', 'init'] # init is a special case
|
||||
mode: "train" # choice=['train', 'val', 'infer']
|
||||
task: "classify" # choices=['detect', 'segment', 'classify', 'init'] # init is a special case
|
||||
mode: "train" # choice=['train', 'val', 'infer']
|
||||
|
||||
# Train settings -------------------------------------------------------------------------------------------------------
|
||||
model: null # i.e. yolov5s.pt, yolo.yaml
|
||||
data: null # i.e. coco128.yaml
|
||||
epochs: 300
|
||||
epochs: 100
|
||||
batch_size: 16
|
||||
imgsz: 640
|
||||
nosave: False
|
||||
@ -42,10 +42,10 @@ noval: False
|
||||
save_json: False
|
||||
save_hybrid: False
|
||||
conf_thres: 0.001
|
||||
iou_thres: 0.6
|
||||
iou_thres: 0.7
|
||||
max_det: 300
|
||||
half: True
|
||||
dnn: False # use OpenCV DNN for ONNX inference
|
||||
dnn: False # use OpenCV DNN for ONNX inference
|
||||
plots: True
|
||||
|
||||
# Prediction settings:
|
||||
@ -56,9 +56,9 @@ save_conf: False
|
||||
save_crop: False
|
||||
hide_labels: False # hide labels
|
||||
hide_conf: False
|
||||
vid_stride: 1 # video frame-rate stride
|
||||
vid_stride: 1 # video frame-rate stride
|
||||
line_thickness: 3 # bounding box thickness (pixels)
|
||||
update: False # Update all models
|
||||
update: False # Update all models
|
||||
visualize: False
|
||||
augment: False
|
||||
agnostic_nms: False # class-agnostic NMS
|
||||
@ -77,7 +77,7 @@ cls: 0.5 # cls loss gain (scale with pixels)
|
||||
dfl: 1.5 # dfl loss gain
|
||||
fl_gamma: 0.0 # focal loss gamma (efficientDet default gamma=1.5)
|
||||
label_smoothing: 0.0
|
||||
nbs: 64 # nominal batch size
|
||||
nbs: 64 # nominal batch size
|
||||
hsv_h: 0.015 # image HSV-Hue augmentation (fraction)
|
||||
hsv_s: 0.7 # image HSV-Saturation augmentation (fraction)
|
||||
hsv_v: 0.4 # image HSV-Value augmentation (fraction)
|
||||
@ -92,6 +92,9 @@ mosaic: 1.0 # image mosaic (probability)
|
||||
mixup: 0.0 # image mixup (probability)
|
||||
copy_paste: 0.0 # segment copy-paste (probability)
|
||||
|
||||
# For debugging. Don't change
|
||||
v5loader: True
|
||||
|
||||
# Hydra configs --------------------------------------------------------------------------------------------------------
|
||||
hydra:
|
||||
output_subdir: null # disable hydra directory creation
|
||||
|
@ -47,7 +47,7 @@ def generate_ddp_command(world_size, trainer):
|
||||
if using_cli:
|
||||
file_name = generate_ddp_file(trainer)
|
||||
return [
|
||||
sys.executable, "-m", "torch.distributed.launch", "--nproc_per_node", f"{world_size}", "--master_port",
|
||||
sys.executable, "-m", "torch.distributed.run", "--nproc_per_node", f"{world_size}", "--master_port",
|
||||
f"{find_free_network_port()}", file_name] + sys.argv[1:]
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ def ddp_cleanup(command, trainer):
|
||||
# delete temp file if created
|
||||
# TODO: this is a temp solution in case the file is deleted before DDP launching
|
||||
time.sleep(5)
|
||||
tempfile_suffix = str(id(trainer)) + ".py"
|
||||
tempfile_suffix = f"{id(trainer)}.py"
|
||||
if tempfile_suffix in "".join(command):
|
||||
for chunk in command:
|
||||
if tempfile_suffix in chunk:
|
||||
|
Reference in New Issue
Block a user