mmtracking icon indicating copy to clipboard operation
mmtracking copied to clipboard

Hello! How to visualization the reid data.

Open 459737087 opened this issue 3 years ago • 11 comments

After training the reid model, how to visualization it

459737087 avatar Aug 23 '22 06:08 459737087

You can use the tool in mmcls: https://github.com/open-mmlab/mmclassification/blob/master/mmcls/core/visualization/image.py

JingweiZhang12 avatar Aug 23 '22 07:08 JingweiZhang12

Thank you!

459737087 avatar Aug 23 '22 08:08 459737087

when I train reid with my own dataset, But I find It demands me set a label 0 . Why it need the label 0 dataset @JingweiZhang12

459737087 avatar Aug 24 '22 05:08 459737087

File "/usr/local/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop data = fetcher.fetch(index) File "/usr/local/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/usr/local/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/usr/local/lib/python3.8/site-packages/mmcls/datasets/base_dataset.py", line 97, in getitem return self.prepare_data(idx) File "/output/mmtracking/mmtrack/datasets/reid_dataset.py", line 118, in prepare_data img_infos = self.triplet_sampling( File "/output/mmtracking/mmtrack/datasets/reid_dataset.py", line 103, in triplet_sampling neg_idxs = self.index_dic[neg_pid]

459737087 avatar Aug 24 '22 05:08 459737087

Please post your complete error log.

JingweiZhang12 avatar Aug 24 '22 06:08 JingweiZhang12

File "train.py", line 117, in main train_model(
File "/usr/local/lib/python3.8/site-packages/mmdet/apis/train.py", line 208, in train_detector runner.run(data_loaders, cfg.workflow) File "/usr/local/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 127, in run epoch_runner(data_loaders[i], **kwargs) File "/usr/local/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 47, in train for i, data_batch in enumerate(self.data_loader): File "/usr/local/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 530, in next data = self._next_data() File "/usr/local/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1224, in _next_data return self._process_data(data) File "/usr/local/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1250, in _process_data data.reraise() File "/usr/local/lib/python3.8/site-packages/torch/_utils.py", line 457, in reraise raise exception KeyError: Caught KeyError in DataLoader worker process 0. Original Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop data = fetcher.fetch(index) File "/usr/local/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/usr/local/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/usr/local/lib/python3.8/site-packages/mmcls/datasets/base_dataset.py", line 97, in getitem return self.prepare_data(idx) File "/output/mmtracking/mmtrack/datasets/reid_dataset", line 118, in prepare_data img_infos = self.triplet_sampling( File "/output/mmtracking/mmtrack/datasets/reid_dataset", line 103, in triplet_sampling neg_idxs = self.index_dic[neg_pid] KeyError: 0

ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1) local_rank: 0 (pid: 1836) of binary: /usr/local/bin/python

Traceback (most recent call last): File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.8/site-packages/torch/distributed/launch.py", line 193, in main() File "/usr/local/lib/python3.8/site-packages/torch/distributed/launch.py", line 189, in main launch(args) File "/usr/local/lib/python3.8/site-packages/torch/distributed/launch.py", line 174, in launch run(args) File "/usr/local/lib/python3.8/site-packages/torch/distributed/run.py", line 715, in run elastic_launch( File "/usr/local/lib/python3.8/site-packages/torch/distributed/launcher/api.py", line 131, in call return launch_agent(self._config, self._entrypoint, list(args)) File "/usr/local/lib/python3.8/site-packages/torch/distributed/launcher/api.py", line 245, in launch_agent raise ChildFailedError( torch.distributed.elastic.multiprocessing.errors.ChildFailedError:

openbayes.py FAILED

Failures: <NO_OTHER_FAILURES>

Root Cause (first observed failure): [0]: time : 2022-08-24_07:08:26 host : openbayesalgo-id35uyq9vjt3-main rank : 0 (local_rank: 0) exitcode : 1 (pid: 1836) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html

459737087 avatar Aug 24 '22 07:08 459737087

And. I have a confusuion about using mmcls to visualization the result, mmtrack predicting a tensor array such as

tensor([-0.0052, 0.0104, 0.0013, -0.0052, -0.0104, -0.0208, -0.0209, -0.0210,

    -0.0013,  0.0209, -0.0104, -0.0211,  0.0104, -0.0209, -0.0013,  0.0052,
     0.0208, -0.0105, -0.0208,  0.0052, -0.0026, -0.0210, -0.0104,  0.0210,
     0.0209, -0.0209,  0.0013,  0.0105,  0.0105, -0.0013,  0.0208,  0.0026,
     0.0052, -0.0026,  0.0208,  0.0104, -0.0104, -0.0104,  0.0026,  0.0104,
     0.0104,  0.0208, -0.0052, -0.0105,  0.0104,  0.0209,  0.0209, -0.0104,
     0.0002, -0.0208, -0.0026,  0.0052,  0.0026,  0.0052, -0.0105, -0.0052,
    -0.0104, -0.0208,  0.0104,  0.0104, -0.0052,  0.0052,  0.0052, -0.0026,
    -0.0013, -0.0208, -0.0209,  0.0208, -0.0104, -0.0104, -0.0208,  0.0208,
    -0.0208, -0.0209,  0.0052, -0.0104,  0.0209,  0.0104, -0.0052,  0.0208,
    -0.0208,  0.0209,  0.0209, -0.0104, -0.0013,  0.0209, -0.0104, -0.0208,
     0.0026, -0.0209, -0.0104,  0.0208,  0.0104,  0.0209,  0.0104,  0.0208,
     0.0104, -0.0208, -0.0052, -0.0104, -0.0210,  0.0208,  0.0104,  0.0052,
     0.0208,  0.0104, -0.0104,  0.0052,  0.0104,  0.0013, -0.0208, -0.0052,
    -0.0104,  0.0104, -0.0104, -0.0026,  0.0208, -0.0104, -0.0208,  0.0104,
     0.0209, -0.0210,  0.0104, -0.0104,  0.0052, -0.0208,  0.0104, -0.0104],
   device='cuda:0')]

but how to transplant to mmcls @JingweiZhang12

459737087 avatar Aug 24 '22 08:08 459737087

You can set breakpoint here: https://github.com/open-mmlab/mmtracking/blob/be8a7afbd719b7846a76caca74dd7f331036cdc3/mmtrack/datasets/reid_dataset.py#L52, and see how to generate self.index_dic.

JingweiZhang12 avatar Aug 24 '22 09:08 JingweiZhang12

You can use the tool in mmcls: https://github.com/open-mmlab/mmclassification/blob/master/mmcls/core/visualization/image.py

How can I visualize the CAM of the output?

noreenanwar avatar Aug 26 '22 10:08 noreenanwar

import mmcv

from mmcls.core import visualization as vis img_name = info['img_prefix']+"/"+info['img_info']['filename'] img1 = mmcv.imread(img_name) info1 = {} info1['gt_label'] = info['gt_label'] info1 = int(info1) with vis.ImshowInfosContextManager() as manager: manager.put_img_infos(img1, info1,out_file='w.png') manager.put_img_infos(img2, info2, out_file='2_out.png')

you can try this, But if you want to see reid data ,this way is valid @noreenanwar

459737087 avatar Aug 26 '22 10:08 459737087

import mmcv

from mmcls.core import visualization as vis img_name = info['img_prefix']+"/"+info['img_info']['filename'] img1 = mmcv.imread(img_name) info1 = {} info1['gt_label'] = info['gt_label'] info1 = int(info1) with vis.ImshowInfosContextManager() as manager: manager.put_img_infos(img1, info1,out_file='w.png') manager.put_img_infos(img2, info2, out_file='2_out.png')

you can try this, But if you want to see reid data ,this way is valid @noreenanwar

this is just for Reid data?

noreenanwar avatar Aug 26 '22 10:08 noreenanwar