Skip to content

Commit

Permalink
Merge pull request #1061 from mikel-brostrom/fix-save
Browse files Browse the repository at this point in the history
use args to yolo, delete later internal yolo args modifications
  • Loading branch information
mikel-brostrom authored Aug 8, 2023
2 parents d5a3c29 + c4ee33a commit 9ee31b3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
2 changes: 2 additions & 0 deletions examples/evolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ def parse_opt():
help='nr of trials for evolution')
parser.add_argument('--resume', action='store_true',
help='resume hparam search')
parser.add_argument('--save', action='store_true',
help='save video tracking results')
parser.add_argument('--processes-per-device', type=int, default=2,
help='how many subprocesses can be invoked per GPU (to manage memory consumption)')
parser.add_argument('--objectives', type=str, default='HOTA,MOTA,IDF1',
Expand Down
22 changes: 14 additions & 8 deletions examples/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from boxmot import TRACKERS
from boxmot.tracker_zoo import create_tracker
from boxmot.utils import EXAMPLES, ROOT, WEIGHTS
from boxmot.utils import ROOT, WEIGHTS
from boxmot.utils.checks import TestRequirements
from examples.detectors import get_yolo_inferer

Expand Down Expand Up @@ -55,7 +55,9 @@ def on_predict_start(predictor, persist=False):
trackers.append(tracker)

predictor.trackers = trackers
predictor.save_dir = predictor.get_save_dir()
# predictor.get_save_dir().mkdir()
# predictor.save_dir = predictor.get_save_dir()
# print(predictor.save_dir)


@torch.no_grad()
Expand All @@ -75,7 +77,11 @@ def run(args):
show_conf=args.show_conf,
show_labels=args.show_labels,
save=args.save,
verbose=args.verbose
verbose=args.verbose,
exist_ok=args.exist_ok,
project=args.project,
name=args.name,
classes=args.classes
)

yolo.add_callback('on_predict_start', partial(on_predict_start, persist=True))
Expand All @@ -90,10 +96,10 @@ def run(args):
)
yolo.predictor.model = model

yolo.predictor.args.project = args.project
yolo.predictor.args.name = args.name
yolo.predictor.args.exist_ok = args.exist_ok
yolo.predictor.args.classes = args.classes
# yolo.predictor.args.project = args.project
# yolo.predictor.args.name = args.name
# yolo.predictor.args.exist_ok = args.exist_ok
# yolo.predictor.args.classes = args.classes
yolo.predictor.custom_args = args

for frame_idx, r in enumerate(results):
Expand Down Expand Up @@ -155,7 +161,7 @@ def parse_opt():
# # class 0 is person, 1 is bycicle, 2 is car... 79 is oven
parser.add_argument('--classes', nargs='+', type=int,
help='filter by class: --classes 0, or --classes 0 2 3')
parser.add_argument('--project', default=EXAMPLES / 'runs' / 'track',
parser.add_argument('--project', default=ROOT / 'runs' / 'track',
help='save results to project/name')
parser.add_argument('--name', default='exp',
help='save results to project/name')
Expand Down
7 changes: 5 additions & 2 deletions examples/val.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def eval_setup(self, opt, val_tools_path):
if not (Path(opt.project) / opt.name).exists():
LOGGER.error(f'{save_dir} does not exist')
else:
save_dir = increment_path(Path(opt.project) / opt.name, exist_ok=opt.exist_ok)
save_dir = increment_path(Path(opt.project) / opt.name, exist_ok=False)
MOT_results_folder = (
val_tools_path / 'data' / 'trackers' /
'mot_challenge' / opt.benchmark / save_dir.name / 'data'
Expand Down Expand Up @@ -203,6 +203,7 @@ def eval(self, opt, seq_paths, save_dir, MOT_results_folder, val_tools_path, gt_
"--imgsz", str(self.opt.imgsz[0]),
"--classes", *self.opt.classes,
"--name", save_dir.name,
"--save" if self.opt.save else ""
"--save-mot",
"--project", self.opt.project,
"--device", str(tracking_subprocess_device),
Expand Down Expand Up @@ -329,7 +330,7 @@ def parse_opt():
help='save results to project/name')
parser.add_argument('--classes', nargs='+', type=str, default=['0'],
help='filter by class: --classes 0, or --classes 0 2 3')
parser.add_argument('--project', default=EXAMPLES / 'runs' / 'val',
parser.add_argument('--project', default=ROOT / 'runs' / 'val',
help='save results to project/name')
parser.add_argument('--exist-ok', action='store_true',
help='existing project/name ok, do not increment')
Expand All @@ -347,6 +348,8 @@ def parse_opt():
help='inference size h,w')
parser.add_argument('--device', default='',
help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
parser.add_argument('--save', action='store_true',
help='save video tracking results')
parser.add_argument('--processes-per-device', type=int, default=2,
help='how many subprocesses can be invoked per GPU (to manage memory consumption)')
opt = parser.parse_args()
Expand Down

0 comments on commit 9ee31b3

Please sign in to comment.