ifzhang / ByteTrack

[ECCV 2022] ByteTrack: Multi-Object Tracking by Associating Every Detection Box
MIT License
4.8k stars 906 forks source link

the fps number is not matched #156

Open arhow opened 2 years ago

arhow commented 2 years ago

hi, I tried the demo_track. and got this log

2022-03-04 00:51:52.284 | INFO | main:main:316 - Args: Namespace(aspect_ratio_thresh=1.6, camid=0, ckpt='/content/drive/MyDrive/tracking_data/bytetrack_x_mot17.pth.tar', conf=None, demo='video', device=device(type='cuda'), exp_file='exps/example/mot/yolox_x_mix_det.py', experiment_name='yolox_x_mix_det', fp16=True, fps=30, fuse=True, match_thresh=0.8, min_box_area=10, mot20=False, name=None, nms=None, path='/content/drive/MyDrive/tracking_data/2022-0114-D1_ld.mp4', save_result=True, track_buffer=30, track_thresh=0.5, trt=False, tsize=None) /usr/local/lib/python3.7/dist-packages/torch/functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:2157.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] 2022-03-04 00:51:56.724 | INFO | main:main:326 - Model Summary: Params: 99.00M, Gflops: 791.73 2022-03-04 00:51:56.727 | INFO | main:main:334 - loading checkpoint 2022-03-04 00:52:10.154 | INFO | main:main:338 - loaded checkpoint done. 2022-03-04 00:52:10.154 | INFO | main:main:341 - Fusing model... /usr/local/lib/python3.7/dist-packages/torch/_tensor.py:1013: UserWarning: The .grad attribute of a Tensor that is not a leaf Tensor is being accessed. Its .grad attribute won't be populated during autograd.backward(). If you indeed want the .grad field to be populated for a non-leaf Tensor, use .retain_grad() on the non-leaf Tensor. If you access the non-leaf Tensor by mistake, make sure you access the leaf Tensor instead. See github.com/pytorch/pytorch/pull/30531 for more informations. (Triggered internally at aten/src/ATen/core/TensorBody.h:417.) return self._grad 2022-03-04 00:52:11.869 | INFO | main:imageflow_demo:248 - video save_path is ./YOLOX_outputs/yolox_x_mix_det/track_vis/2022_03_04_00_52_11/2022-0114-D1_ld.mp4 2022-03-04 00:52:11.879 | INFO | main:imageflow_demo:258 - Processing frame 0 (100000.00 fps) 2022-03-04 00:52:17.324 | INFO | main:imageflow_demo:258 - Processing frame 20 (7.03 fps) 2022-03-04 00:52:22.613 | INFO | main:imageflow_demo:258 - Processing frame 40 (7.12 fps) 2022-03-04 00:52:27.877 | INFO | main:imageflow_demo:258 - Processing frame 60 (7.15 fps) 2022-03-04 00:52:33.138 | INFO | main:imageflow_demo:258 - Processing frame 80 (7.16 fps) 2022-03-04 00:52:38.400 | INFO | main:imageflow_demo:258 - Processing frame 100 (7.17 fps) 2022-03-04 00:52:43.660 | INFO | main:imageflow_demo:258 - Processing frame 120 (7.18 fps) 2022-03-04 00:52:48.926 | INFO | main:imageflow_demo:258 - Processing frame 140 (7.18 fps) 2022-03-04 00:52:54.200 | INFO | main:imageflow_demo:258 - Processing frame 160 (7.18 fps) 2022-03-04 00:52:59.452 | INFO | main:imageflow_demo:258 - Processing frame 180 (7.18 fps) 2022-03-04 00:53:04.717 | INFO | main:imageflow_demo:258 - Processing frame 200 (7.18 fps) 2022-03-04 00:53:09.945 | INFO | main:imageflow_demo:258 - Processing frame 220 (7.19 fps) 2022-03-04 00:53:15.204 | INFO | main:imageflow_demo:258 - Processing frame 240 (7.19 fps) 2022-03-04 00:53:20.429 | INFO | main:imageflow_demo:258 - Processing frame 260 (7.19 fps) 2022-03-04 00:53:25.684 | INFO | main:imageflow_demo:258 - Processing frame 280 (7.19 fps) 2022-03-04 00:53:30.905 | INFO | main:imageflow_demo:258 - Processing frame 300 (7.19 fps) 2022-03-04 00:53:36.163 | INFO | main:imageflow_demo:258 - Processing frame 320 (7.19 fps) 2022-03-04 00:53:41.370 | INFO | main:imageflow_demo:258 - Processing frame 340 (7.19 fps) 2022-03-04 00:53:46.637 | INFO | main:imageflow_demo:258 - Processing frame 360 (7.20 fps) 2022-03-04 00:53:51.850 | INFO | main:imageflow_demo:258 - Processing frame 380 (7.20 fps) 2022-03-04 00:53:57.090 | INFO | main:imageflow_demo:258 - Processing frame 400 (7.20 fps) 2022-03-04 00:54:02.309 | INFO | main:imageflow_demo:258 - Processing frame 420 (7.20 fps) 2022-03-04 00:54:07.582 | INFO | main:imageflow_demo:258 - Processing frame 440 (7.20 fps) 2022-03-04 00:54:12.808 | INFO | main:imageflow_demo:258 - Processing frame 460 (7.20 fps) 2022-03-04 00:54:18.081 | INFO | main:imageflow_demo:258 - Processing frame 480 (7.20 fps) 2022-03-04 00:54:23.324 | INFO | main:imageflow_demo:258 - Processing frame 500 (7.20 fps) 2022-03-04 00:54:28.560 | INFO | main:imageflow_demo:258 - Processing frame 520 (7.20 fps) 2022-03-04 00:54:33.798 | INFO | main:imageflow_demo:258 - Processing frame 540 (7.20 fps) 2022-03-04 00:54:39.063 | INFO | main:imageflow_demo:258 - Processing frame 560 (7.20 fps) 2022-03-04 00:54:44.301 | INFO | main:imageflow_demo:258 - Processing frame 580 (7.20 fps) 2022-03-04 00:54:49.552 | INFO | main:imageflow_demo:258 - Processing frame 600 (7.20 fps) 2022-03-04 00:54:54.802 | INFO | main:imageflow_demo:258 - Processing frame 620 (7.20 fps) 2022-03-04 00:55:00.058 | INFO | main:imageflow_demo:258 - Processing frame 640 (7.20 fps) 2022-03-04 00:55:05.289 | INFO | main:imageflow_demo:258 - Processing frame 660 (7.20 fps) 2022-03-04 00:55:10.553 | INFO | main:imageflow_demo:258 - Processing frame 680 (7.20 fps) 2022-03-04 00:55:15.745 | INFO | main:imageflow_demo:258 - Processing frame 700 (7.20 fps) 2022-03-04 00:55:20.995 | INFO | main:imageflow_demo:258 - Processing frame 720 (7.20 fps) 2022-03-04 00:55:26.215 | INFO | main:imageflow_demo:258 - Processing frame 740 (7.20 fps) 2022-03-04 00:55:31.444 | INFO | main:imageflow_demo:258 - Processing frame 760 (7.20 fps) 2022-03-04 00:55:36.673 | INFO | main:imageflow_demo:258 - Processing frame 780 (7.20 fps) 2022-03-04 00:55:41.920 | INFO | main:imageflow_demo:258 - Processing frame 800 (7.20 fps) 2022-03-04 00:55:47.196 | INFO | main:imageflow_demo:258 - Processing frame 820 (7.20 fps) 2022-03-04 00:55:52.460 | INFO | main:imageflow_demo:258 - Processing frame 840 (7.20 fps) 2022-03-04 00:55:57.677 | INFO | main:imageflow_demo:258 - Processing frame 860 (7.20 fps) 2022-03-04 00:56:02.949 | INFO | main:imageflow_demo:258 - Processing frame 880 (7.20 fps) 2022-03-04 00:56:08.173 | INFO | main:imageflow_demo:258 - Processing frame 900 (7.20 fps) 2022-03-04 00:56:13.447 | INFO | main:imageflow_demo:258 - Processing frame 920 (7.20 fps) 2022-03-04 00:56:18.683 | INFO | main:imageflow_demo:258 - Processing frame 940 (7.20 fps) 2022-03-04 00:56:23.927 | INFO | main:imageflow_demo:258 - Processing frame 960 (7.20 fps) 2022-03-04 00:56:29.145 | INFO | main:imageflow_demo:258 - Processing frame 980 (7.20 fps) 2022-03-04 00:56:34.421 | INFO | main:imageflow_demo:258 - Processing frame 1000 (7.20 fps) 2022-03-04 00:56:39.621 | INFO | main:imageflow_demo:258 - Processing frame 1020 (7.20 fps) 2022-03-04 00:56:44.876 | INFO | main:imageflow_demo:258 - Processing frame 1040 (7.20 fps) 2022-03-04 00:56:50.087 | INFO | main:imageflow_demo:258 - Processing frame 1060 (7.20 fps) 2022-03-04 00:56:55.359 | INFO | main:imageflow_demo:258 - Processing frame 1080 (7.20 fps) 2022-03-04 00:57:00.566 | INFO | main:imageflow_demo:258 - Processing frame 1100 (7.20 fps) 2022-03-04 00:57:05.821 | INFO | main:imageflow_demo:258 - Processing frame 1120 (7.20 fps) 2022-03-04 00:57:11.052 | INFO | main:imageflow_demo:258 - Processing frame 1140 (7.20 fps) 2022-03-04 00:57:16.359 | INFO | main:imageflow_demo:258 - Processing frame 1160 (7.20 fps) 2022-03-04 00:57:21.682 | INFO | main:imageflow_demo:258 - Processing frame 1180 (7.20 fps) 2022-03-04 00:57:26.963 | INFO | main:imageflow_demo:258 - Processing frame 1200 (7.20 fps) 2022-03-04 00:57:32.221 | INFO | main:imageflow_demo:258 - Processing frame 1220 (7.20 fps) 2022-03-04 00:57:37.486 | INFO | main:imageflow_demo:258 - Processing frame 1240 (7.20 fps) 2022-03-04 00:57:42.862 | INFO | main:imageflow_demo:258 - Processing frame 1260 (7.20 fps) 2022-03-04 00:57:48.098 | INFO | main:imageflow_demo:258 - Processing frame 1280 (7.20 fps) 2022-03-04 00:57:53.334 | INFO | main:imageflow_demo:258 - Processing frame 1300 (7.20 fps) 2022-03-04 00:57:58.543 | INFO | main:imageflow_demo:258 - Processing frame 1320 (7.20 fps) 2022-03-04 00:58:03.748 | INFO | main:imageflow_demo:258 - Processing frame 1340 (7.20 fps) 2022-03-04 00:58:08.987 | INFO | main:imageflow_demo:258 - Processing frame 1360 (7.20 fps) 2022-03-04 00:58:14.192 | INFO | main:imageflow_demo:258 - Processing frame 1380 (7.20 fps) 2022-03-04 00:58:19.450 | INFO | main:imageflow_demo:258 - Processing frame 1400 (7.20 fps) 2022-03-04 00:58:24.731 | INFO | main:imageflow_demo:258 - Processing frame 1420 (7.20 fps) 2022-03-04 00:58:29.972 | INFO | main:imageflow_demo:258 - Processing frame 1440 (7.20 fps) 2022-03-04 00:58:35.175 | INFO | main:imageflow_demo:258 - Processing frame 1460 (7.20 fps) 2022-03-04 00:58:40.436 | INFO | main:imageflow_demo:258 - Processing frame 1480 (7.20 fps) 2022-03-04 00:58:45.634 | INFO | main:imageflow_demo:258 - Processing frame 1500 (7.20 fps) 2022-03-04 00:58:50.880 | INFO | main:imageflow_demo:258 - Processing frame 1520 (7.20 fps) 2022-03-04 00:58:56.103 | INFO | main:imageflow_demo:258 - Processing frame 1540 (7.20 fps) 2022-03-04 00:59:01.284 | INFO | main:imageflow_demo:258 - Processing frame 1560 (7.20 fps) 2022-03-04 00:59:06.500 | INFO | main:imageflow_demo:258 - Processing frame 1580 (7.20 fps) 2022-03-04 00:59:11.678 | INFO | main:imageflow_demo:258 - Processing frame 1600 (7.20 fps) 2022-03-04 00:59:16.829 | INFO | main:imageflow_demo:258 - Processing frame 1620 (7.20 fps) 2022-03-04 00:59:22.007 | INFO | main:imageflow_demo:258 - Processing frame 1640 (7.20 fps) 2022-03-04 00:59:27.217 | INFO | main:imageflow_demo:258 - Processing frame 1660 (7.20 fps) 2022-03-04 00:59:32.399 | INFO | main:imageflow_demo:258 - Processing frame 1680 (7.20 fps) 2022-03-04 00:59:37.564 | INFO | main:imageflow_demo:258 - Processing frame 1700 (7.20 fps) 2022-03-04 00:59:42.762 | INFO | main:imageflow_demo:258 - Processing frame 1720 (7.20 fps) 2022-03-04 00:59:47.963 | INFO | main:imageflow_demo:258 - Processing frame 1740 (7.20 fps) 2022-03-04 00:59:53.126 | INFO | main:imageflow_demo:258 - Processing frame 1760 (7.20 fps) 2022-03-04 00:59:58.297 | INFO | main:imageflow_demo:258 - Processing frame 1780 (7.20 fps) 2022-03-04 00:59:59.589 | INFO | main:imageflow_demo:298 - save results to ./YOLOX_outputs/yolox_x_mix_det/track_vis/2022_03_04_00_52_11.txt

I did the rough fps calculation by myself. the start datetime is 2022-03-04 00:52:11.879. the end datetime is 2022-03-04 00:59:59.589. there are 1780 frames.

fps = 1780/(end-start).seconds = 3.8

I tried the code on google colab. is my fps calculation wrong? I really confused.

iAmNikola commented 2 years ago

Yeah I think they messed up something with the Timer class from timer.py.

I get 25 FPS with the Timer calculation, but I think it's wrong.

Importing tqdm and changing this line to for i in tqdm(range(2000)): i get around 7-8 iters per second, meaning that the speed of inference is actually 7-8 FPS and not the advertised 20+.

Inthuch95 commented 2 years ago

demo_track.py

You should move timer.tic() from line 167 to line 159 to get accurate FPS. Currently it does not include preproc() function in FPS calculation.

yihongXU commented 2 years ago

Hi, Nice work! I am also testing the FPS. One question: do we need to do torch.cuda.synchronize() before running time.time() since we are using the GPU?

Thank you!