Spaces:
Runtime error
Runtime error
Commit ·
5ede26e
1
Parent(s): 8ad7701
associativity types
Browse files- inference.py +7 -2
- scripts/track_eval.py +13 -10
inference.py
CHANGED
|
@@ -258,7 +258,6 @@ def do_confidence_boost(inference, safe_preds, gp=None, batch_size=BATCH_SIZE, b
|
|
| 258 |
boost_range = math.floor(math.sqrt(1/boost_decay * math.log(boost_power / boost_cutoff)))
|
| 259 |
boost_scale = boost_power * math.exp(-boost_decay)
|
| 260 |
|
| 261 |
-
outputs = []
|
| 262 |
with tqdm(total=len(inference), desc="Running confidence boost", ncols=0, disable=not verbose) as pbar:
|
| 263 |
for batch_i in range(len(inference)):
|
| 264 |
|
|
@@ -297,7 +296,13 @@ def do_confidence_boost(inference, safe_preds, gp=None, batch_size=BATCH_SIZE, b
|
|
| 297 |
def boost_frame(safe_frame, base_frame, dt, power=1, decay=1):
|
| 298 |
safe_boxes = safe_frame[:, :4]
|
| 299 |
boxes = xywh2xyxy(base_frame[:, :4]) # center_x, center_y, width, height) to (x1, y1, x2, y2)≈
|
| 300 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
score = torch.matmul(ious, safe_frame[:, 4])
|
| 302 |
# score = iou(safe_box, base_box) * confidence(safe_box)
|
| 303 |
base_frame[:, 4] *= 1 + power*(score)*math.exp(-decay*(dt*dt-1))
|
|
|
|
| 258 |
boost_range = math.floor(math.sqrt(1/boost_decay * math.log(boost_power / boost_cutoff)))
|
| 259 |
boost_scale = boost_power * math.exp(-boost_decay)
|
| 260 |
|
|
|
|
| 261 |
with tqdm(total=len(inference), desc="Running confidence boost", ncols=0, disable=not verbose) as pbar:
|
| 262 |
for batch_i in range(len(inference)):
|
| 263 |
|
|
|
|
| 296 |
def boost_frame(safe_frame, base_frame, dt, power=1, decay=1):
|
| 297 |
safe_boxes = safe_frame[:, :4]
|
| 298 |
boxes = xywh2xyxy(base_frame[:, :4]) # center_x, center_y, width, height) to (x1, y1, x2, y2)≈
|
| 299 |
+
|
| 300 |
+
# If running on CPU, you have to convert to double for the .prod() function in box_iou for some reason?
|
| 301 |
+
if torch.cuda.is_available():
|
| 302 |
+
ious = box_iou(boxes, safe_boxes)
|
| 303 |
+
else:
|
| 304 |
+
ious = box_iou(boxes.double(), safe_boxes).float()
|
| 305 |
+
|
| 306 |
score = torch.matmul(ious, safe_frame[:, 4])
|
| 307 |
# score = iou(safe_box, base_box) * confidence(safe_box)
|
| 308 |
base_frame[:, 4] *= 1 + power*(score)*math.exp(-decay*(dt*dt-1))
|
scripts/track_eval.py
CHANGED
|
@@ -21,18 +21,25 @@ def main(args):
|
|
| 21 |
|
| 22 |
config = {
|
| 23 |
'conf_threshold': float(args.conf_threshold),
|
| 24 |
-
'low_conf_threshold': float(args.low_conf),
|
| 25 |
-
'high_conf_threshold': float(args.high_conf),
|
| 26 |
'nms_iou': float(args.nms_iou),
|
| 27 |
'min_length': float(args.min_length),
|
| 28 |
'max_age': int(args.max_age),
|
| 29 |
'iou_threshold': float(args.iou_threshold),
|
| 30 |
'min_hits': int(args.min_hits),
|
| 31 |
-
'
|
| 32 |
-
'boost_decay': float(args.boost_decay),
|
| 33 |
-
'use_associative': args.use_associative
|
| 34 |
}
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
print("verbose", args.verbose)
|
| 37 |
|
| 38 |
track(infer_args, config=config, verbose=args.verbose)
|
|
@@ -51,16 +58,12 @@ def argument_parser():
|
|
| 51 |
parser = argparse.ArgumentParser()
|
| 52 |
parser.add_argument("--detection_dir", default="../frames/detection_storage")
|
| 53 |
parser.add_argument("--conf_threshold", default=0.3, help="Config object. Required.")
|
| 54 |
-
parser.add_argument("--low_conf", default=0.01, help="Config object. Required.")
|
| 55 |
-
parser.add_argument("--high_conf", default=0.3, help="Config object. Required.")
|
| 56 |
parser.add_argument("--nms_iou", default=0.3, help="Config object. Required.")
|
| 57 |
parser.add_argument("--min_length", default=0.3, help="Config object. Required.")
|
| 58 |
parser.add_argument("--max_age", default=20, help="Config object. Required.")
|
| 59 |
parser.add_argument("--iou_threshold", default=0.01, help="Config object. Required.")
|
| 60 |
parser.add_argument("--min_hits", default=11, help="Config object. Required.")
|
| 61 |
-
parser.add_argument("--
|
| 62 |
-
parser.add_argument("--boost_decay", default=1, help="Config object. Required.")
|
| 63 |
-
parser.add_argument("--use_associative", action='store_true', help="Config object. Required.")
|
| 64 |
parser.add_argument("--verbose", action='store_true', help="Config object. Required.")
|
| 65 |
return parser
|
| 66 |
|
|
|
|
| 21 |
|
| 22 |
config = {
|
| 23 |
'conf_threshold': float(args.conf_threshold),
|
|
|
|
|
|
|
| 24 |
'nms_iou': float(args.nms_iou),
|
| 25 |
'min_length': float(args.min_length),
|
| 26 |
'max_age': int(args.max_age),
|
| 27 |
'iou_threshold': float(args.iou_threshold),
|
| 28 |
'min_hits': int(args.min_hits),
|
| 29 |
+
'associativity': None
|
|
|
|
|
|
|
| 30 |
}
|
| 31 |
|
| 32 |
+
if (args.associativity.startswith("boost")):
|
| 33 |
+
config['associativity'] = "boost"
|
| 34 |
+
conf = args.associativity.split(":")
|
| 35 |
+
if len(conf) > 1: config['boost_power'] = float(conf[1])
|
| 36 |
+
if len(conf) > 2: config['boost_decay'] = float(conf[2])
|
| 37 |
+
if (args.associativity.startswith("bytetrack")):
|
| 38 |
+
config['associativity'] = "bytetrack"
|
| 39 |
+
conf = args.associativity.split(":")
|
| 40 |
+
if len(conf) > 1: config['low_conf_threshold'] = float(conf[1])
|
| 41 |
+
if len(conf) > 2: config['high_conf_threshold'] = float(conf[2])
|
| 42 |
+
|
| 43 |
print("verbose", args.verbose)
|
| 44 |
|
| 45 |
track(infer_args, config=config, verbose=args.verbose)
|
|
|
|
| 58 |
parser = argparse.ArgumentParser()
|
| 59 |
parser.add_argument("--detection_dir", default="../frames/detection_storage")
|
| 60 |
parser.add_argument("--conf_threshold", default=0.3, help="Config object. Required.")
|
|
|
|
|
|
|
| 61 |
parser.add_argument("--nms_iou", default=0.3, help="Config object. Required.")
|
| 62 |
parser.add_argument("--min_length", default=0.3, help="Config object. Required.")
|
| 63 |
parser.add_argument("--max_age", default=20, help="Config object. Required.")
|
| 64 |
parser.add_argument("--iou_threshold", default=0.01, help="Config object. Required.")
|
| 65 |
parser.add_argument("--min_hits", default=11, help="Config object. Required.")
|
| 66 |
+
parser.add_argument("--associativity", default='', help="Config object. Required.")
|
|
|
|
|
|
|
| 67 |
parser.add_argument("--verbose", action='store_true', help="Config object. Required.")
|
| 68 |
return parser
|
| 69 |
|