comparison scripts/dltrack.py @ 1219:8a626226793e

update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 19 Jun 2023 17:09:56 -0400
parents
children 5a207c838323
comparison
equal deleted inserted replaced
1218:1f0b1fc172f8 1219:8a626226793e
1 #! /usr/bin/env python3
2 # from https://docs.ultralytics.com/modes/track/
3 import sys, argparse
4
5 from trafficintelligence.moving import cocoUserTypeNames
6 from ultralytics import YOLO
7
8 parser = argparse.ArgumentParser(description='The program tracks objects following the ultralytics yolo executable.')#, epilog = 'Either the configuration filename or the other parameters (at least video and database filenames) need to be provided.')
9 parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file (overrides the configuration file)')
10 # detect model
11 # tracker model
12 parser.add_argument('--display', dest = 'display', help = 'show the results (careful with long videos, risk of running out of memory)', action = 'store_true')
13 args = parser.parse_args()
14
15 # Load a model
16 model = YOLO('/home/nicolas/Research/Data/classification-models/yolov8x.pt ') # seg yolov8x-seg.pt
17 # seg could be used on cropped image... if can be loaded and kept in memory
18 # model = YOLO('/home/nicolas/Research/Data/classification-models/yolo_nas_l.pt ') # AttributeError: 'YoloNAS_L' object has no attribute 'get'
19
20 # Track with the model
21 if args.display:
22 results = model.track(source=args.videoFilename, tracker="/home/nicolas/Research/Data/classification-models/bytetrack.yaml", classes=list(cocoUserTypeNames.keys()), show=True) # , save_txt=True
23 else:
24 results = model.track(source=args.videoFilename, tracker="/home/nicolas/Research/Data/classification-models/bytetrack.yaml", classes=list(cocoUserTypeNames.keys()), stream=True)
25 for result in results:
26 for box in result.boxes:
27 print(box.xyxy)