ChenhongyiYang / PPAL

[CVPR 2024] Plug and Play Active Learning for Object Detection
Apache License 2.0
68 stars 8 forks source link

What is class_quality ? #5

Closed kdh-awraw1019 closed 1 year ago

kdh-awraw1019 commented 1 year ago

I dont know what is class_quality

code : mmdet\ppal\sampler\difficulty_calibrated_uncertainty_sampler.py line : 41 class_qualities = ckpt['state_dict']['bbox_head.class_quality'].numpy() in def _get_classwise_weight(self, results_json):

I did load checkpoint file retinanet_r50_caffe_fpn_mstrain_1x_coco-586977a0.pth from https://mmdetection.readthedocs.io/en/stable/model_zoo.html

but, the checkpoint file has not key of dict 'bbox_head.class_quality'.

so I cannot run this command python tools/run_al_coco.py --config ./al_configs/coco/ppal_retinanet_coco.py --model retinanet

And, when I run this command in anaconda prompt ternimal this error occured..

obviously, I did installation with your guide

python tools/run_al_coco.py --config al_configs/coco/ppal_retinanet_coco.py --model retinanet Traceback (most recent call last): File "tools/run_al_coco.py", line 5, in from mmdet.ppal.sampler import * ModuleNotFoundError: No module named 'mmdet.ppal'

My environments

RTX3060 anaconda3 pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3 mmcv-full==1.5.0 mmdet==2.27.0

ChenhongyiYang commented 1 year ago

Hi,

Thank you for being interested in our work.

For the first question, the class_quality equals to (1 - class_difficulty), which is introduced in Section 3.3 of our paper. It is computed and updated using EMA during model training, so a pre-trained model provided by mmdetection will not include it.

For the second question, you need to run python setup.py install under the PPAL project instead of a newly cloned mmdetection.

Best, Chenhongyi

kdh-awraw1019 commented 1 year ago

Thank you for your comment

So, is the correct and only way to install PPAL is to just run the 'python setup.py install' command?

ChenhongyiYang commented 1 year ago

Hi,

You can also run pip install -v -e .

kdh-awraw1019 commented 1 year ago

Hi,

I still have question.

How can I find the code for the process of calculating the difficulty of all predicted boxes during learning and the process of updating to EMA to calculate image uncertainty in DCUS (Section3.3)?

ChenhongyiYang commented 1 year ago

Hi,

You can find the implementations here

kdh-awraw1019 commented 1 year ago

OK, And...

I want to fine the code for the process of calculating the similarity of Images in CCMS

I found implementation about diversity sampling (k-greedy-centers and kmeans) https://github.com/ChenhongyiYang/PPAL/blob/main/mmdet/ppal/sampler/diversity_sampler.py

but, I could not find calculating similarity...

ChenhongyiYang commented 1 year ago

Hi, you can find it here

kdh-awraw1019 commented 1 year ago

Hi, New questions.

  1. In run_al_coco.py, 'torch.distributed.launch' is in train / eval / unlabeled command.

    • Can I run 'torch.distributed.launch' in windows 10?
  2. KeyError: 'bbox_head.class_quality' (Runned in pycharm)

Traceback (most recent call last): File "D:\Workspace\PPAL\tools\run_al_coco.py", line 168, in run(i+1, i!=int(cfg.get('round_num'))-1) File "D:\Workspace\PPAL\tools\run_al_coco.py", line 129, in run uncertainty_sampler.al_round(round_uncertainty_inference_json, round_labeled_json, round_uncertainty_new_labeled_json, round_uncertainty_new_unlabeled_json) File "D:\Workspace\PPAL\mmdet\ppal\sampler\difficulty_calibrated_uncertainty_sampler.py", line 136, in al_round sampled_img_ids, rest_img_ids = self.al_acquisition(result_path, last_label_path) File "D:\Workspace\PPAL\mmdet\ppal\sampler\difficulty_calibrated_uncertainty_sampler.py", line 55, in al_acquisition class_weights = self._get_classwise_weight(result_json) File "D:\Workspace\PPAL\mmdet\ppal\sampler\difficulty_calibrated_uncertainty_sampler.py", line 41, in _get_classwise_weight class_qualities = ckpt['state_dict']['bbox_head.class_quality'].numpy() KeyError: 'bbox_head.class_quality'

config file (ppal_retinanet_coco.py)

Paths

config_dir = 'D:/Workspace/PPAL/configs/coco_active_learning/' work_dir = 'D:/Workspace/PPAL/work_dirs/'

Environment setting

python_path = 'C:/Users/aaaaa/Anaconda3/envs/ppal/' port = 29500 gpus = 1

Data setting

oracle_path = 'D:/Workspace/PPAL/data/coco/annotations/instances_train2017.json' init_label_json = 'D:/Workspace/PPAL/data/active_learning/coco/coco_2365_labeled_1.json' init_unlabeled_json = 'D:/Workspace/PPAL/data/active_learning/coco/coco_2365_unlabeled_1.json' init_model = None

Config setting

train_config = config_dir + 'al_train/retinanet_26e.py' uncertainty_infer_config = config_dir + 'al_inference/retinanet_uncertainty.py' diversity_infer_config = config_dir + 'al_inference/retinanet_diversity.py'

Active learning setting

round_num = 5 budget = 2365 budget_expand_ratio = 4 uncertainty_pool_size = budget budget_expand_ratio + gpus - (budget budget_expand_ratio) % gpus

Sampler setting

uncertainty_sampler_config = dict( type='DCUSSampler', n_sample_images=uncertainty_pool_size, oracle_annotation_path=oracle_path, score_thr=0.05, class_weight_ub=0.2, class_weight_alpha=0.3, dataset_type='coco') diversity_sampler_config = dict( type='DiversitySampler', n_sample_images=budget, oracle_annotation_path=oracle_path, dataset_type='coco')

output_dir = work_dir + 'retinanet_coco_ppal_5rounds_2percent_to_10percent'

and I wanna know about 'port'

//////////////////////////////////////////////////////

if I run ./tools/run_al_coco.py —config ./al_configs/coco/ppal_retinanet_coco.py —model retinanet command in Terminal,

its print this: (ppal) D:\Workspace\PPAL>tools\run_al_coco.py --config ./al_configs/coco/ppal_retinanet_coco.py --model retinanet

(ppal) D:\Workspace\PPAL> [main 2023-01-30T06:19:35.953Z] update#setState idle [main 2023-01-30T06:19:36.681Z] Starting extension host with pid 19264 (fork() took 12 ms). [main 2023-01-30T06:20:05.963Z] update#setState checking for updates [main 2023-01-30T06:20:07.381Z] update#setState idle [9676:0130/152135.996:ERROR:gpu_init.cc(481)] Passthrough is not supported, GL is disabled, ANGLE is

sangeethnrs commented 1 month ago

@kdh-awraw1019 i do have the same error and how to solve it? the checkpoint file has not key of dict 'bbox_head.class_quality'.