From aaba774b79c14b7ea23f78812ea9eb2186cfd0df Mon Sep 17 00:00:00 2001 From: huuuuusy Date: Mon, 20 Jun 2022 11:33:27 +0800 Subject: [PATCH] 220620 fix issue #2 and issue #3 --- README.md | 1 + tracker/siamfc.py | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 14f4ee7..8487a5d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # VideoCube Python Toolkit > UPDATE:
+> [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).
> [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).
> [2022.03.03] Update the toolkit installation, dataset download instructions and a concise example. Now the basic function of this toolkit has been finished.
diff --git a/tracker/siamfc.py b/tracker/siamfc.py index 7906bb2..f9d3b6f 100644 --- a/tracker/siamfc.py +++ b/tracker/siamfc.py @@ -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() @@ -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