Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SiamFC with pretrained would run slower and slower #2

Closed
MzeroMiko opened this issue Jun 19, 2022 · 3 comments
Closed

SiamFC with pretrained would run slower and slower #2

MzeroMiko opened this issue Jun 19, 2022 · 3 comments

Comments

@MzeroMiko
Copy link

MzeroMiko commented Jun 19, 2022

ISSUE and CAUSE:
we find that when using SiamFC with pretrained model in this toolkit, the code would get slower and slower (from <1 second to even > 2 minutes per sample). When using SiamFC without pretraining, we did not find this issue.
Then we find out that is because the SiamFC with pretrained predict a bad center: the center get out of the image and fly far and far way, which makes the function siamfc.py: TrackerSiamFC._crop_and_resize run slower and slower.

SOLUTION:
we just add some code in siamfc.py: TrackerSiamFC.update to restrict the center within (-2height, 2height) x (-2width, 2width) and solve this issue

# return 1-indexed and left-top based bounding box
        box = np.array([
            self.center[1] + 1 - (self.target_sz[1] - 1) / 2,
            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
        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
huuuuusy added a commit that referenced this issue Jun 20, 2022
@huuuuusy
Copy link
Owner

Thanks a lot; I have updated the codes based on your suggestion.

@zugofn
Copy link

zugofn commented Jun 22, 2022

Hi!
How about the test FPS after modify the code?
It takes me a few days to test the entire dataset.

@MzeroMiko
Copy link
Author

MzeroMiko commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants