Git Product home page Git Product logo

few-shot-object-detection's Introduction

Few-Shot Object Detection (FsDet)

Language grade: Python Code style: black pre-commit

FsDet contains the official few-shot object detection implementation of the ICML 2020 paper Frustratingly Simple Few-Shot Object Detection. TFA Figure

In addition to the benchmarks used by previous works, we introduce new benchmarks on three datasets: PASCAL VOC, COCO, and LVIS. We sample multiple groups of few-shot training examples for multiple runs of the experiments and report evaluation results on both the base classes and the novel classes. These are described in more detail in Data Preparation.

We also provide benchmark results and pre-trained models for our two-stage fine-tuning approach (TFA). In TFA, we first train the entire object detector on the data-abundant base classes, and then only fine-tune the last layers of the detector on a small balanced training set. See Models for our provided models and Getting Started for instructions on training and evaluation.

FsDet is well-modularized so you can easily add your own datasets and models. The goal of this repository is to provide a general framework for few-shot object detection that can be used for future research.

If you find this repository useful for your publications, please consider citing our paper.

@article{wang2020few,
    title={Frustratingly Simple Few-Shot Object Detection},
    author={Wang, Xin and Huang, Thomas E. and  Darrell, Trevor and Gonzalez, Joseph E and Yu, Fisher}
    booktitle = {International Conference on Machine Learning (ICML)},
    month = {July},
    year = {2020}
}

Updates

  • (Oct 2020) The code has been upgraded to detectron2 v0.2.1. If you need the original released code, please checkout the release v0.1 in the tag.

Table of Contents

Installation

Requirements

  • Linux with Python >= 3.6
  • PyTorch >= 1.4
  • torchvision that matches the PyTorch installation
  • CUDA 9.2, 10.0, 10.1, 10.2, 11.0
  • GCC >= 4.9

Build FsDet

  • Create a virtual environment.
python3 -m venv fsdet
source fsdet/bin/activate

You can also use conda to create a new environment.

conda create --name fsdet
conda activate fsdet
  • Install PyTorch. You can choose the PyTorch and CUDA version according to your machine. Just make sure your PyTorch version matches the prebuilt Detectron2 version (next step). Example for PyTorch v1.6.0:
pip install torch==1.6.0 torchvision==0.7.0

Currently, the codebase is compatible with Detectron2 v0.2.1, Detectron2 v0.3, and Detectron2 v0.4. Tags correspond to the exact version of Detectron2 that is supported. To checkout the right tag (example for Detectron2 v0.3):

git checkout v0.3

To install depedencies (example for PyTorch v1.6.0, CUDA v10.2, Detectron2 v0.3):

  • Install Detectron2 v0.3
python3 -m pip install detectron2==0.3 -f \
  https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.6/index.html
  • Install other requirements.
python3 -m pip install -r requirements.txt

Code Structure

  • configs: Configuration files
  • datasets: Dataset files (see Data Preparation for more details)
  • fsdet
    • checkpoint: Checkpoint code.
    • config: Configuration code and default configurations.
    • engine: Contains training and evaluation loops and hooks.
    • layers: Implementations of different layers used in models.
    • modeling: Code for models, including backbones, proposal networks, and prediction heads.
  • tools
    • train_net.py: Training script.
    • test_net.py: Testing script.
    • ckpt_surgery.py: Surgery on checkpoints.
    • run_experiments.py: Running experiments across many seeds.
    • aggregate_seeds.py: Aggregating results from many seeds.

Data Preparation

We evaluate our models on three datasets:

  • PASCAL VOC: We use the train/val sets of PASCAL VOC 2007+2012 for training and the test set of PASCAL VOC 2007 for evaluation. We randomly split the 20 object classes into 15 base classes and 5 novel classes, and we consider 3 random splits. The splits can be found in fsdet/data/builtin_meta.py.
  • COCO: We use COCO 2014 and extract 5k images from the val set for evaluation and use the rest for training. We use the 20 object classes that are the same with PASCAL VOC as novel classes and use the rest as base classes.
  • LVIS: We treat the frequent and common classes as the base classes and the rare categories as the novel classes.

See datasets/README.md for more details.

If you would like to use your own custom dataset, see CUSTOM.md for instructions. If you would like to contribute your custom dataset to our codebase, feel free to open a PR.

Models

We provide a set of benchmark results and pre-trained models available for download in MODEL_ZOO.md.

Getting Started

Inference Demo with Pre-trained Models

  1. Pick a model and its config file from model zoo, for example, COCO-detection/faster_rcnn_R_101_FPN_ft_all_1shot.yaml.
  2. We provide demo.py that is able to run builtin standard models. Run it with:
python3 -m demo.demo --config-file configs/COCO-detection/faster_rcnn_R_101_FPN_ft_all_1shot.yaml \
  --input input1.jpg input2.jpg \
  [--other-options]
  --opts MODEL.WEIGHTS fsdet://coco/tfa_cos_1shot/model_final.pth

The configs are made for training, therefore we need to specify MODEL.WEIGHTS to a model from model zoo for evaluation. This command will run the inference and show visualizations in an OpenCV window.

For details of the command line arguments, see demo.py -h or look at its source code to understand its behavior. Some common arguments are:

  • To run on your webcam, replace --input files with --webcam.
  • To run on a video, replace --input files with --video-input video.mp4.
  • To run on cpu, add MODEL.DEVICE cpu after --opts.
  • To save outputs to a directory (for images) or a file (for webcam or video), use --output.

Training & Evaluation in Command Line

To train a model, run

python3 -m tools.train_net --num-gpus 8 \
        --config-file configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_base1.yaml

To evaluate the trained models, run

python3 -m tools.test_net --num-gpus 8 \
        --config-file configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_all1_1shot.yaml \
        --eval-only

For more detailed instructions on the training procedure of TFA, see TRAIN_INST.md.

Multiple Runs

For ease of training and evaluation over multiple runs, we provided several helpful scripts in tools/.

You can use tools/run_experiments.py to do the training and evaluation. For example, to experiment on 30 seeds of the first split of PascalVOC on all shots, run

python3 -m tools.run_experiments --num-gpus 8 \
        --shots 1 2 3 5 10 --seeds 0 30 --split 1

After training and evaluation, you can use tools/aggregate_seeds.py to aggregate the results over all the seeds to obtain one set of numbers. To aggregate the 3-shot results of the above command, run

python3 -m tools.aggregate_seeds --shots 3 --seeds 30 --split 1 \
        --print --plot

few-shot-object-detection's People

Contributors

anthuang avatar scott-vsi avatar thomasehuang avatar xinw1012 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

few-shot-object-detection's Issues

how to make vocsplit/box_{1,2,3,5,10}shot_{category}_train.txt?

Hi,

Thanks for all your effort on this work, it is truly amazing! I'm trying to replicate the result for single run PASCAL VOC TFA w/ cos, what seed do you use in the report number (seed 30?)
More specifically,
vocsplit/
box_{1,2,3,5,10}shot_{category}_train.txt → which seed is these files?
seed{1-29}/
# shots)

Thanks!

Different training paradigm for VOC and COCO

Hi, I have a question for the fine-tune pipeline.
For the VOC, you use a 2-stage paradigm, 1) base training, 2) fine-tune on base+novel.
For COCO, you use a 3-stage paradigm, 1) base training, 2) novel training(only head), 3) fine-tune on base+novel

I wonder what's difference between these two types in motivation? and why use different paradigms for different datasets? Thanks.

about novel files?

image
faster_rcnn_R_101_FPN_ft_novel1_1shot.yaml file is not exist? can you share it?
image

Questions about experimental results in Tab1 and Tab7

Hi, thanks for sharing your work.
I well read your paper and found that there are 2 result on Pascal VOC.
Table 1 shows the amazing results on Pascal VOC, Is the mAP in Tab1 only on noval classes ?
Why the results in Table 1 and Table 7 are different ?

I am very confused about this,could you explained it?

thanks :)

basic questions about trainval/test splits of VOC

I wonder how to get the base training list in your few-shot setting and have some questions. Let's take VOC dataset example, the questions are:

  1. For the base training which has abundant annotations of 15 base classes, will the training images include any object belong to the unlabeled 5 novel classes? (for example, the base person and the novel sofa are both in a single training image)
  2. If the above 1. is true, how to handle the unlabeled novel classes during base training? (maybe not take it as background)
  3. How can I get a filename list (like trainval.txt) for the base training? I only see the x-shot list for training in this URL:http://dl.yf.io/fs-det/datasets/vocsplit/

Thanks a lot.

Freezing Layers for Finetuning

Firstly, many thanks for sharing your work.

I just had a very quick question on where I can find parts of the code that implements freezing of the layers and the cosine similarity classifier during the finetuning stage.

Kind regards,
Se

I cannot download pretrained model succesesfully.

Thank you for your good work.
When I try to use demo for a test, I find the 'mode_final.pth' cannot be download succesesfully.
Could you provide these files from a other websites or google.dirve?

Thank you very much. Best wishes!

Unable to evaluate using test_net.py

Hi, I have followed the instructions from #29 to add my own dataset (in COCO format) and was able to train it using the config faster_rcnn_R_101_FPN_base.yaml . However, when I try to run test_net, I get the warning:
WARNING [07/08 17:02:03 fsdet.engine.defaults]: No evaluator found. Use DefaultTrainer.test(evaluators=), or implement its build_evaluator method.

and nothing more. What am I missing? Where should I define the evaluator for my new dataset?

My system is: Linux Mint 18.3, Nvidia titan XP, Cuda 10.0, Pytorch 1.5

I still cannot down the trained models.

I still cannot down the trained models. The following is the massege when I downloaded them by "model = model_zoo.get(
... "COCO-detection/faster_rcnn_R_101_FPN_ft_all_1shot.yaml", trained=True)
":
froze backbone parameters
froze proposal generator parameters
froze roi_box_head parameters
model_final.pth: 8%|█▌ | 19.7M/245M [10:18<1:57:46, 31.9kB/s]
Failed to download http://dl.yf.io/fs-det/models/coco/tfa_cos_1shot/model_final.pth
Traceback (most recent call last):
File "", line 2, in
File "/opt/data/public/retail/jishuangxi/Alg-test/Git/few-shot-object-detection-master/fsdet/model_zoo/model_zoo.py", line 179, in get
DetectionCheckpointer(model).load(cfg.MODEL.WEIGHTS)
File "/root/anaconda3/envs/pytorch/lib/python3.7/site-packages/fvcore/common/checkpoint.py", line 100, in load
path = PathManager.get_local_path(path)
File "/root/anaconda3/envs/pytorch/lib/python3.7/site-packages/fvcore/common/file_io.py", line 620, in get_local_path
path, **kwargs
File "/root/anaconda3/envs/pytorch/lib/python3.7/site-packages/fvcore/common/file_io.py", line 495, in _get_local_path
cached = download(path, dirname, filename=filename)
File "/root/anaconda3/envs/pytorch/lib/python3.7/site-packages/fvcore/common/download.py", line 58, in download
tmp, _ = request.urlretrieve(url, filename=tmp, reporthook=hook(t))
File "/root/anaconda3/envs/pytorch/lib/python3.7/urllib/request.py", line 288, in urlretrieve
% (read, size), result)
urllib.error.ContentTooShortError: <urlopen error retrieval incomplete: got only 19710913 out of 245166210 bytes>

How can I get them?

The Impact of Batch Size

I find the batch size has a very large impact on your model. Could you give an interpretation?

How to get official results by Matlab API?

Dear authors,

The first question I wanna confirm that all results on your paper is from python evaluation or matlab. If this is from python, How do I can get this from Matlab. As far as, I know that some works provide a pickle of detection results (detections.pkl) to evaluate in official Matlab? Could you provide this file or any alternative for that?

The second one is that I successfully run your code, but when I checked the results I see inconsistently some locations. For examples, in table 1: the results in your table is different from the original papers at novel set 2 and 3
image
Besides, when I run your code:
python tools/train_net.py --num-gpus 1
--config-file configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_all1_1shot.yaml
--opts MODEL.WEIGHTS WEIGHTS_PATH
I get the results like this:
1shot
I want to know whether it is true or not, because it is also different in your table 1. By the way, the result from base training I got like this one:
1

Hope to hear from you soon!
Sincerely,
Duynn

can't find faster_rcnn_R_101_FPN_ft_novel1_1shot.yaml

I am trying to retrain the models following the tutorial here:
https://github.com/ucbdrive/few-shot-object-detection/blob/master/TRAIN_INST.md#fine-tuning

I am trying to use the Novel weights instead of the random weights. When I run the following command:

`python tools/train_net.py --num-gpus 8 \
    --config-file configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_novel1_1shot.yaml \
    --opts MODEL.WEIGHTS checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_all1/model_reset_remove.pth

I see that the config file does not exist at that location. Also the --opts flag does not exist in the code base and Hence I am manually editing the yaml files for the coresponding weights file.

WHere can I find the config files for the novel1_1shot setting?

Combined Error

When I try to initialize the weight for novel class and combine it to the base weights, it gives out en error as stated below:
RuntimeError: The expanded size of the tensor (21) must match the existing size (60) at non-singleton dimension 0. Target sizes: [21, 1024]. Tensor sizes: [60, 1024]

Note that I use COCO dataset. Here's the commands I have run:
python tools/ckpt_surgery.py --src1 checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_base/model_final.pth --method remove --save-dir checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_all

python tools/train_net.py --num-gpus 8 --config-file configs/COCO-detection/faster_rcnn_R_101_FPN_ft_novel_10shot.yaml MODEL.WEIGHTS checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_all/model_reset_remove.pth

python tools/ckpt_surgery.py --src1 checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_base/model_final.pth --src2 checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_ft_novel_10shot/model_final.pth --method combine --save-dir checkpoints/coco/faster_rcnn/faster_rcnn_R_101_FPN_all
The error prompted out at the step of combine. Could you advise? Thanks.

LR schedule for the fine-tune phase

Hi,
I have noticed that you use different lr schedules in the fine-tune phase.
For the COCO experiments, when using 30 shots, the total iterations is up to 240000, which is larger than the base phase(110000).
I wonder does the iterations matter a lot for the fine-tune stage, 240000 iterations are too expensive for the fine-tuning.

Importerror: cannot import name '_C'

I have done all the installations shown on README.mb but still, I get his error message whenever I try to do the demo.py:
Importerror: cannot import name '_C'

How to Register Novel Dataset ?

Hi

I am trying to use my own dataset to fine tune the pipeline on, but it gives me the error of 'KeyError: "Dataset 'equipment_imgs' is not registered!' , how do I register this dataset to to fine tune the algorithm on this ?

about error fsdet

image
I according to your config, but got the error like above, can you help me what‘s wrong?

Missing files for coco

Hi, I couldn't find trainvalno5k.json and 5k.json - can you please point me where can I find them?
Thanks.

cannot find config file faster_rcnn_R_101_FPN_ft_novel1_1shot.yaml

The command line (below) you provide in TRAIN_INST.md indicates the need for faster_rcnn_R_101_FPN_ft_novel1_1shot.yaml, but I cannot find such file. Thanks.

python tools/train_net.py --num-gpus 8 \
        --config-file configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_novel1_1shot.yaml \
        --opts MODEL.WEIGHTS checkpoints/voc/faster_rcnn/faster_rcnn_R_101_FPN_all1/model_reset_remove.pth

About experimental results

Hi, thanks for sharing your great work.
I currently work on one-shot detection and would like to compare results on VOC dataset in your paper. Since both Table 1 and Table 7 contain results on VOC novel classes, is it suitable to use results in Table7 rather than Table1? thanks.

Basic few shot question

Lets say I have few images of particular class (different from COCO : base training set ? ). How can we use this to train for the new class ?

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

I am trying to implement the code but while running setup.py, I am getting this error.

In file included from /content/few-shot-object-detection/fsdet/layers/csrc/vision.cpp:7:0:
/content/few-shot-object-detection/fsdet/layers/csrc/deformable/deform_conv.h:344:26: warning: ‘at::DeprecatedTypeProperties& at::Tensor::type() const’ is deprecated: Tensor.type() is deprecated. Instead use Tensor.options(), which in many cases (e.g. in a constructor) is a drop-in replacement. If you were using data from type(), that is now available from Tensor itself, so instead of tensor.type().scalar_type(), use tensor.scalar_type() instead and instead of tensor.type().backend() use tensor.device(). [-Wdeprecated-declarations]
AT_CHECK(offset.type().is_cuda(), "offset tensor is not on GPU!");
^
In file included from /usr/local/lib/python3.6/dist-packages/torch/include/ATen/Tensor.h:11:0,
from /usr/local/lib/python3.6/dist-packages/torch/include/ATen/Context.h:4,
from /usr/local/lib/python3.6/dist-packages/torch/include/ATen/ATen.h:5,
from /usr/local/lib/python3.6/dist-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
from /usr/local/lib/python3.6/dist-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
from /usr/local/lib/python3.6/dist-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
from /usr/local/lib/python3.6/dist-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
from /usr/local/lib/python3.6/dist-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
from /usr/local/lib/python3.6/dist-packages/torch/include/torch/csrc/api/include/torch/data.h:3,
from /usr/local/lib/python3.6/dist-packages/torch/include/torch/csrc/api/include/torch/all.h:4,
from /usr/local/lib/python3.6/dist-packages/torch/include/torch/extension.h:4,
from /content/few-shot-object-detection/fsdet/layers/csrc/vision.cpp:3:
/usr/local/lib/python3.6/dist-packages/torch/include/ATen/core/TensorBody.h:262:30: note: declared here
DeprecatedTypeProperties & type() const {
^~~~
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

How can i evaluate the model without FPN?

Thanks for nice work and source code.
I'd like to evaluate the model without FPN in backbone.

So, i changed config files 'Base-RCNN-FPN.yaml' as
VERSION: 2
MODEL:
META_ARCHITECTURE: "GeneralizedRCNN"
BACKBONE:
NAME: "build_resnet_backbone"
RPN:
PRE_NMS_TOPK_TRAIN: 2000
PRE_NMS_TOPK_TEST: 1000
POST_NMS_TOPK_TRAIN: 1000
POST_NMS_TOPK_TEST: 1000
ROI_HEADS:
NAME: "StandardROIHeads"
ROI_BOX_HEAD:
NAME: "FastRCNNConvFCHead"
NUM_FC: 2
POOLER_RESOLUTION: 7
DATASETS:
TRAIN: ("coco_2017_train",)
TEST: ("coco_2017_val",)
SOLVER:
IMS_PER_BATCH: 16
BASE_LR: 0.02
STEPS: (60000, 80000)
MAX_ITER: 90000
INPUT:
MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800)

I changed backbone name and delete some descriptions for FPN feature level.
And i didn't change source code. Is it enough to evaluate the model without FPN?

Thanks,

training procedure

In your paper, you mention training two-stage but in your readme file just you provide base training. how can I train the network in two-stage?

About cumulative performance

Hi, thx for you work. As you say, the average value across multiple runs is consistently lower than that on the first run, especially in the one-shot case. Is that means the few shot images in the first run used in FSRW are well selected which yeilds better performance than random selecting?

Same model without FPN in backbone

Hi,
I'm trying to test the proposed model without FPN in backbone.
so i changed config file like below (BASE-RCNN-FPN.yaml)

MODEL:
META_ARCHITECTURE: "GeneralizedRCNN"
BACKBONE:
NAME: "build_resnet_backbone"
RPN:
PRE_NMS_TOPK_TEST: 6000
POST_NMS_TOPK_TEST: 1000
ROI_HEADS:
NAME: "StandardROIHeads"
ROI_BOX_HEAD:
NAME: "FastRCNNConvFCHead"
NUM_FC: 2
POOLER_RESOLUTION: 7
DATASETS:
TRAIN: ("coco_2017_train",)
TEST: ("coco_2017_val",)
SOLVER:
IMS_PER_BATCH: 16
BASE_LR: 0.02
STEPS: (60000, 80000)
MAX_ITER: 90000
INPUT:
MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800)
VERSION: 2

It runs(base train) well with the config files but, I found there are some mismatch with checkpoint

[04/07 11:49:55 fsdet.checkpoint.c2_model_loading]: Some model parameters are not in the checkpoint:
proposal_generator.anchor_generator.cell_anchors.0
proposal_generator.rpn_head.anchor_deltas.{bias, weight}
proposal_generator.rpn_head.conv.{bias, weight}
proposal_generator.rpn_head.objectness_logits.{bias, weight}
roi_heads.box_head.fc1.{bias, weight}
roi_heads.box_head.fc2.{bias, weight}
roi_heads.box_predictor.bbox_pred.{bias, weight}
roi_heads.box_predictor.cls_score.{bias, weight}
[04/07 11:49:55 fsdet.checkpoint.c2_model_loading]: The checkpoint contains parameters not used by the model:
fc1000_b
fc1000_w
res5_0_branch2a_bn_beta
res5_0_branch2a_bn_running_mean
res5_0_branch2a_bn_running_var
res5_0_branch2a_bn_gamma
res5_0_branch2a_w
res5_0_branch2b_bn_beta
res5_0_branch2b_bn_running_mean
res5_0_branch2b_bn_running_var
res5_0_branch2b_bn_gamma
res5_0_branch2b_w
res5_0_branch2c_bn_beta
res5_0_branch2c_bn_running_mean
res5_0_branch2c_bn_running_var
res5_0_branch2c_bn_gamma
res5_0_branch2c_w
res5_0_branch1_bn_beta
res5_0_branch1_bn_running_mean
res5_0_branch1_bn_running_var
res5_0_branch1_bn_gamma
res5_0_branch1_w
res5_1_branch2a_bn_beta
res5_1_branch2a_bn_running_mean
res5_1_branch2a_bn_running_var
res5_1_branch2a_bn_gamma
res5_1_branch2a_w
res5_1_branch2b_bn_beta
res5_1_branch2b_bn_running_mean
res5_1_branch2b_bn_running_var
res5_1_branch2b_bn_gamma
res5_1_branch2b_w
res5_1_branch2c_bn_beta
res5_1_branch2c_bn_running_mean
res5_1_branch2c_bn_running_var
res5_1_branch2c_bn_gamma
res5_1_branch2c_w
res5_2_branch2a_bn_beta
res5_2_branch2a_bn_running_mean
res5_2_branch2a_bn_running_var
res5_2_branch2a_bn_gamma
res5_2_branch2a_w
res5_2_branch2b_bn_beta
res5_2_branch2b_bn_running_mean
res5_2_branch2b_bn_running_var
res5_2_branch2b_bn_gamma
res5_2_branch2b_w
res5_2_branch2c_bn_beta
res5_2_branch2c_bn_running_mean
res5_2_branch2c_bn_running_var
res5_2_branch2c_bn_gamma
res5_2_branch2c_w

Is there anything to know when i try to change your config file?
Thanks!

Question about experimental results in paper

Hi, thanks for sharing your work.
I well read your paper and found that there are 2 result on Pascal VOC.
In Figure 4, you shows the mAP over 30 random samples. And there is another mAP result in Table 1.
Is it the best mAP of your model? I noticed there were unreliable experimental report as you wrote. But still, i wonder how did you choose the result on Table 1.

Thanks :)

Mismatch of the annotation file of COCO

Hi,
I have some questions about your provided 5k json.
I found the number of annotations of the official

data_2014 = json.load(open("coco2014/annotations/instances_minival2014.json"))                                                 
In [21]: data_2014['images'].__len__()                                                                                                                                         
Out[21]: 5000
In [22]: data_2014['annotations'].__len__()                                                                                                                                    
Out[22]: 36781

while in your 5k json

In [23]: data['images'].__len__()                                                                                                                                              
Out[23]: 5000
In [24]: data['annotations'].__len__()                                                                                                                                         
Out[24]: 35511

Could you explaine the difference between your provided annotations and the official ones, thanks a lot.

error occurs "Dataset 'voc_2007_trainval_base1' is not registered!"

Thanks for your interesting work. Unfortunately i found a error on training code like below.

dataset_dicts = [DatasetCatalog.get(dataset_name) for dataset_name in dataset_names] File "py36/lib/python3.6/site-packages/detectron2/data/catalog.py", line 59, in get name, ", ".join(DatasetCatalog._REGISTERED.keys()) KeyError: "Dataset 'voc_2007_trainval_base1' is not registered! Available datasets are: coco_2014_train, coco_2014_val, coco_2014_minival, coco_2014_minival_100, coco_2014_valminusminival, coco_2017_train, coco_2017_val, coco_2017_test, coco_2017_test-dev, coco_2017_val_100, keypoints_coco_2014_train, keypoints_coco_2014_val, keypoints_coco_2014_minival, keypoints_coco_2014_valminusminival, keypoints_coco_2014_minival_100, keypoints_coco_2017_train, keypoints_coco_2017_val, keypoints_coco_2017_val_100, coco_2017_train_panoptic_separated, coco_2017_train_panoptic_stuffonly, coco_2017_val_panoptic_separated, coco_2017_val_panoptic_stuffonly, coco_2017_val_100_panoptic_separated, coco_2017_val_100_panoptic_stuffonly, lvis_v0.5_train, lvis_v0.5_val, lvis_v0.5_val_rand_100, lvis_v0.5_test, lvis_v0.5_train_cocofied, lvis_v0.5_val_cocofied, cityscapes_fine_instance_seg_train, cityscapes_fine_sem_seg_train, cityscapes_fine_instance_seg_val, cityscapes_fine_sem_seg_val, cityscapes_fine_instance_seg_test, cityscapes_fine_sem_seg_test, voc_2007_trainval, voc_2007_train, voc_2007_val, voc_2007_test, voc_2012_trainval, voc_2012_train, voc_2012_val"
Is there anything to do with your data setting?

Why using different hyperparameters in VOC split2?

Hi authors,

I found the hyperparameters for the experiments on VOC split2 are a little bit different from the ones used in split1. For example, the learning rate in split2 is 5x of the one in split1. And the learning rate schedule (the step to decrease learning rate) is also a bit different.

My question is that are the results in the paper generated by different hyperparameters for three splits? If so, do different hyperparameters offer better results than a unified set of hyperparameters?

Thanks for your reply in advance.

About data augmentation

Hello.

According to the configuration files, the minimum size of inputs (INPUT.MIN_SIZE_TRAIN) has multiple values. This setting means that multi-scale training is used in the experiment. I also reviewed the code from [Kang et al., 2019, Yan et al., 2019] and both of them use a single-scale training setting. I wonder whether the multi-scale training is one of the factors making your method have very significant improvement than currently meta-learning-based ones (some results have >10% improvement). Have you evaluated performance under the same experiment settings (such as single-scale training) in other methods?

Thanks.

infinite loop while preparing splits

Hi I have a 3 known class dataset and 2 novel classes. I am trying to prepare the splits according to prepare_coco_few_shot.py but for shots of 5 or more, for some classes the script gets stuck in an infinite loop. It works fine for the coco dataset. Any suggestion?

compile error

when I run python setup.py build develop, an error occurred.

/home/super/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/torch/include/pybind11/cast.h:2108:44: error: no matching function for call to ‘collect_arguments(pybind11::object&, const pybind11::handle&)’
     return detail::collect_arguments<policy>(std::forward<Args>(args)...).call(derived().
                                            ^
/home/super/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/torch/include/pybind11/cast.h:2087:1: note: candidate: template<pybind11::return_value_policy policy, class ... Args, class> pybind11::detail::simple_collector<policy> pybind11::detail::collect_arguments(Args&& ...)
 simple_collector<policy> collect_arguments(Args &&...args) {
 ^
/home/super/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/torch/include/pybind11/cast.h:2087:1: note:   template argument deduction/substitution failed:
/home/super/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/torch/include/pybind11/cast.h:2094:1: note: candidate: template<pybind11::return_value_policy policy, class ... Args, class> pybind11::detail::unpacking_collector<policy> pybind11::detail::collect_arguments(Args&& ...)
 unpacking_collector<policy> collect_arguments(Args &&...args) {
 ^
/home/super/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/torch/include/pybind11/cast.h:2094:1: note:   template argument deduction/substitution failed:
error: command '/usr/local/cuda-9.0/bin/nvcc' failed with exit status 1

my torch version and gcc version are as follows:

torch==1.3.0+cu92 torchvision==0.4.0+cu92
gcc 5.4.0

thanks :)

about training time.

thanks for your work, about few shot, we expect less train data and less training time. but I think it use a lot of times during training steps, maybe it Slow convergence compare meta learning method?

How to create a new shot for training, e.g. 20 shot or 30 shot?

Hi authors,

How can I add a new shot for training, e.g. 20 shot or 30 shot? I attempt to add 20 shot to train the network but your code just prints a string of keys of training dataset name like this:
image

May you show me a way to register a new shot for training?

Sincerely,
Duynn

Fine-tuning method used in paper

There are two fine-tuning methods proposed in TRAIN_INST.md, one with random weights and the other with novel weights.
I could not locate the file : configs/PascalVOC-detection/split1/faster_rcnn_R_101_FPN_ft_novel1_1shot.yaml

Also, in the paper what was the initialization that was performed for finetuning? Random weights or novel weights and what was the difference in outcomes?

compile error

I have successfully installed detectron2 and then i run python setup.py build develop to rebuild this repository, but I met this error :

/home/baby47/Documents/few-shot-object-detection-master/fsdet/layers/csrc/vision.cpp:79:8: error: ‘modulated_deform_conv_backward’ was not declared in this scope
&modulated_deform_conv_backward,
^
/home/baby47/Documents/few-shot-object-detection-master/fsdet/layers/csrc/vision.cpp:79:8: note: suggested alternative:
In file included from /home/baby47/Documents/few-shot-object-detection-master/fsdet/layers/csrc/vision.cpp:7:0:
/home/baby47/Documents/few-shot-object-detection-master/fsdet/layers/csrc/deformable/deform_conv.h:314:13: note: ‘detectron2::modulated_deform_conv_backward’
inline void modulated_deform_conv_backward(
^
error: command 'gcc' failed with exit status 1

My environment is based on torch1.4.0 cuda10.0 and gcc 5.4.0.

Could you explain possible reasons?
Thanks

Questions about base classes annotation for LVIS

Hi,
I'm curious about how to generate the annotation of base classes for LVIS, i.e. lvis_v0_5_train_freq and lvis_v0_5_train_common.

Here is what I implemented:

import json

save_names = {
    'f': 'lvis_v0.5_train_freq.json',
    'c': 'lvis_v0.5_train_common.json',
    'r': 'lvis_v0.5_train_rare.json'
}

with open('datasets/lvis/lvis_v0.5_train.json', 'r') as f:
    data = json.load(f)


anns = data['annotations']
cats = data['categories']

split_annos = {
    'f': [],
    'c': [],
    'r': []
}

for ann in anns:
    cat = cats[ann['category_id'] - 1]
    assert ann['category_id'] == cat['id']
    frequency = cat['frequency']
    split_annos[frequency].append(ann)

for name in save_names.keys():
    new_data = {
        'info': data['info'],
        'licenses': data['licenses'],
        'categories': data['categories'],
        'images': data['images'],
        'annotations': split_annos[name],
    }
    print('name {}, instance num {}'.format(name, len(split_annos[name])))
    with open(save_names[name], 'w') as f:
        json.dump(new_data, f)

Obviously, this Implementation does not take into account that some images may have both freq and common classes annotations.
If I guess wrong, could you upload yours about it? Thank you very much.

How much memory for training?

Dear authors,

Thank you for your shared source of code!

I have a problem with memory. I was wondering if you could please tell me how much memory of GPU for training. Btw, I only have 1 GPU 12Gb.

Best regards.

why 'Train base only' achieves the novel mAP 9.0?

Thanks for your good work!
But there is a weird phenomenon in Table2, the [Train base only] method achieves 9.0 nAP. As far as I understand, there is not any labeled novel instance while using this method. If any, maybe you ignore its label and treat it as background. Thus the network could not learn any class-specific information of a certain novel class, and the weights of classification and regression head of novel classes are just random initializations, why it can achieve nAP 9.0?
I'm looking forward to your answer.

nvcc fatal : Unsupported gpu architecture 'compute 61'

Hi All,

I am tryign to set this repo on my machine with Ubuntu 16.04 and an Nvidia P6000 GPU with Cuda 10.1. When I initiate the python setup.py build develop command, I get the following error:

nvcc fatal   : Unsupported gpu architecture 'compute_61
error: command '/usr/bin/nvcc' failed with exit status 1

Can somebody please help me resolve this error?

Thank you.

Can't import model_zoo

When trying to import model_zoo as following:

from fsdet import model_zoo

attribute error raises as:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from fsdet import model_zoo
  File "/media/kist/DATA_2/few-shot-object-detection/fsdet/model_zoo/__init__.py", line 7, in <module>
    from .model_zoo import get, get_config_file, get_checkpoint_url
  File "/media/kist/DATA_2/few-shot-object-detection/fsdet/model_zoo/model_zoo.py", line 182, in <module>
    model = get('COCO-detection/faster_rcnn_R_101_FPN_ft_all_1shot_unfreeze.yaml', True)
  File "/media/kist/DATA_2/few-shot-object-detection/fsdet/model_zoo/model_zoo.py", line 178, in get
    model = build_model(cfg)
  File "/media/kist/DATA_2/few-shot-object-detection/fsdet/modeling/meta_arch/build.py", line 18, in build_model
    return META_ARCH_REGISTRY.get(meta_arch)(cfg)
  File "/media/kist/DATA_2/few-shot-object-detection/fsdet/modeling/meta_arch/rcnn.py", line 33, in __init__
    self.roi_heads = build_roi_heads(cfg, self.backbone.output_shape())
  File "/media/kist/DATA_2/few-shot-object-detection/fsdet/modeling/roi_heads/roi_heads.py", line 40, in build_roi_heads
    return ROI_HEADS_REGISTRY.get(name)(cfg, input_shape)
  File "/media/kist/DATA_2/few-shot-object-detection/fsdet/modeling/roi_heads/roi_heads.py", line 372, in __init__
    self._init_box_head(cfg)
  File "/media/kist/DATA_2/few-shot-object-detection/fsdet/modeling/roi_heads/roi_heads.py", line 404, in _init_box_head
    self.cls_agnostic_bbox_reg,
  File "/media/kist/DATA_2/few-shot-object-detection/fsdet/modeling/roi_heads/fast_rcnn.py", line 392, in __init__
    self.scale = global_cfg.MODEL.ROI_HEADS.COSINE_SCALE
  File "/home/kist/few-shot-object-detection/fsdet/lib/python3.7/site-packages/yacs/config.py", line 141, in __getattr__
    raise AttributeError(name)
AttributeError: MODEL

Adding a regression head

Hi

Thanks for sharing your work , along with the classification and regression head , i wanted to add another regression head. How can i go about this?

Thanks in advance.

json files generated with seed0 mismatch the ones you provide

I notice some errors in the few-shot json files for coco. For instance, the json file full_box_1shot_person_trainval.json contains redundant images, expected 1 but 8. Moreover, I try to generate these files that are directly under folder datasets/cocosplit/ with seed 0. However, it turns out different with those you provide. Hope for clarifying. Thanks.

ckpt_surgery on VOC like custom dataset

I am using a custom dataset with annotations similar to VOC and the evaluation mechanism identified is also similar. In that regard I would like to perform a novel initialization before fine-tuning. The base dataset contains 7 classes and novel contains 3 classes (modified the codebase accordingly). When I try to perform a checkpoint combine.. i get the following error. Any help would be appreciated.
Traceback (most recent call last):
File "tools/ckpt_surgery.py", line 311, in
combine_ckpts(args)
File "tools/ckpt_surgery.py", line 143, in combine_ckpts
surgery_loop(args, surgery)
File "tools/ckpt_surgery.py", line 181, in surgery_loop
surgery(param_name, False, tar_size, ckpt, ckpt2)
File "tools/ckpt_surgery.py", line 125, in surgery
ckpt2_weight = ckpt2['model'][weight_name]
KeyError: 'roi_heads.box_predictor.cls_score.bias'

I understand the error that the bias for the layer 'roi_heads.box_predictor.cls_score' is missing. But how can that be so is my question, and how can I avoid that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.