oskarastrom commited on
Commit
fb7d89a
·
1 Parent(s): ac33b94

Reversed tracking

Browse files
inference.py CHANGED
@@ -330,7 +330,7 @@ def do_tracking(all_preds, image_meter_width, image_meter_height, gp=None, max_a
330
 
331
  return json_data
332
 
333
- def do_associative_tracking(low_preds, high_preds, image_meter_width, image_meter_height, gp=None, low_thresh=0.2, high_threshold=0.2, max_age=MAX_AGE, iou_thres=IOU_THRES, min_hits=MIN_HITS, min_length=MIN_LENGTH, batch_size=BATCH_SIZE, verbose=True):
334
 
335
  if (gp): gp(0, "Tracking...")
336
 
@@ -342,11 +342,11 @@ def do_associative_tracking(low_preds, high_preds, image_meter_width, image_mete
342
  'image_meter_width': image_meter_width,
343
  'image_meter_height': image_meter_height
344
  }
345
- tracker = Tracker(clip_info, algorithm=Associate, reversed=True, args={ 'max_age': max_age, 'min_hits': 0, 'iou_threshold': iou_thres}, min_hits=min_hits)
346
 
347
  # Run tracking
348
  with tqdm(total=len(low_preds), desc="Running tracking", ncols=0, disable=not verbose) as pbar:
349
- for i, key in enumerate(sorted(low_preds.keys(), reverse=True)):
350
  if gp: gp(i / len(low_preds), pbar.__str__())
351
  low_boxes = low_preds[key]
352
  high_boxes = high_preds[key]
 
330
 
331
  return json_data
332
 
333
+ def do_associative_tracking(low_preds, high_preds, image_meter_width, image_meter_height, reverse=False, gp=None, max_age=MAX_AGE, iou_thres=IOU_THRES, min_hits=MIN_HITS, min_length=MIN_LENGTH, verbose=True):
334
 
335
  if (gp): gp(0, "Tracking...")
336
 
 
342
  'image_meter_width': image_meter_width,
343
  'image_meter_height': image_meter_height
344
  }
345
+ tracker = Tracker(clip_info, algorithm=Associate, reverse=reverse, args={ 'max_age': max_age, 'min_hits': 0, 'iou_threshold': iou_thres}, min_hits=min_hits)
346
 
347
  # Run tracking
348
  with tqdm(total=len(low_preds), desc="Running tracking", ncols=0, disable=not verbose) as pbar:
349
+ for i, key in enumerate(sorted(low_preds.keys(), reverse=reverse)):
350
  if gp: gp(i / len(low_preds), pbar.__str__())
351
  low_boxes = low_preds[key]
352
  high_boxes = high_preds[key]
lib/fish_eye/tracker.py CHANGED
@@ -9,13 +9,13 @@ from sort import Sort
9
  from associative import Associate
10
 
11
  class Tracker:
12
- def __init__(self, clip_info, algorithm=Sort, args={'max_age':1, 'min_hits':0, 'iou_threshold':0.05}, min_hits=3, reversed=False):
13
  self.algorithm = algorithm(**args)
14
  self.fish_ids = Counter()
15
- self.reversed = reversed
16
  self.min_hits = min_hits
17
  self.json_data = deepcopy(clip_info)
18
- if reversed:
19
  self.frame_id = self.json_data['end_frame']
20
  else:
21
  self.frame_id = self.json_data['start_frame']
@@ -63,7 +63,7 @@ class Tracker:
63
  'frame_num': self.frame_id,
64
  'fish': new_frame_entries
65
  })
66
- if self.reversed:
67
  self.frame_id -= 1
68
  else:
69
  self.frame_id += 1
 
9
  from associative import Associate
10
 
11
  class Tracker:
12
+ def __init__(self, clip_info, algorithm=Sort, args={'max_age':1, 'min_hits':0, 'iou_threshold':0.05}, min_hits=3, reverse=False):
13
  self.algorithm = algorithm(**args)
14
  self.fish_ids = Counter()
15
+ self.reverse = reverse
16
  self.min_hits = min_hits
17
  self.json_data = deepcopy(clip_info)
18
+ if reverse:
19
  self.frame_id = self.json_data['end_frame']
20
  else:
21
  self.frame_id = self.json_data['start_frame']
 
63
  'frame_num': self.frame_id,
64
  'fish': new_frame_entries
65
  })
66
+ if self.reverse:
67
  self.frame_id -= 1
68
  else:
69
  self.frame_id += 1
scripts/detect_frames.py CHANGED
@@ -31,7 +31,7 @@ def main(args, verbose=True):
31
  model, device = setup_model(args.weights)
32
 
33
  locations = [
34
- "kenai-val"
35
  ]
36
  for loc in locations:
37
 
 
31
  model, device = setup_model(args.weights)
32
 
33
  locations = [
34
+ "kenai-rightbank"
35
  ]
36
  for loc in locations:
37
 
scripts/track_detection.py CHANGED
@@ -42,7 +42,7 @@ def main(args, config={}, verbose=True):
42
 
43
 
44
  locations = [
45
- "kenai-val"
46
  ]
47
  for loc in locations:
48
 
@@ -109,7 +109,7 @@ def track(in_loc_dir, out_loc_dir, metadata_path, seq, config, verbose):
109
  high_outputs = do_suppression(inference, conf_thres=config['high_conf_threshold'], iou_thres=config['nms_iou'], verbose=verbose)
110
  high_preds, real_width, real_height = format_predictions(image_shapes, high_outputs, width, height, verbose=verbose)
111
 
112
- results = do_associative_tracking(low_preds, high_preds, image_meter_width, image_meter_height, min_length=config['min_length'], max_age=config['max_age'], iou_thres=config['iou_threshold'], min_hits=config['min_hits'], verbose=verbose)
113
  else:
114
  outputs = do_suppression(inference, conf_thres=config['conf_threshold'], iou_thres=config['nms_iou'], verbose=verbose)
115
 
 
42
 
43
 
44
  locations = [
45
+ "kenai-rightbank"
46
  ]
47
  for loc in locations:
48
 
 
109
  high_outputs = do_suppression(inference, conf_thres=config['high_conf_threshold'], iou_thres=config['nms_iou'], verbose=verbose)
110
  high_preds, real_width, real_height = format_predictions(image_shapes, high_outputs, width, height, verbose=verbose)
111
 
112
+ results = do_associative_tracking(low_preds, high_preds, image_meter_width, image_meter_height, reverse=False, min_length=config['min_length'], max_age=config['max_age'], iou_thres=config['iou_threshold'], min_hits=config['min_hits'], verbose=verbose)
113
  else:
114
  outputs = do_suppression(inference, conf_thres=config['conf_threshold'], iou_thres=config['nms_iou'], verbose=verbose)
115