Skip to content

Commit

Permalink
add visualization.py for sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
Wei-An Lin committed Apr 17, 2018
1 parent d47bbc8 commit 6f9c687
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/trackers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import torch
from torch.autograd import Variable
import numpy as np
import math
from sklearn.utils.linear_assignment_ import linear_assignment
from scipy.optimize import linear_sum_assignment
from collections import deque
Expand Down Expand Up @@ -122,8 +123,14 @@ def similarity(self, bbox, feature=None):
Computes similarity between the RANTrack and the new detection
"""

# linear combination of instances in the external memory using alpha
pass
# compute log probability
diff2 = torch.pow(self.mu_bbox - bbox, 2)
M = (diff2 / self.sigma_bbox).sum()
log_scale = self.sigma_bbox.log().sum()

constant = math.log(2 * math.pi) * len(bbox)

return -0.5 * (constant + log_scale + M)


class RANTracker(object):
Expand Down
42 changes: 42 additions & 0 deletions src/visualization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os
import numpy as np
import time
from skimage import io
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from utils import load_mot16_gt

file_path = '/scratch0/MOT/MOT16/'

gt, train_seq = load_mot16_gt(file_path)

colours = np.random.rand(32, 3)
plt.ion()
fig = plt.figure(figsize=(16, 12))


for num in range(0, 50):
fn = os.path.join(file_path, 'train', 'MOT16-13', 'img1', '{:06d}.jpg'.format(num+1))

im = io.imread(fn)
ax1 = fig.add_subplot(111, aspect='equal')
ax1.imshow(im)

tracks = gt[0][gt[0]['frame_num'] == num]
mask = tracks['track_id'] == 8
bboxes = tracks[['x', 'y', 'w', 'h', 'track_id', 'class']][mask]

# select_bboxes = bboxes[bboxes[:, 4] == 7]


for bbox in bboxes:
bbox = np.array(bbox.tolist(), dtype=np.int32)
bbox[0:2] -= bbox[2:4] // 2
ax1.add_patch(patches.Rectangle((bbox[0], bbox[1]), bbox[2], bbox[3], fill=False, lw=1, ec=colours[bbox[4]%32,:]))
ax1.set_adjustable('box-forced')
print(bbox[5])


fig.canvas.flush_events()
plt.draw()
ax1.cla()

0 comments on commit 6f9c687

Please sign in to comment.