Skip to content

Commit

Permalink
220620 fix issue #2 and issue #3
Browse files Browse the repository at this point in the history
  • Loading branch information
huuuuusy committed Jun 20, 2022
1 parent 1739b1b commit aaba774
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# VideoCube Python Toolkit

> UPDATE:<br>
> [2022.06.20] Update the [SiamFC](https://github.com/huuuuusy/videocube-toolkit/blob/master/tracker/siamfc.py) based on [issue #2](https://github.com/huuuuusy/videocube-toolkit/issues/2) and [issue #3](https://github.com/huuuuusy/videocube-toolkit/issues/3). <br>
> [2022.04.25] Update the [time](https://github.com/huuuuusy/videocube-toolkit/blob/master/videocube/trackers/__init__.py) calculation method based on [issue #1](https://github.com/huuuuusy/videocube-toolkit/issues/1). <br>
> [2022.03.03] Update the toolkit installation, dataset download instructions and a concise example. Now the basic function of this toolkit has been finished. <br>
Expand Down
17 changes: 9 additions & 8 deletions tracker/siamfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,7 @@ def __init__(self, net_path=None, **kargs):

# setup GPU device if available
self.cuda = torch.cuda.is_available()
self.cuda_num = torch.cuda.device_count()
if self.cuda_num == 0:
self.device = torch.device('cpu')
elif self.cuda_num == 1:
self.device = torch.device('cuda:0')
else:
self.device = torch.device('cuda:2,3')
#self.device = torch.device('cuda:0' if self.cuda else 'cpu')
self.device = torch.device('cuda:0' if self.cuda else 'cpu')

# setup model
self.net = SiamFC()
Expand Down Expand Up @@ -229,6 +222,14 @@ def update(self, image):
self.center[0] + 1 - (self.target_sz[0] - 1) / 2,
self.target_sz[1], self.target_sz[0]])

# to keep center not that rediculars, which effects self._crop_and_resize
# updated based on issue #2(https://github.com/huuuuusy/videocube-toolkit/issues/2), thanks a lot for MzeroMiko
if abs(self.center[0]) > 2 * height or abs(self.center[1]) > 2 * width:
print("WARNING: Force reset center. center:", self.center, ", size:", self.target_sz)
self.center[0] = height if self.center[0] > 0 else 0
self.center[1] = width if self.center[1] > 0 else 0


if box[0] < 0 or box[1] < 0 or box[0]+box[2] > width or box[1]+box[3] > height:
box = np.array([0,0,0,0])
return box
Expand Down

0 comments on commit aaba774

Please sign in to comment.