Model enhancements 2 (#109)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
pull/112/head
Ayush Chaurasia 2 years ago committed by GitHub
parent 8406b49b49
commit 0303ced8ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      ultralytics/yolo/engine/model.py
  2. 16
      ultralytics/yolo/engine/predictor.py
  3. 7
      ultralytics/yolo/engine/validator.py

@ -112,8 +112,9 @@ class YOLO:
source (str): Accepts all source types accepted by yolo
**kwargs : Any other args accepted by the predictors. Too see all args check 'configuration' section in the docs
"""
kwargs.update(self.overrides)
predictor = self.PredictorClass(overrides=kwargs)
overrides = self.overrides.copy()
overrides.update(kwargs)
predictor = self.PredictorClass(overrides=overrides)
# check size type
sz = predictor.args.imgsz
@ -136,8 +137,9 @@ class YOLO:
if not self.model:
raise Exception("model not initialized!")
kwargs.update(self.overrides)
args = get_config(config=DEFAULT_CONFIG, overrides=kwargs)
overrides = self.overrides.copy()
overrides.update(kwargs)
args = get_config(config=DEFAULT_CONFIG, overrides=overrides)
args.data = data or args.data
args.task = self.task

@ -46,7 +46,9 @@ class BasePredictor:
def __init__(self, config=DEFAULT_CONFIG, overrides={}):
self.args = get_config(config, overrides)
self.save_dir = increment_path(Path(self.args.project) / self.args.name, exist_ok=self.args.exist_ok)
project = overrides.get("project") or self.args.task
name = overrides.get("name") or self.args.mode
self.save_dir = increment_path(Path("runs") / project / name, exist_ok=self.args.exist_ok)
(self.save_dir / 'labels' if self.args.save_txt else self.save_dir).mkdir(parents=True, exist_ok=True)
self.done_setup = False
@ -84,18 +86,6 @@ class BasePredictor:
if is_url and is_file:
source = check_file(source) # download
# data
if self.data:
try:
if self.data.endswith(".yaml"):
self.data = check_dataset_yaml(self.data)
else:
self.data = check_dataset(self.data)
except AssertionError as e:
LOGGER.info(f"Error ocurred: {e}")
finally:
LOGGER.info("Predictor will continue without reading the dataset")
# model
device = select_device(self.args.device)
model = model or self.args.model

@ -31,8 +31,11 @@ class BaseValidator:
self.training = True
self.speed = None
self.jdict = None
self.save_dir = save_dir if save_dir is not None else \
increment_path(Path(self.args.project) / self.args.name, exist_ok=self.args.exist_ok)
project = self.args.project if self.args.project != "runs/train" else self.args.task
name = self.args.name if self.args.name != "exp" else self.args.mode
self.save_dir = increment_path(Path("runs") / project / name, exist_ok=self.args.exist_ok)
(self.save_dir / 'labels' if self.args.save_txt else self.save_dir).mkdir(parents=True, exist_ok=True)
@smart_inference_mode()
def __call__(self, trainer=None, model=None):

Loading…
Cancel
Save