Skip to content

vittrack(gsoc realtime object tracking model)#24201

Merged
asmorkalov merged 14 commits intoopencv:4.xfrom
lpylpy0514:4.x
Sep 19, 2023
Merged

vittrack(gsoc realtime object tracking model)#24201
asmorkalov merged 14 commits intoopencv:4.xfrom
lpylpy0514:4.x

Conversation

@lpylpy0514
Copy link
Copy Markdown
Contributor

@lpylpy0514 lpylpy0514 commented Aug 27, 2023

Vit tracker(vision transformer tracker) is a much better model for real-time object tracking. Vit tracker can achieve speeds exceeding nanotrack by 20% in single-threaded mode with ARM chip, and the advantage becomes even more pronounced in multi-threaded mode. In addition, on the dataset, vit tracker demonstrates better performance compared to nanotrack. Moreover, vit trackerprovides confidence values during the tracking process, which can be used to determine if the tracking is currently lost.
opencv_zoo: opencv/opencv_zoo#194
opencv_extra: opencv/opencv_extra#1088

Performance comparison is as follows:

NOTE: The speed below is tested by onnxruntime because opencv has poor support for the transformer architecture for now.

ONNX speed test on ARM platform(apple M2)(ms):

thread nums 1 2 3 4
nanotrack 5.25 4.86 4.72 4.49
vit tracker 4.18 2.41 1.97 1.46 (3X)

ONNX speed test on x86 platform(intel i3 10105)(ms):

thread nums 1 2 3 4
nanotrack 3.20 2.75 2.46 2.55
vit tracker 3.84 2.37 2.10 2.01

opencv speed test on x86 platform(intel i3 10105)(ms):

thread nums 1 2 3 4
vit tracker 31.3 31.4 31.4 31.4

preformance test on lasot dataset(AUC is the most important data. Higher AUC means better tracker):

LASOT AUC P Pnorm
nanotrack 46.8 45.0 43.3
vit tracker 48.6 44.8 54.7

https://youtu.be/MJiPnu1ZQRI
In target tracking tasks, the score is an important indicator that can indicate whether the current target is lost. In the video, vit tracker can track the target and display the current score in the upper left corner of the video. When the target is lost, the score drops significantly. While nanotrack will only return 0.9 score in any situation, so that we cannot determine whether the target is lost.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@zihaomu zihaomu self-assigned this Aug 28, 2023
@zihaomu zihaomu added the GSoC label Aug 28, 2023
@zihaomu zihaomu changed the title vttrack(gsoc realtime object tracking model) vittrack(gsoc realtime object tracking model) Aug 28, 2023
Copy link
Copy Markdown
Member

@zihaomu zihaomu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look.

Copy link
Copy Markdown
Member

@zihaomu zihaomu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

@asmorkalov asmorkalov added this to the 4.9.0 milestone Sep 8, 2023
Comment on lines +90 to +91
cv::Scalar meanvalue(0.485, 0.456, 0.406);
cv::Scalar stdvalue(0.229, 0.224, 0.225);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to move it to parameters. In case if users re-trained the model they can use custom pre-proc params.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any sample code available for reference?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually these parameters are from the classic ImageNet image classification. Basically everybody uses these params by default. I dont see anyone changing them in any practical sense.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The model may be re-trained for YUV or use-cases that are not classical RGB imaging in science, medicine, etc.

@@ -0,0 +1,176 @@
// VitTracker
// model: https://github.com/opencv/opencv_extra/blob/4.x/testdata/dnn/onnx/models/vitTracker.onnx
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use opencv_zoo too to avoid mess of different sources

Also it makes sense to dump suggested model path in --help mode.

Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me in general. Tested manually with Ubuntu and Camera. I propose to extract mean and std to the class parameters with existing default values and then merge.

@asmorkalov asmorkalov merged commit 70d7e83 into opencv:4.x Sep 19, 2023
asmorkalov pushed a commit to opencv/opencv_extra that referenced this pull request Sep 19, 2023
VIT track(gsoc realtime object tracking model) #1088

add an onnx model for opencv vttrack PR opencv/opencv#24201
asmorkalov pushed a commit to opencv/opencv_zoo that referenced this pull request Sep 19, 2023
Add VIT track model and demo #194

GSOC Realtime tracking model
opencv repo PR link is [here](opencv/opencv#24201)
@opencv-alalek
Copy link
Copy Markdown
Contributor

@asmorkalov Why do you merge large PR without CI checks? We should run extended scope of tests in that case instead of ignoring them.

Debug builds are broken.

@asmorkalov asmorkalov mentioned this pull request Sep 20, 2023
6 tasks
@asmorkalov asmorkalov mentioned this pull request Sep 28, 2023
thewoz pushed a commit to thewoz/opencv that referenced this pull request Jan 4, 2024
VIT track(gsoc realtime object tracking model) opencv#24201

Vit tracker(vision transformer tracker) is a much better model for real-time object tracking. Vit tracker can achieve speeds exceeding nanotrack by 20% in single-threaded mode with ARM chip, and the advantage becomes even more pronounced in multi-threaded mode. In addition, on the dataset, vit tracker demonstrates better performance compared to nanotrack. Moreover, vit trackerprovides confidence values during the tracking process, which can be used to determine if the tracking is currently lost.
opencv_zoo: opencv/opencv_zoo#194
opencv_extra: [https://github.com/opencv/opencv_extra/pull/1088](https://github.com/opencv/opencv_extra/pull/1088)

# Performance comparison is as follows:
NOTE: The speed below is tested by **onnxruntime** because opencv has poor support for the transformer architecture for now.

ONNX speed test on ARM platform(apple M2)(ms):
| thread nums | 1| 2| 3| 4|
|--------|--------|--------|--------|--------|
| nanotrack| 5.25| 4.86| 4.72| 4.49|
| vit tracker| 4.18| 2.41| 1.97| **1.46 (3X)**|

ONNX speed test on x86 platform(intel i3 10105)(ms):
| thread nums | 1| 2| 3| 4|
|--------|--------|--------|--------|--------|
| nanotrack|3.20|2.75|2.46|2.55|
| vit tracker|3.84|2.37|2.10|2.01|

opencv speed test on x86 platform(intel i3 10105)(ms):
| thread nums | 1| 2| 3| 4|
|--------|--------|--------|--------|--------|
| vit tracker|31.3|31.4|31.4|31.4|

preformance test on lasot dataset(AUC is the most important data. Higher AUC means better tracker):

|LASOT | AUC| P| Pnorm|
|--------|--------|--------|--------|
| nanotrack| 46.8| 45.0| 43.3|
| vit tracker| 48.6| 44.8| 54.7|

[https://youtu.be/MJiPnu1ZQRI](https://youtu.be/MJiPnu1ZQRI)
 In target tracking tasks, the score is an important indicator that can indicate whether the current target is lost. In the video, vit tracker can track the target and display the current score in the upper left corner of the video. When the target is lost, the score drops significantly. While nanotrack will only return 0.9 score in any situation, so that we cannot determine whether the target is lost.

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
thewoz pushed a commit to thewoz/opencv that referenced this pull request May 29, 2024
VIT track(gsoc realtime object tracking model) opencv#24201

Vit tracker(vision transformer tracker) is a much better model for real-time object tracking. Vit tracker can achieve speeds exceeding nanotrack by 20% in single-threaded mode with ARM chip, and the advantage becomes even more pronounced in multi-threaded mode. In addition, on the dataset, vit tracker demonstrates better performance compared to nanotrack. Moreover, vit trackerprovides confidence values during the tracking process, which can be used to determine if the tracking is currently lost.
opencv_zoo: opencv/opencv_zoo#194
opencv_extra: [https://github.com/opencv/opencv_extra/pull/1088](https://github.com/opencv/opencv_extra/pull/1088)

# Performance comparison is as follows:
NOTE: The speed below is tested by **onnxruntime** because opencv has poor support for the transformer architecture for now.

ONNX speed test on ARM platform(apple M2)(ms):
| thread nums | 1| 2| 3| 4|
|--------|--------|--------|--------|--------|
| nanotrack| 5.25| 4.86| 4.72| 4.49|
| vit tracker| 4.18| 2.41| 1.97| **1.46 (3X)**|

ONNX speed test on x86 platform(intel i3 10105)(ms):
| thread nums | 1| 2| 3| 4|
|--------|--------|--------|--------|--------|
| nanotrack|3.20|2.75|2.46|2.55|
| vit tracker|3.84|2.37|2.10|2.01|

opencv speed test on x86 platform(intel i3 10105)(ms):
| thread nums | 1| 2| 3| 4|
|--------|--------|--------|--------|--------|
| vit tracker|31.3|31.4|31.4|31.4|

preformance test on lasot dataset(AUC is the most important data. Higher AUC means better tracker):

|LASOT | AUC| P| Pnorm|
|--------|--------|--------|--------|
| nanotrack| 46.8| 45.0| 43.3|
| vit tracker| 48.6| 44.8| 54.7|

[https://youtu.be/MJiPnu1ZQRI](https://youtu.be/MJiPnu1ZQRI)
 In target tracking tasks, the score is an important indicator that can indicate whether the current target is lost. In the video, vit tracker can track the target and display the current score in the upper left corner of the video. When the target is lost, the score drops significantly. While nanotrack will only return 0.9 score in any situation, so that we cannot determine whether the target is lost.

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants