-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Wei-An Lin
committed
Apr 16, 2018
1 parent
b9211bd
commit afd389a
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import torch | ||
from torch.autograd import Variable | ||
|
||
use_cuda = torch.cuda.is_available() | ||
|
||
|
||
class RANTracker(object): | ||
def __init__(self, bbox, feature=None): | ||
self.bbox = bbox | ||
self.feature = feature | ||
self.h_bbox = 0 | ||
self.h_feature = 0 | ||
|
||
# use np array for this | ||
self.external_bbox = 0 | ||
self.externel_feature = 0 | ||
|
||
def update(self, bbox, feature=None): | ||
self.bbox = bbox | ||
self.feature = feature | ||
|
||
def predict(self, model): | ||
bbox = Variable(torch.from_numpy(self.bbox)).cuda() | ||
h_bbox = Variable(torch.from_numpy(self.h_bbox)).cuda() | ||
#update h, alpha, sigma using RAN | ||
alpha_bbox, sigma_bbox, self.h_bbox = model(bbox, h_bbox) | ||
|
||
self.alpha_bbox = alpha_bbox.data.cpu().to_numpy() | ||
self.sigma_bbox = sigma_bbox.data.cpu().to_numpy() | ||
|
||
def similarity(self, bbox, feature=None): | ||
""" | ||
Computes similarity between the new detection and this target | ||
""" |