Wuziyi616 / LEOD

Code release for CVPR 2024 paper LEOD: Label-Efficient Object Detection for Event Cameras
MIT License
30 stars 3 forks source link

The mp4 files is not getting generated or saved to ./vis/gen1_rnndet_small/pred/ #1

Closed Tushar-Isamaliya closed 6 months ago

Tushar-Isamaliya commented 6 months ago

Problem: The video .mp4 is not getting generated in given folder (/vis/gen1_rnndet_small/pred/) but code runs successfully.

after successful run of the visualisation code :

python vis_pred.py model=rnndet dataset=gen1 dataset.path=./datasets/gen1/ checkpoint="pretrained/Sec.4.2-WSOD_SSOD/gen1-WSOD/rvt-s-gen1x0.01_ss-final.ckpt" +experiment/gen1="small.yaml" model.postprocess.confidence_threshold=0.1 num_video=5 reverse=False

Using python-based detection evaluation Set MaxViTRNN backbone (height, width) to (256, 320) Set partition sizes: (8, 10) Set num_classes=2 for detection head Found 46 sequences in datasets/gen1/test Using 1.25% of data --> 1 sequences creating streaming test datasets: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 418.26it/s] num_full_sequences=1 num_splits=0 num_split_sequences=0 Event sequence: 0it [00:00, ?it/s] [2024-04-02 20:47:06,734][py.warnings][WARNING] - /home/tushar/miniforge3/envs/leod/lib/python3.9/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /opt/conda/conda-bld/pytorch_1678402412426/work/aten/src/ATen/native/TensorShape.cpp:3483.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]

Predict: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 6.55it/s] Plot: 2it [00:00, 258.37it/s]████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 6.38it/s] Event sequence: 1it [00:01, 1.73s/it] == Timing statistics ==

Wuziyi616 commented 6 months ago

Hi, this is what I got when running your command:

python vis_pred.py model=rnndet dataset=gen1 dataset.path=./datasets/gen1/ checkpoint="pretrained/Sec.4.2-WSOD_SSOD/gen1-WSOD/rvt-s-gen1x0.01_ss-final.ckpt" +experiment/gen1="small.yaml" model.postprocess.confidence_threshold=0.1 num_video=5 reverse=False

Using python-based detection evaluation
Set MaxViTRNN backbone (height, width) to (256, 320)
Set partition sizes: (8, 10)
Set num_classes=2 for detection head
Found 470 sequences in /datasets/automotive-megapixel/gen1/test
Using 1.25% of data --> 6 sequences
creating streaming test datasets: 100%|█████████████████████████████████████| 6/6 [00:00<00:00, 65.62it/s]
num_full_sequences=6
num_splits=0
num_split_sequences=0
Event sequence: 0it [00:00, ?it/s]

                                                                                                         [2024-04-02 17:29:44,920][py.warnings][WARNING] - /fs01/home/ziyiwu/conda/event/lib/python3.9/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /opt/conda/conda-bld/pytorch_1682343997789/work/aten/src/ATen/native/TensorShape.cpp:3483.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]

Predict: 100%|█████████████████████████████████████████████████████████| 640/640 [00:06<00:00, 104.51it/s]
Plot: 640it [00:02, 315.64it/s]████████████████████████████████████████| 640/640 [00:06<00:00, 121.03it/s]

I notice that the number of sequence detected in the test set is different -- your logs say 46 sequences detected in datasets/gen1/test, while mine say 470 sequences (and it's the correct number in the paper). As a result, the dataset only loads one sequence for testing (set here to reduce RAM consumption), and that's actually skipped (see these lines) because I noticed that test sequence 1 on Gen1 has very few motion, and thus there is almost no events which makes it impossible to detect anything.

To fix this, you can comment out this line, and the dataset should load all 46 sequences, test on the first 5 of them, and save them.

Tushar-Isamaliya commented 6 months ago

I did tried with full 470 sequences in the test but there was issue with cuda out of memory. so i tried with few samples (here 46) in test.

python vis_pred.py model=rnndet dataset=gen1 dataset.path=./datasets/gen1/ checkpoint="pretrained/Sec.4.2-WSOD_SSOD/gen1-WSOD/rvt-s-gen1x0.01_ss-final.ckpt" +experiment/gen1="small.yaml" model.postprocess.confidence_threshold=0.1 num_video=5 reverse=False Using python-based detection evaluation Set MaxViTRNN backbone (height, width) to (256, 320) Set partition sizes: (8, 10) Set num_classes=2 for detection head Found 470 sequences in datasets/gen1/test Using 1.25% of data --> 6 sequences creating streaming test datasets: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 6/6 [00:00<00:00, 8.78it/s] num_full_sequences=6 num_splits=0 num_split_sequences=0 Event sequence: 0it [00:10, ?it/s] Error executing job with overrides: ['model=rnndet', 'dataset=gen1', 'dataset.path=./datasets/gen1/', 'checkpoint=pretrained/Sec.4.2-WSOD_SSOD/gen1-WSOD/rvt-s-gen1x0.01_ss-final.ckpt', '+experiment/gen1=small.yaml', 'model.postprocess.confidence_threshold=0.1', 'num_video=5', 'reverse=False'] Traceback (most recent call last): File "/media/tushar/6993b3ed-e07f-4e72-bb9c-feefe00f1b99/Thesis/LEOD/vis_pred.py", line 267, in main video, eoe, prev_t = pred_one_seq( File "/home/tushar/miniforge3/envs/leod/lib/python3.9/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, kwargs) File "/media/tushar/6993b3ed-e07f-4e72-bb9c-feefe00f1b99/Thesis/LEOD/vis_pred.py", line 193, in pred_one_seq all_preds, ev_seq, all_lbl = model.predict_one_seq(seq) File "/media/tushar/6993b3ed-e07f-4e72-bb9c-feefe00f1b99/Thesis/LEOD/modules/detection.py", line 526, in predict_one_seq ev_tensor_sequence = torch.stack(data[DataType.EV_REPR], dim=0).cuda() torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 3.91 GiB (GPU 0; 3.81 GiB total capacity; 37.75 MiB already allocated; 3.63 GiB free; 56.00 MiB reserved in total by PyTorch)** If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.

Also Tried this: Provided Solution: To fix this, you can comment out (#config.dataset.test_ratio = num_video / 400 if is_gen1 else num_video / 100) and the dataset should load all 46 sequences, test on the first 5 of them, and save them.

python vis_pred.py model=rnndet dataset=gen1 dataset.path=./datasets/gen1/ checkpoint="pretrained/Sec.4.2-WSOD_SSOD/gen1-WSOD/rvt-s-gen1x0.01_ss-final.ckpt" +experiment/gen1="small.yaml" model.postprocess.confidence_threshold=0.1 num_video=5 reverse=False Using python-based detection evaluation Set MaxViTRNN backbone (height, width) to (256, 320) Set partition sizes: (8, 10) Set num_classes=2 for detection head Found 46 sequences in datasets/gen1/test creating streaming test datasets: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 46/46 [00:02<00:00, 19.92it/s] num_full_sequences=46 num_splits=0 num_split_sequences=0 Event sequence: 0it [00:12, ?it/s] Error executing job with overrides: ['model=rnndet', 'dataset=gen1', 'dataset.path=./datasets/gen1/', 'checkpoint=pretrained/Sec.4.2-WSOD_SSOD/gen1-WSOD/rvt-s-gen1x0.01_ss-final.ckpt', '+experiment/gen1=small.yaml', 'model.postprocess.confidence_threshold=0.1', 'num_video=5', 'reverse=False'] Traceback (most recent call last): File "/media/tushar/6993b3ed-e07f-4e72-bb9c-feefe00f1b99/Thesis/LEOD/vis_pred.py", line 268, in main video, eoe, prev_t = pred_one_seq( File "/home/tushar/miniforge3/envs/leod/lib/python3.9/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, kwargs) File "/media/tushar/6993b3ed-e07f-4e72-bb9c-feefe00f1b99/Thesis/LEOD/vis_pred.py", line 193, in pred_one_seq all_preds, ev_seq, all_lbl = model.predict_one_seq(seq) File "/media/tushar/6993b3ed-e07f-4e72-bb9c-feefe00f1b99/Thesis/LEOD/modules/detection.py", line 526, in predict_one_seq ev_tensor_sequence = torch.stack(data[DataType.EV_REPR], dim=0).cuda() torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 3.91 GiB (GPU 0; 3.81 GiB total capacity; 37.75 MiB already allocated; 3.63 GiB free; 56.00 MiB reserved in total by PyTorch)** If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace. == Timing statistics ==

I tried to reduce the cuda memory by this : (Set the memory fraction to 0.5 (even reduced to lower) torch.cuda.set_per_process_memory_fraction(0.5)

But there is still issues with CUDA out of memory.

Wuziyi616 commented 6 months ago

Maybe try reducing this sequence length to e.g. 10

What's the memory size of your GPU? From the error message, it seems 4 GB? I believe that's too low to run the model, unfortunately.