SysCV / qdtrack

Quasi-Dense Similarity Learning for Multiple Object Tracking, CVPR 2021 (Oral)
Apache License 2.0
384 stars 61 forks source link

KeyError: 'frame_id' when using inference_model from inference api #92

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello. I tried to use the inference API. Here is my code:

model = init_model('trackers/qdtrack/configs/tao/qdtrack_frcnn_r101_fpn_12e_tao_ft.py',
                           'trackers/qdtrack/weights/qdtrack_tao_20210812_221438-b6bd07e2.pth')
        for img_file in img_files:
            img_file_path = os.path.join(session, 'org-imgs', img_file)
            results = inference_model(model, img_file_path, img_files.index(img_file))

However, I get the following error:

/home/muhammadmehdi/anaconda3/envs/memex/lib/python3.7/site-packages/mmdet/core/anchor/builder.py:16: UserWarning: ``build_anchor_generator`` would be deprecated soon, please use ``build_prior_generator`` 
  '``build_anchor_generator`` would be deprecated soon, please use '
Use load_from_local loader
/home/muhammadmehdi/anaconda3/envs/memex/lib/python3.7/site-packages/mmdet/datasets/utils.py:68: UserWarning: "ImageToTensor" pipeline is replaced by "DefaultFormatBundle" for batch inference. It is recommended to manually replace it in the test data pipeline in your config file.
  'data pipeline in your config file.', UserWarning)
Traceback (most recent call last):
  File "/home/muhammadmehdi/ALL_PROJECTS/memex/run_offline.py", line 28, in <module>
    run_algo(session_root)
  File "/home/muhammadmehdi/ALL_PROJECTS/memex/algorithm.py", line 49, in run_algo
    session)
  File "/home/muhammadmehdi/ALL_PROJECTS/memex/algorithm.py", line 191, in run_auto
    tracks = utils.get_tracks(img_files, session)
  File "/home/muhammadmehdi/ALL_PROJECTS/memex/utils/tracker.py", line 59, in get_tracks
    results = inference_model(model, img_file_path, img_files.index(img_file))
  File "/home/muhammadmehdi/ALL_PROJECTS/memex/trackers/qdtrack/qdtrack/apis/inference.py", line 87, in inference_model
    data = test_pipeline(data)
  File "/home/muhammadmehdi/anaconda3/envs/memex/lib/python3.7/site-packages/mmdet/datasets/pipelines/compose.py", line 40, in __call__
    data = t(data)
  File "/home/muhammadmehdi/anaconda3/envs/memex/lib/python3.7/site-packages/mmdet/datasets/pipelines/test_time_aug.py", line 106, in __call__
    data = self.transforms(_results)
  File "/home/muhammadmehdi/anaconda3/envs/memex/lib/python3.7/site-packages/mmdet/datasets/pipelines/compose.py", line 40, in __call__
    data = t(data)
  File "/home/muhammadmehdi/anaconda3/envs/memex/lib/python3.7/site-packages/mmdet/datasets/pipelines/formating.py", line 315, in __call__
    img_meta[key] = results[key]
KeyError: 'frame_id'

Process finished with exit code 1
OceanPang commented 3 years ago

Sorry that the inference_model is now a copy from mmdet and not supported for tracking yet. You can directly inference the model with test.py