【代码调试】《Multi-scale Positive Sample Refinement for Few-shot Object Detection》

news/2024/7/10 2:31:34 标签: 目标检测, 深度学习, 小样本

论文地址:https://arxiv.org/abs/2007.09384#:~:text=Multi-Scale%20Positive%20Sample%20Refinement%20for%20Few-Shot%20Object%20Detection.,previous%20attempts%20that%20exploit%20few-shot%20classification%20techniques%20
代码地址:https://github.com/jiaxi-wu/MPSR

我的配置:
Python :3.6.5(ubuntu20.04)
Pytorch :1.9.0
Cuda :11.1
GPU:RTX 3090 Ti(24GB)

1、依赖安装

conda install ipython pip

pip install ninja yacs cython matplotlib tqdm opencv-python

pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html

2、安装pycocotools

创建文件夹 install_dir
在这里插入图片描述

cd install_dir

git clone https://github.com/cocodataset/cocoapi.git

cd cocoapi/PythonAPI

python setup.py build_ext install

pycocotools编译成功:
在这里插入图片描述

3、安装apex

cd install_dir

git clone https://github.com/NVIDIA/apex.git

cd apex

git checkout 96b017a

python setup.py install --cuda_ext --cpp_ext

apex编译成功:
在这里插入图片描述

4、build

python setup.py build develop

报错:

/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/include/ATen/core/TensorBody.h:303:30: note: declared here
  303 |   DeprecatedTypeProperties & type() const {
      |                              ^~~~
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1673, in _run_ninja_build
    env=env)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "setup.py", line 68, in <module>
    cmdclass={"build_ext": torch.utils.cpp_extension.BuildExtension},
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/setuptools/__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/distutils/command/build.py", line 135, in run
    self.run_command(cmd_name)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 79, in run
    _build_ext.run(self)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
    _build_ext.build_ext.run(self)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/distutils/command/build_ext.py", line 339, in run
    self.build_extensions()
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 708, in build_extensions
    build_ext.build_extensions(self)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions
    _build_ext.build_ext.build_extensions(self)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
    self._build_extensions_serial()
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
    self.build_extension(ext)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 202, in build_extension
    _build_ext.build_extension(self, ext)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
    depends=ext.depends)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 538, in unix_wrap_ninja_compile
    with_cuda=with_cuda)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1359, in _write_ninja_file_and_compile_objects
    error_prefix='Error compiling objects for extension')
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1683, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error compiling objects for extension

解决方案:

https://github.com/facebookresearch/maskrcnn-benchmark/issues/1274
https://github.com/amazon-science/siam-mot/blob/main/readme/INSTALL.md

cuda_dir="maskrcnn_benchmark/csrc/cuda"
perl -i -pe 's/AT_CHECK/TORCH_CHECK/' $cuda_dir/deform_pool_cuda.cu $cuda_dir/deform_conv_cuda.cu
# You can then run the regular setup command
python setup.py build develop

build成功:
在这里插入图片描述

4、准备数据集

4.1、VOC数据集

mkdir -p datasets/voc
wget https://pjreddie.com/media/files/VOCtrainval_11-May-2012.tar
wget https://pjreddie.com/media/files/VOCtrainval_06-Nov-2007.tar
wget https://pjreddie.com/media/files/VOCtest_06-Nov-2007.tar
tar xf VOCtrainval_11-May-2012.tar
tar xf VOCtrainval_06-Nov-2007.tar
tar xf VOCtest_06-Nov-2007.tar

将VOC2007和VOC2012放在 datasets/voc 文件夹下:
在这里插入图片描述

4.2、准备基数据集和小样本数据集

bash tools/fewshot_exp/datasets/init_fs_dataset_standard.sh

在这里我没有使用COCO数据集,所以把tools/fewshot_exp/datasets/init_fs_dataset_standard.sh文件中的第7、8行注释掉了
报错:

正克隆到 '../Fewshot_Detection'...
remote: Enumerating objects: 365, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 365 (delta 2), reused 1 (delta 0), pack-reused 358
接收对象中: 100% (365/365), 121.58 KiB | 496.00 KiB/s, 完成.
处理 delta 中: 100% (267/267), 完成.
Traceback (most recent call last):
  File "tools/fewshot_exp/datasets/voc_create_base.py", line 1, in <module>
    from maskrcnn_benchmark.data.datasets.voc import PascalVOCDataset
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/data/__init__.py", line 2, in <module>
    from .build import make_data_loader
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/data/build.py", line 8, in <module>
    from maskrcnn_benchmark.utils.imports import import_file
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/utils/imports.py", line 4, in <module>
    if torch._six.PY3:
AttributeError: module 'torch._six' has no attribute 'PY3'
Traceback (most recent call last):
  File "tools/fewshot_exp/datasets/voc_create_standard.py", line 2, in <module>
    from maskrcnn_benchmark.data.datasets.voc import PascalVOCDataset
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/data/__init__.py", line 2, in <module>
    from .build import make_data_loader
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/data/build.py", line 8, in <module>
    from maskrcnn_benchmark.utils.imports import import_file
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/utils/imports.py", line 4, in <module>
    if torch._six.PY3:
AttributeError: module 'torch._six' has no attribute 'PY3'
Traceback (most recent call last):
  File "tools/fewshot_exp/datasets/coco_create_base.py", line 1, in <module>
    from maskrcnn_benchmark.data.datasets.coco import COCODataset
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/data/__init__.py", line 2, in <module>
    from .build import make_data_loader
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/data/build.py", line 8, in <module>
    from maskrcnn_benchmark.utils.imports import import_file
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/utils/imports.py", line 4, in <module>
    if torch._six.PY3:
AttributeError: module 'torch._six' has no attribute 'PY3'
Traceback (most recent call last):
  File "tools/fewshot_exp/datasets/coco_create_standard.py", line 1, in <module>
    from maskrcnn_benchmark.data.datasets.coco import COCODataset
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/data/__init__.py", line 2, in <module>
    from .build import make_data_loader
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/data/build.py", line 8, in <module>
    from maskrcnn_benchmark.utils.imports import import_file
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/utils/imports.py", line 4, in <module>
    if torch._six.PY3:
AttributeError: module 'torch._six' has no attribute 'PY3'

解决方案:

https://blog.csdn.net/pangweijian/article/details/120371802

完成:
在这里插入图片描述

5、对 VOC 数据集进行小样本训练

5.1、对 3 个 VOC splits进行基础训练

下载Resnet-101权重文件,将 configs/fewshot/base 文件夹和configs/fewshot_baseline/base文件夹下的三个yaml配置文件中的WEIGHTS路径改为Resnet-101权重文件的路径:
在这里插入图片描述

根据自己的电脑配置修改tools/fewshot_exp/train_voc_base.sh文件中GPU的数量和GPU编号:

在这里插入图片描述

基础训练:

bash tools/fewshot_exp/train_voc_base.sh

1、报错:

Traceback (most recent call last):
  File "./tools/train_net.py", line 197, in <module>
    main()
  File "./tools/train_net.py", line 190, in main
    model = train(cfg, args.local_rank, args.distributed)
  File "./tools/train_net.py", line 65, in train
    extra_checkpoint_data = checkpointer.load(cfg.MODEL.WEIGHT)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/utils/checkpoint.py", line 61, in load
    checkpoint = self._load_file(f)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/utils/checkpoint.py", line 134, in _load_file
    return load_c2_format(self.cfg, f)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/utils/c2_model_loading.py", line 206, in load_c2_format
    return C2_FORMAT_LOADER[cfg.MODEL.BACKBONE.CONV_BODY](cfg, f)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/utils/c2_model_loading.py", line 192, in load_resnet_c2_format
    state_dict = _load_c2_pickled_weights(f)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/utils/c2_model_loading.py", line 135, in _load_c2_pickled_weights
    if torch._six.PY3:
AttributeError: module 'torch._six' has no attribute 'PY3'
Killing subprocess 58533

解决方案:
找到报错的文件,将PY3改为PY37:
在这里插入图片描述

2、报错:

2023-04-10 18:29:41,611 maskrcnn_benchmark.trainer INFO: Start training
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/multiprocessing/resource_sharer.py", line 139, in _serve
    signal.pthread_sigmask(signal.SIG_BLOCK, range(1, signal.NSIG))
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/signal.py", line 60, in pthread_sigmask
    sigs_set = _signal.pthread_sigmask(how, mask)
  ValueError: signal number 32 out of range

解决方案:
修改maskrcnn_benchmark/config/defaults.py文件中_C.DATALOADER.NUM_WORKERS = 0,然后重新运行build.py文件进行编译:
在这里插入图片描述

3、报错

Traceback (most recent call last):
  File "./tools/train_net.py", line 197, in <module>
    main()
  File "./tools/train_net.py", line 190, in main
    model = train(cfg, args.local_rank, args.distributed)
  File "./tools/train_net.py", line 96, in train
    data_loader_closeup
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/engine/trainer.py", line 78, in do_train
    loss_dict = model(images, targets, closeups, closeup_targets)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/apex-0.1-py3.6-linux-x86_64.egg/apex/amp/_initialize.py", line 197, in new_fwd
    **applier(kwargs, input_caster))
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/modeling/detector/generalized_rcnn.py", line 70, in forward
    proposals, proposal_losses = self.rpn(images, features, targets, closeup_rpn_features)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/modeling/rpn/rpn.py", line 189, in forward
    return self._forward_train(anchors, objectness, rpn_box_regression, targets, closeup_objectness)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/modeling/rpn/rpn.py", line 208, in _forward_train
    anchors, objectness, rpn_box_regression, targets, closeup_objectness
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/modeling/rpn/loss.py", line 114, in __call__
    sampled_pos_inds, sampled_neg_inds = self.fg_bg_sampler(labels)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/maskrcnn_benchmark-0.1-py3.6-linux-x86_64.egg/maskrcnn_benchmark/modeling/balanced_positive_negative_sampler.py", line 50, in __call__
    perm2 = torch.randperm(negative.numel(), device=negative.device)[:num_neg]
RuntimeError: radix_sort: failed on 1st step: cudaErrorInvalidDevice: invalid device ordinal
Killing subprocess 61318
Traceback (most recent call last):
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/launch.py", line 340, in <module>
    main()
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/launch.py", line 326, in main
    sigkill_handler(signal.SIGTERM, None)  # not coming back
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/launch.py", line 301, in sigkill_handler
    raise subprocess.CalledProcessError(returncode=last_return_code, cmd=cmd)
subprocess.CalledProcessError: Command '['/home/test/anaconda3/envs/mpsr/bin/python', '-u', './tools/train_net.py', '--local_rank=0', '--config-file', 'configs/fewshot/base/e2e_voc_split1_base.yaml']' returned non-zero exit status 1.

解决方案:
将pytorch1.8.0换成1.9.0,然后重新编译apex以及MPSR整个项目

pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

4、报错

cannot import name ‘container_abcs‘ from ‘torch._six‘

找到报错的位置,把
from torch._six import container_abcs
改为:
import collections.abc as container_abcs
在这里插入图片描述

5、报错

    "__main__", mod_spec)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/launch.py", line 173, in <module>
    main()
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/launch.py", line 169, in main
    run(args)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/run.py", line 624, in run
    )(*cmd_args)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/launcher/api.py", line 116, in __call__
    return launch_agent(self._config, self._entrypoint, list(args))
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/elastic/multiprocessing/errors/__init__.py", line 348, in wrapper
    return f(*args, **kwargs)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/launcher/api.py", line 238, in launch_agent
    result = agent.run()
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/elastic/metrics/api.py", line 125, in wrapper
    result = f(*args, **kwargs)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/elastic/agent/server/api.py", line 700, in run
    result = self._invoke_run(role)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/elastic/agent/server/api.py", line 822, in _invoke_run
    self._initialize_workers(self._worker_group)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/elastic/metrics/api.py", line 125, in wrapper
    result = f(*args, **kwargs)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/elastic/agent/server/api.py", line 670, in _initialize_workers
    self._rendezvous(worker_group)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/elastic/metrics/api.py", line 125, in wrapper
    result = f(*args, **kwargs)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/elastic/agent/server/api.py", line 530, in _rendezvous
    store, group_rank, group_world_size = spec.rdzv_handler.next_rendezvous()
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/distributed/elastic/rendezvous/static_tcp_rendezvous.py", line 60, in next_rendezvous
    self.timeout,
RuntimeError: Address already in use

解决方案:
https://github.com/facebookresearch/maskrcnn-benchmark/issues/241

训练完成,得到三个权重文件:
在这里插入图片描述

5.2、微调

依旧是,根据自己的电脑配置修改tools/fewshot_exp/train_voc_standard.sh文件中GPU的数量和GPU编号
在这里插入图片描述
依旧是,参考这个修改train_voc_standard.sh文件:
https://github.com/facebookresearch/maskrcnn-benchmark/issues/241

微调:

bash tools/fewshot_exp/train_voc_standard.sh

1、报错

Traceback (most recent call last):
  File "tools/train_net.py", line 197, in <module>
    main()
  File "tools/train_net.py", line 190, in main
    model = train(cfg, args.local_rank, args.distributed)
  File "tools/train_net.py", line 65, in train
    extra_checkpoint_data = checkpointer.load(cfg.MODEL.WEIGHT)
  File "/home/test/code/MPSR/maskrcnn_benchmark/utils/checkpoint.py", line 62, in load
    self._load_model(checkpoint)
  File "/home/test/code/MPSR/maskrcnn_benchmark/utils/checkpoint.py", line 98, in _load_model
    load_state_dict(self.model, checkpoint.pop("model"))
  File "/home/test/code/MPSR/maskrcnn_benchmark/utils/model_serialization.py", line 80, in load_state_dict
    model.load_state_dict(model_state_dict)
  File "/home/test/anaconda3/envs/mpsr/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1407, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))

        size mismatch for roi_heads.box.predictor.cls_score.weight: copying a param with shape torch.Size([16, 1024]) from checkpoint, the shape in current model is torch.Size([21, 1024]).
        size mismatch for roi_heads.box.predictor.cls_score.bias: copying a param with shape torch.Size([16]) from checkpoint, the shape in current model is torch.Size([21]).

解决方案:
https://github.com/jiaxi-wu/MPSR/issues/9

修改完成之后运行以下命令重新生成’voc0712_split%dbase_pretrained.pth’就行了

python tools/fewshot_exp/trans_voc_pretrained.py 1
python tools/fewshot_exp/trans_voc_pretrained.py 2
python tools/fewshot_exp/trans_voc_pretrained.py 3

微调完成,得到这些:

5.3、评估

3 split的1/2/3/5/10 shot进行评估。
默认情况下,存储结果文件夹为 fs_exp/voc_standard_results,可以通过以下方式快速获得评估结果:

python tools/fewshot_exp/cal_novel_voc.py fs_exp/voc_standard_results

6、结论

官方代码使用2个GPU,而我只有1个GPU。按照作者提供的单卡训练方法修改了诸多参数之后跑出来的效果仍旧远远不及官方效果,放在这里给大家做一个参考,不过具体数值就不列出了:基础训练mAP在0.2~0.4之间,微调后的mAP在0.1~0.2之间。
如有错误,欢迎指正。


http://www.niftyadmin.cn/n/329518.html

相关文章

数据结构学习记录——图的遍历(深度优先搜索、广度优先搜索、为什么需要两种遍历、图不连通怎么办)

目录 深度优先搜索 概念 图解过程 伪代码 时间复杂度 具体代码&#xff08;C语言&#xff09; 广度优先搜索 概念 图解过程 伪代码 时间复杂度 具体代码&#xff08;C语言&#xff09; 为什么需要两种遍历 图不连通怎么办 连通 路径 回路 连通图 连通…

深度学习之迁移学习

数据增强 数据太少可能会过拟合。 # data_transforms中指定了所有图像预处理&#xff08;变换&#xff09;操作&#xff08;图像数据增强&#xff09; data_transforms {train: transforms.Compose([transforms.RandomRotation(45), # 随机旋转&#xff0c;-45到45度之间随…

Go语言面试题--进阶提升(10)

文章目录 1.下面代码输出什么&#xff1f;2.下面的代码能编译通过吗&#xff1f;可以的话输出什么&#xff0c;请说明&#xff1f;3.下面代码有什么问题&#xff0c;请说明&#xff1f;4.假设 x 已声明&#xff0c;y 未声明&#xff0c;下面 4 行代码哪些是正确的。错误的请说明…

中本聪思想精髓难以领悟?Web3实际上还在“幻想”之中?

Web3概念是不错&#xff0c;有人说它是下一代互联网&#xff0c;有人说它是NFT和元宇宙等未来应用的基础设施。然而理论炒得火热&#xff0c;但却仍不见像ChatGPT一样能引爆市场的杀手级应用出现。 原因在于&#xff0c;当前的Web3概念是对中本聪思想的不断概括和提炼&#xff…

丁鹿学堂:2023前端学习指南之vue3的数据响应式原理总结

js的普通对象 如果定义一个普通对象&#xff0c;修改对象的值&#xff0c;不会影响别的元素。 const obj {name:丁鹿,age:20 } obj.name 前端如果想要在修改对象的元素的同时&#xff0c;去触发一些别的操作&#xff0c;我们需要把对象进行改造。 在vue3中&#xff0c;使用…

面向对象分析与设计_类图

判断题 类与对象之间的关系&#xff0c;可以理解为模板与具体实例之间的关系 T 类是现实世界中客观存在的事物或实体。 F 类是具有相同属性和服务的一组对象的集合 T 对象的属性都有值&#xff0c;类的属性没有值 T 类的可见性描述了其属性和操作是否对于其他类可见&…

如何把容器变成物理机

如何把容器变成物理机 本文的主题是把容器变成物理机&#xff0c;根据所学的知识。以及通过各种搜索引擎。他们都告诉我们&#xff0c;这是不可能的。这真的是不可能的吗&#xff1f;我不信&#xff0c;那我就要创造奇迹。请继续往下看。本文将教你如何把容器变成物理机。 这…

ES6中Proxy

1. Proxy 说明&#xff1a;Proxy可以理解成在目标对象架设一层拦截器&#xff0c;外界访问内部的变量都必须经过这一层&#xff0c;可以对外界的访问进行过滤和改写。 1.1例子&#xff1a; const proxynew Proxy(target,handler) 说明&#xff1a;Proxy对象的用法&#xff0…