GithubHelp home page GithubHelp logo

chongruo / detectron2-resnest Goto Github PK

View Code? Open in Web Editor NEW

This project forked from facebookresearch/detectron2

384.0 384.0 73.0 2.26 MB

A fork of Detectron2 with ResNeSt backbone

Home Page: https://arxiv.org/abs/2004.08955

License: Apache License 2.0

Shell 0.64% Python 89.11% C++ 3.55% Cuda 6.61% Dockerfile 0.09%
detectron2 resnest

detectron2-resnest's Introduction

Hi there!

github follow profile views

chongruo

detectron2-resnest's People

Contributors

alexander-kirillov avatar arutyunovg avatar botcs avatar bryant1410 avatar bxiong1202 avatar chongruo avatar endernewton avatar jerryzcn avatar kondela avatar lyttonhao avatar marcszafraniec avatar maxfrei750 avatar obendidi avatar patricklabatut avatar ppwwyyxx avatar rajprateek avatar raymondcm avatar rbgirshick avatar sampepose avatar srishti-nema avatar superirabbit avatar timgates42 avatar timofurrer avatar vkhalidov avatar wangg12 avatar wanyenlo avatar wat3rbro avatar xmyqsh avatar yanicklandry avatar zhanghang1989 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

detectron2-resnest's Issues

Performing inference with ResNeSt 200 returns empty tensors

Instructions To Reproduce the Issue:

I was trying to follow this tutorial Detectron2 Beginner's Tutorial using ResNeSt 200 instead of Mask RCNN to perform instance segmentation.

In order to get the configs and weights of the model I used the code proposed in the following issue #25 :

cfg = get_cfg()
cfg.merge_from_file('./configs/COCO-InstanceSegmentation/mask_cascade_rcnn_ResNeSt_200_FPN_dcn_syncBN_all_tricks_3x.yaml')
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5  # set threshold for this model
cfg.MODEL.WEIGHTS = "https://s3.us-west-1.wasabisys.com/resnest/detectron/resnest200_detectron-02644020.pth"
predictor = DefaultPredictor(cfg)
outputs = predictor(im)

print(outputs["instances"].pred_classes)
print(outputs["instances"].pred_boxes)

Running the code above returns empty tensors when performing inference:

tensor([], device='cuda:0', dtype=torch.int64)
Boxes(tensor([], device='cuda:0', size=(0, 4)))

Hence, there is no generated mask:

image

Expected behavior:

The model should return an image masked and labeled. If the model is instantiated through the model zoo the results are as expected:

cfg = get_cfg()
cfg.merge_from_file("./configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml")
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5
cfg.MODEL.WEIGHTS = model_zoo.get_checkpoint_url("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml")

print(outputs["instances"].pred_classes)
print(outputs["instances"].pred_boxes)

Results:

tensor([17,  0,  0,  0,  0,  0,  0,  0, 25,  0, 25, 25,  0,  0, 24],
       device='cuda:0')
Boxes(tensor([[126.6035, 244.8977, 459.8291, 480.0000],
        [251.1083, 157.8127, 338.9731, 413.6379],
        [114.8496, 268.6864, 148.2352, 398.8111],
        [  0.8217, 281.0327,  78.6072, 478.4210],
        [ 49.3954, 274.1229,  80.1545, 342.9808],
        [561.2248, 271.5816, 596.2755, 385.2552],
        [385.9072, 270.3125, 413.7130, 304.0397],
        [515.9295, 278.3744, 562.2792, 389.3802],
        [335.2409, 251.9167, 414.7491, 275.9375],
        [350.9300, 269.2060, 386.0984, 297.9081],
        [331.6292, 230.9996, 393.2759, 257.2009],
        [510.7349, 263.2656, 570.9865, 295.9194],
        [409.0841, 271.8646, 460.5582, 356.8722],
        [506.8767, 283.3257, 529.9403, 324.0392],
        [594.5663, 283.4820, 609.0577, 311.4124]], device='cuda:0'))

Masked image:
image

Environment:

After running the following command:

wget -nc -q https://github.com/facebookresearch/detectron2/raw/master/detectron2/utils/collect_env.py && python collect_env.py

I get environment details as follows:

------------------------  ---------------------------------------------------------------
sys.platform              linux
Python                    3.6.9 (default, Jul 17 2020, 12:50:27) [GCC 8.4.0]
numpy                     1.18.5
detectron2                0.1.1 @/content/detectron2-ResNeSt/detectron2
detectron2 compiler       GCC 7.5
detectron2 CUDA compiler  10.1
detectron2 arch flags     sm_75
DETECTRON2_ENV_MODULE     <not set>
PyTorch                   1.6.0+cu101 @/usr/local/lib/python3.6/dist-packages/torch
PyTorch debug build       False
CUDA available            True
GPU 0                     Tesla T4
CUDA_HOME                 /usr/local/cuda
NVCC                      Cuda compilation tools, release 10.1, V10.1.243
Pillow                    7.0.0
torchvision               0.7.0+cu101 @/usr/local/lib/python3.6/dist-packages/torchvision
torchvision arch flags    sm_35, sm_50, sm_60, sm_70, sm_75
cv2                       4.1.2
------------------------  ---------------------------------------------------------------
PyTorch built with:
  - GCC 7.3
  - C++ Version: 201402
  - Intel(R) Math Kernel Library Version 2019.0.5 Product Build 20190808 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v1.5.0 (Git Hash e2ac1fac44c5078ca927cb9b90e1b3066a0b2ed0)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 10.1
  - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75
  - CuDNN 7.6.3
  - Magma 2.5.2
  - Build settings: BLAS=MKL, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_VULKAN_WRAPPER -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_STATIC_DISPATCH=OFF, 

Following official Colab Notebook but cant add ResNeSt config

❓ I'm using the official colab notebook

https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5

but how do I add the config for ReNeSt

from detectron2.engine import DefaultTrainer
from detectron2.config import get_cfg

cfg = get_cfg()
cfg.merge_from_file("COCO-Detection/faster_cascade_rcnn_ResNeSt_50_FPN_syncbn_range-scale-1x.yaml")
cfg.DATASETS.TRAIN = ("my_dataset_train",)
cfg.DATASETS.TEST = ()
cfg.DATALOADER.NUM_WORKERS = 2
cfg.MODEL.WEIGHTS = model_zoo.get_checkpoint_url("COCO-Detection/faster_cascade_rcnn_ResNeSt_50_FPN_syncbn_range-scale-1x.yaml") # Let training initialize from model zoo
cfg.SOLVER.IMS_PER_BATCH = 2
cfg.SOLVER.BASE_LR = 0.00025 # pick a good LR
cfg.SOLVER.MAX_ITER = 300 # 300 iterations seems good enough for this toy dataset; you may need to train longer for a practical dataset
cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = 128 # faster, and good enough for this toy dataset (default: 512)
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 1 # only has one class (ballon)

os.makedirs(cfg.OUTPUT_DIR, exist_ok=True)
trainer = DefaultTrainer(cfg)
trainer.resume_or_load(resume=False)
trainer.train()

This doesnt seem to work and gives following error
AssertionError: Config file 'COCO-Detection/faster_cascade_rcnn_ResNeSt_50_FPN_syncbn_range-scale-1x.yaml' does not exist!

Cannot rebulid Detectron2

when I execute this code: python -m pip install -e .
I encountered the following error.
I'm very confused, I found many methods and didn't solve them.
I followed the step by step instructions provided by you.
https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5#scrollTo=Vk4gID50K03a
错误一:

(pytorch1.5) ⚙ hdc@hdc-IBM  /media/hdc/data1/dzc/detectron2-ResNeSt-resnest/detectron2  python -m pip install -e . [20/05/23| 9:10AM] ERROR: File "setup.py" not found. Directory cannot be installed in editable mode: /media/hdc/data1/dzc/detectron2-ResNeSt-resnest/detectron2
错误二:运行train_net.py
from detectron2 import _C ImportError: cannot import name '_C' from 'detectron2' (/media/hdc/data1/dzc/detectron2-ResNeSt-resnest/detectron2/__init__.py)

How to fine-tune on custom data?

Hello, how do I fine-tune one of your pretrained models with my custom data, is it similar to fine-tuning a detectron2 model?

advice for the way of naming weights

Thanks for your great work.

In your provided pre-trained weights for detectron2, I notice that the names of tensors start with backbone.bottom_up (eg. backbone.bottom_up.stem.conv1_1.weight), and I can not directly use them for other models such as C4 models. I have tried to rename them and enable loading weights by more models in detectron2. Here is my way to save the weights:

dict(model={"stem.conv1_1.weight": weights1, ...}, matching_heuristics=True)

By adding matching_heuristics=True, we can use the automatic matching rules in detectron2 and do not need to add the prefix name manually.

Could you please consider updating your model weights?

Predicting the trained detectron2-Resnest model in original detectron2

Hi @zhanghang1989

I used your pre-trained model in training with our custom dataset and it worked very well and thanks to your work.

I have a doubt regarding the trained model and installation.

Consider the process as follows.

  1. I have trained the model with your repo detectron2-resnest.
  2. In my local I have detectron2(original) installed.
  3. While I am predicting the model trained from your repo in local I'm getting the below error.

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/yacs-0.1.6-py3.6.egg/yacs/config.py in _merge_a_into_b(a, b, root, key_list)
458 if isinstance(v, CfgNode):
459 try:
--> 460 _merge_a_into_b(v, b[k], root, key_list + [k])
461 except BaseException:
462 raise

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/yacs-0.1.6-py3.6.egg/yacs/config.py in _merge_a_into_b(a, b, root, key_list)
471 root.raise_key_rename_error(full_key)
472 else:
--> 473 raise KeyError("Non-existent config key: {}".format(full_key))
474
475

KeyError: 'Non-existent config key: MODEL.RESNETS.RADIX'

Note: I have used the config file from your repo i.e /detectron2-ResNeSt/configs/COCO-InstanceSegmentation/mask_rcnn_ResNeSt_50_FPN_syncBN_1x.yaml

Is there any way that I can predict the trained model from the original detectron2 instead of your repo??

RuntimeError: The size of tensor a (1741) must match the size of tensor b (4741) at non-singleton dimension 0

最近想用下ResNeSt,于是按照步骤安装了detectron2-ResNeSt,但是在运行时遇到一点问题,错误如下:
Traceback (most recent call last):
File "demo/demo.py", line 89, in
predictions, visualized_output = demo.run_on_image(img)
File "/root/detectron2-ResNeSt/demo/predictor.py", line 48, in run_on_image
predictions = self.predictor(image)
File "/root/anaconda3/envs/pytorch1.4.0/lib/python3.6/site-packages/detectron2/engine/defaults.py", line 196, in call
predictions = self.model([inputs])[0]
File "/root/anaconda3/envs/pytorch1.4.0/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/root/anaconda3/envs/pytorch1.4.0/lib/python3.6/site-packages/detectron2/modeling/meta_arch/rcnn.py", line 108, in forward
return self.inference(batched_inputs)
File "/root/anaconda3/envs/pytorch1.4.0/lib/python3.6/site-packages/detectron2/modeling/meta_arch/rcnn.py", line 165, in inference
proposals, _ = self.proposal_generator(images, features, None)
File "/root/anaconda3/envs/pytorch1.4.0/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/root/anaconda3/envs/pytorch1.4.0/lib/python3.6/site-packages/detectron2/modeling/proposal_generator/rpn.py", line 182, in forward
self.training,
File "/root/anaconda3/envs/pytorch1.4.0/lib/python3.6/site-packages/detectron2/modeling/proposal_generator/rpn_outputs.py", line 142, in find_top_rpn_proposals
keep = batched_nms(boxes.tensor, scores_per_img, lvl, nms_thresh)
File "/root/anaconda3/envs/pytorch1.4.0/lib/python3.6/site-packages/detectron2/layers/nms.py", line 17, in batched_nms
return box_ops.batched_nms(boxes, scores, idxs, iou_threshold)
File "/root/anaconda3/envs/pytorch1.4.0/lib/python3.6/site-packages/torchvision/ops/boxes.py", line 75, in batched_nms
boxes_for_nms = boxes + offsets[:, None]
RuntimeError: The size of tensor a (1741) must match the size of tensor b (4741) at non-singleton dimension 0

我的输入如果是detectron2上原有的R50-FPN,即
python demo/demo.py --config-file /root/detectron2-ResNeSt/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml \

--input test_img/input/0_original.jpg test_img/input/1.jpg test_img/input/2.png test_img/input/3.png test_img/input/4.png --output test_img/output/
--opts MODEL.WEIGHTS /root/detectron2-ResNeSt/pretrain_model/pretrain_model/R50-FPN-1x/model_final_a54504.pkl
程序可以跑通;

但是如果输入换为ResNeSt50,即
python demo/demo.py --config-file /root/detectron2-ResNeSt/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml \

--input test_img/input/0_original.jpg test_img/input/1.jpg test_img/input/2.png test_img/input/3.png test_img/input/4.png --output test_img/output/
--opts MODEL.WEIGHTS /root/detectron2-ResNeSt/pretrain_model/pretrain_model/ResNeSt50/mask_rcnn_ResNeSt_50_FPN_syncBN_1x-f442d863.pth
会出现以上问题。即
RuntimeError: The size of tensor a (1741) must match the size of tensor b (4741) at non-singleton dimension 0,
请问这个问题怎么解决。

how to let AP in range [0,1]?

When I run train_net.py and specify eval_only = True to test and calculate the AP, I find that the calculated AP range is not between [0,1], I feel very strange. Do you know how to calculate the AP value for each range [0,1]? After finding the AP for each category, I can calculate the mAP on the entire test data set. Thank you

Load pretrained mask_rcnn_ResNeSt_101_FPN_syncBN model

I am a little bit confused on how to load a pretrained detectron model for using it in my custom dataset. For example, I want to load the model mask_rcnn_ResNeSt_101_FPN_syncBN_1x-528502c6.pth and I tried the following:

from detectron2.modeling import build_model
from detectron2.checkpoint import DetectionCheckpointer
from detectron2.config import get_cfg

args.config_file = 'mask_rcnn_ResNeSt_101_FPN_syncBN_1x.yaml'

def setup(args):
    """
    Create configs and perform basic setups.
    """
    cfg = get_cfg()
    cfg.merge_from_file('mask_rcnn_ResNeSt_101_FPN_syncBN_1x.yaml')
    cfg.merge_from_list(args.opts)
    cfg.freeze()
    default_setup(cfg, args)
    return cfg

cfg = setup(args)

model = build_model(cfg)  # returns a torch.nn.Module

DetectionCheckpointer(model).load('mask_rcnn_ResNeSt_101_FPN_syncBN_1x-528502c6.pth')  

checkpointer = DetectionCheckpointer(model, save_dir="output")

but I get the following error:


FileNotFoundErrorTraceback (most recent call last)
<ipython-input-20-e13983893796> in <module>
     16     return cfg
     17 
---> 18 cfg = setup(args)
     19 
     20 model = build_model(cfg)  # returns a torch.nn.Module

<ipython-input-20-e13983893796> in setup(args)
     10     """
     11     cfg = get_cfg()
---> 12     cfg.merge_from_file('mask_rcnn_ResNeSt_101_FPN_syncBN_1x.yaml')
     13     cfg.merge_from_list(args.opts)
     14     cfg.freeze()

/usr/local/lib/python3.6/dist-packages/detectron2/config/config.py in merge_from_file(self, cfg_filename, allow_unsafe)
     24     def merge_from_file(self, cfg_filename: str, allow_unsafe: bool = True) -> None:
     25         assert PathManager.isfile(cfg_filename), f"Config file '{cfg_filename}' does not exist!"
---> 26         loaded_cfg = _CfgNode.load_yaml_with_base(cfg_filename, allow_unsafe=allow_unsafe)
     27         loaded_cfg = type(self)(loaded_cfg)
     28 

/usr/local/lib/python3.6/dist-packages/fvcore/common/config.py in load_yaml_with_base(filename, allow_unsafe)
     84                 base_cfg_file = os.path.join(os.path.dirname(filename), base_cfg_file)
     85             base_cfg = CfgNode.load_yaml_with_base(
---> 86                 base_cfg_file, allow_unsafe=allow_unsafe
     87             )
     88             del cfg[BASE_KEY]

/usr/local/lib/python3.6/dist-packages/fvcore/common/config.py in load_yaml_with_base(filename, allow_unsafe)
     47             (dict): the loaded yaml
     48         """
---> 49         with PathManager.open(filename, "r") as f:
     50             try:
     51                 cfg = yaml.safe_load(f)

/usr/local/lib/python3.6/dist-packages/fvcore/common/file_io.py in open(path, mode, buffering, **kwargs)
    573         """
    574         return PathManager.__get_path_handler(path)._open(  # type: ignore
--> 575             path, mode, buffering=buffering, **kwargs
    576         )
    577 

/usr/local/lib/python3.6/dist-packages/fvcore/common/file_io.py in _open(self, path, mode, buffering, encoding, errors, newline, closefd, opener, **kwargs)
    378             newline=newline,
    379             closefd=closefd,
--> 380             opener=opener,
    381         )
    382 

FileNotFoundError: [Errno 2] No such file or directory: '../Base-RCNN-FPN.yaml'

Any idea of how to do this?

coco数据集的类别修改成自己的 怎么设置

AssertionError: Attribute 'thing_classes' in the metadata of 'coco_2017_train' cannot be set to a different value!
['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush'] != ['Dascyllus Reticulatus', 'Chaetodon Lununatus', 'Pempheris Vanicolensis', 'Dascyllus Aruanus', 'Plectrogly-Phidodon Dickii', 'Amphiprion Clarkii', 'Chaetodon Trifascialis', 'Acanthurus Nigrofuscus', 'Chromis Chrysura', 'Hemigumnus Malapterus', 'Myripristis Kuntee', 'Chaetodon Speculum', 'Abudefduf Vaigiensis', 'Neoglyphidodon Nigroris', 'Zebrasoma Scopas']

Is CPU inference possible?

Is possible to use a detectron2-resnest trained model to infere using only CPU?
I tried changing DEVICE from cuda to CPU in config.yaml file, but i get a NotImplemented error.
(This works in original Detectron2)

Thanks in advance.

"Not Implemented error" on resnest version and "KeyError: 'Non-existent config key: MODEL.RESNETS.RADIX "' on master version

Installed two different version for custom training (on resnest-200) , but getting following errors:

  1. Master version: (https://github.com/zhanghang1989/detectron2-ResNeSt/tree/6e150b3adb3be1f18efd0bf940206d99c95dbbd8)
    local/lib/python3.6/site-packages/yacs/config.py in _merge_a_into_b(a, b, root, key_list)
    489 root.raise_key_rename_error(full_key)
    490 else:
    --> 491 raise KeyError("Non-existent config key: {}".format(full_key))
    492
    493
    KeyError: 'Non-existent config key: MODEL.RESNETS.RADIX "

  2. resnest version resnest
    Here getting Not Implemented error

@zhanghang1989 , @Jerryzcn , @chongruo
kindly suggest me for downloading right version for training resnest200

About data format

Hello, thanks for your nice work!
But when I use this project following the README file, I got an ERROR saying Expected bytes, got list, any suggestions to solve this? I guess it's something wrong with my coco-format dataset, but actually I can run normally using other detectron2-based projects like AdelaiDet when specify INPUT.FORMAT='bitmask' in the config file, so I just don'k know if there is any differences of dataset format between those projects and yours.
Much Appreciated!
Alvin

## ❓ How to merge this repo with detectron2 master?

❓ How to merge this repo with detectron2 master?

I found the ResNeSt code is all included in resnet.py and splat.py. Besides, this repo uses fvcore==0.1.dev200407, which is different with detectron2 master requirements "fvcore>=0.1.1". Could you tell me what you guys do with fvcore 0.1.dev200407? Could we split this content from fvcore?

How can I use the demo (inference) on cpu?

Hi, is there a way I can use the demo.py on cpu? When I run it and it tries to load, it breaks because the pretrained model is for gpu. I couldn't find the option / flag to turn off cuda. Is that possible for the demo script? Thanks!

Eric

How to train with batch size 1

I try to train an instance segmentation model with resnest200 backbone with image size 1024. But due to memory constraint, I can fit only batch size of 1. But when I use SyncBN, It requires more than 1 sample. Can I use other batch norm (or set norm to None) without effect performance

What does instances_predictions.pth refer to?

After I run train.py, instances_predictions.pth will be generated in the ./output/inference/ directory. What does instances_predictions.pth refer to?
What does it mean?
What's the use?
Thanks a lot!

Some model parameters are not in the checkpoint

python demo.py --config-file ../configs/COCO-InstanceSegmentation/mask_rcnn_ResNeSt_50_FPN_syncBN_1x.yaml --input input.jpg --output output.jpg

[06/09 08:22:15 detectron2]: Arguments: Namespace(confidence_threshold=0.5, config_file='../configs/COCO-InstanceSegmentation/mask_rcnn_ResNeSt_50_FPN_syncBN_1x.yaml', input=['input.jpg'], opts=[], output='output.jpg', video_input=None, webcam=False)
[06/09 08:22:22 fvcore.common.checkpoint]: Loading checkpoint from https://hangzh.s3-us-west-1.amazonaws.com/encoding/models/resnest50_detectron-255b5649.pth
[06/09 08:22:22 fvcore.common.file_io]: Downloading https://hangzh.s3-us-west-1.amazonaws.com/encoding/models/resnest50_detectron-255b5649.pth ...
[06/09 08:22:22 fvcore.common.download]: Downloading from https://hangzh.s3-us-west-1.amazonaws.com/encoding/models/resnest50_detectron-255b5649.pth ...
resnest50_detectron-255b5649.pth: 102MB [15:26, 110kB/s]
[06/09 08:37:48 fvcore.common.download]: Successfully downloaded /root/.torch/fvcore_cache/encoding/models/resnest50_detectron-255b5649.pth. 102065124 bytes.
[06/09 08:37:48 fvcore.common.file_io]: URL https://hangzh.s3-us-west-1.amazonaws.com/encoding/models/resnest50_detectron-255b5649.pth cached in /root/.torch/fvcore_cache/encoding/models/resnest50_detectron-255b5649.pth
[06/09 08:37:49 fvcore.common.checkpoint]: Some model parameters are not in the checkpoint:
roi_heads.mask_head.mask_fcn2.norm.{running_mean, running_var, weight, bias}
roi_heads.mask_head.mask_fcn1.norm.{bias, weight, running_var, running_mean}
backbone.fpn_output2.norm.{running_var, weight, running_mean, bias}
roi_heads.box_head.conv1.norm.{running_var, running_mean, weight, bias}
roi_heads.mask_head.mask_fcn3.norm.{bias, running_mean, running_var, weight}
backbone.fpn_lateral5.norm.{running_mean, running_var, weight, bias}
proposal_generator.anchor_generator.cell_anchors.{4, 3, 1, 2, 0}
roi_heads.box_predictor.bbox_pred.{bias, weight}
roi_heads.mask_head.predictor.{bias, weight}
roi_heads.mask_head.mask_fcn4.norm.{bias, running_var, weight, running_mean}
roi_heads.box_predictor.cls_score.{bias, weight}
roi_heads.box_head.conv2.norm.{running_var, bias, running_mean, weight}
roi_heads.box_head.conv4.weight
backbone.fpn_lateral3.norm.{running_mean, running_var, bias, weight}
roi_heads.box_head.conv3.norm.{running_var, running_mean, weight, bias}
backbone.fpn_lateral5.weight
roi_heads.box_head.conv2.weight
roi_heads.box_head.fc1.{bias, weight}
proposal_generator.rpn_head.objectness_logits.{bias, weight}
backbone.fpn_lateral4.norm.{running_mean, running_var, weight, bias}
backbone.fpn_lateral2.norm.{running_var, weight, bias, running_mean}
backbone.fpn_output5.norm.{running_mean, weight, running_var, bias}
backbone.fpn_output2.weight
roi_heads.box_head.conv4.norm.{running_mean, weight, running_var, bias}
backbone.fpn_output3.weight
backbone.fpn_output4.norm.{weight, running_mean, bias, running_var}
roi_heads.mask_head.deconv.{weight, bias}
backbone.fpn_output3.norm.{running_mean, weight, bias, running_var}
proposal_generator.rpn_head.anchor_deltas.{weight, bias}
backbone.fpn_lateral4.weight
backbone.fpn_output5.weight
roi_heads.mask_head.mask_fcn3.weight
backbone.fpn_output4.weight
roi_heads.mask_head.mask_fcn2.weight
roi_heads.box_head.conv1.weight
proposal_generator.rpn_head.conv.{bias, weight}
backbone.fpn_lateral3.weight
roi_heads.box_head.conv3.weight
backbone.fpn_lateral2.weight
roi_heads.mask_head.mask_fcn4.weight
roi_heads.mask_head.mask_fcn1.weight

This implementation yields shape mismatch errors for Semantic Segmentation when Radix > 1

Instructions To Reproduce the Issue:

  1. what changes you made (git diff) or what code you wrote

I just moved the keys specific to ResNeSt under MODEL.RESNEST for better clarity.

  1. what exact command you run:
    Standard training using this config file :
_BASE_: "Base-SemSeg.yaml"

MODEL:
  WEIGHTS: "https://hangzh.s3-us-west-1.amazonaws.com/encoding/models/resnest200_detectron-02644020.pth"
  BACKBONE:
    NAME: "build_resnest_fpn_backbone"
  RESNEST:
    RADIX: 2
  RESNETS:
    DEPTH : 50
    STRIDE_IN_1X1: False
    NORM: "SyncBN" 
  FPN:
    NORM: "SyncBN"
  ROI_HEADS:
    NAME: CascadeROIHeads
  ROI_BOX_HEAD:
    NAME: "FastRCNNConvFCHead"
    NUM_CONV: 4
    NUM_FC: 1
    NORM: "SyncBN"
    CLS_AGNOSTIC_BBOX_REG: True
  SEM_SEG_HEAD:
    NORM: "SyncBN"
    NUM_CLASSES: 3
  RPN:
    POST_NMS_TOPK_TRAIN: 2000
  PIXEL_MEAN: [123.68, 116.779, 103.939]
  PIXEL_STD: [58.393, 57.12, 57.375]
SOLVER:
  IMS_PER_BATCH: 16
  BASE_LR: 0.02
  STEPS: (240000, 255000)
  MAX_ITER: 270000
TEST:
  PRECISE_BN:
    ENABLED: True
  AUG:
    ENABLED: True

Base-SemSeg.yaml contains the data registration and the "SemanticSegmentor" related entries.

  1. what you observed (including full logs):
Traceback (most recent call last):
  File "/home/jupyter-cyril/venv_detectron2/lib/python3.6/site-packages/detectron2/engine/train_loop.py", line 132, in train
    self.run_step()
  File "/home/jupyter-cyril/venv_detectron2/lib/python3.6/site-packages/detectron2/engine/train_loop.py", line 215, in run_step
    loss_dict = self.model(data)
  File "/home/jupyter-cyril/venv_detectron2/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/jupyter-cyril/venv_detectron2/lib/python3.6/site-packages/detectron2/modeling/meta_arch/semantic_seg.py", line 81, in forward
    results, losses = self.sem_seg_head(features, targets)
  File "/home/jupyter-cyril/venv_detectron2/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/jupyter-cyril/venv_detectron2/lib/python3.6/site-packages/detectron2/modeling/meta_arch/semantic_seg.py", line 167, in forward
    F.cross_entropy(x, targets, reduction="mean", ignore_index=self.ignore_value)
  File "/home/jupyter-cyril/venv_detectron2/lib/python3.6/site-packages/torch/nn/functional.py", line 2021, in cross_entropy
    return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)
  File "/home/jupyter-cyril/venv_detectron2/lib/python3.6/site-packages/torch/nn/functional.py", line 1840, in nll_loss
    ret = torch._C._nn.nll_loss2d(input, target, weight, _Reduction.get_enum(reduction), ignore_index)
RuntimeError: input and target batch or spatial sizes don't match: target [16 x 544 x 800], input [16 x 3 x 800 x 544] at /pytorch/aten/src/THCUNN/generic/SpatialClassNLLCriterion.cu:23

Environment:

Provide your environment information using the following command:

sys.platform              linux
Python                    3.6.7 | packaged by conda-forge | (default, Nov 21 2018, 02:32:25) [GCC 4.8.2 20140120 (Red Hat 4.8.2-15)]
numpy                     1.18.3
detectron2                0.1.1 @/home/jupyter-cyril/venv_detectron2/lib/python3.6/site-packages/detectron2
detectron2 compiler       GCC 7.3
detectron2 CUDA compiler  10.0
detectron2 arch flags     sm_35, sm_37, sm_50, sm_52, sm_60, sm_61, sm_70, sm_75
DETECTRON2_ENV_MODULE     <not set>
PyTorch                   1.4.0+cu100 @/home/jupyter-cyril/venv_detectron2/lib/python3.6/site-packages/torch
PyTorch debug build       False
CUDA available            True
GPU 0                     Tesla T4
CUDA_HOME                 /usr/local/cuda
NVCC                      Cuda compilation tools, release 10.0, V10.0.130
Pillow                    6.2.1
torchvision               0.5.0+cu100 @/home/jupyter-cyril/venv_detectron2/lib/python3.6/site-packages/torchvision
torchvision arch flags    sm_35, sm_50, sm_60, sm_70, sm_75
cv2                       4.2.0
------------------------  ----------------------------------------------------------------------------------------------------------
PyTorch built with:
  - GCC 7.3
  - Intel(R) Math Kernel Library Version 2019.0.4 Product Build 20190411 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v0.21.1 (Git Hash 7d2fd500bc78936d1d648ca713b901012f470dbc)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - NNPACK is enabled
  - CUDA Runtime 10.0
  - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_37,code=compute_37
  - CuDNN 7.6.3
  - Magma 2.5.1
  - Build settings: BLAS=MKL, BUILD_NAMEDTENSOR=OFF, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -fopenmp -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -O2 -fPIC -Wno-narrowing -Wall -Wextra -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Wno-stringop-overflow, DISABLE_NUMA=1, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_STATIC_DISPATCH=OFF, 

AssertionError: Default process group is not initialized

try to use the resnet-101 for cascade network

model_name = "./mask_cascade_rcnn_ResNeSt_101_FPN_syncBN_1x.yaml" cfg.merge_from_file(model_name)
cfg.MODEL.WEIGHTS = os.path.join("./mask_cascade_rcnn_R_101_FPN_syncbn_1x-8cec1631.pth")  # path to the model we just trained

got the following error

Traceback (most recent call last):
  File "train.py", line 1330, in <module>
    main()
  File "train.py", line 1325, in main
    train(cfg,args)
  File "train.py", line 1303, in train
    trainer.train()
  File "/home/jake/Gits/make_demo_clip/car_detection_detectron2/detectron2/detectron2/engine/defaults.py", line 419, in train
    super().train(self.start_iter, self.max_iter)
  File "/home/jake/Gits/make_demo_clip/car_detection_detectron2/detectron2/detectron2/engine/train_loop.py", line 134, in train
    self.run_step()
  File "/home/jake/Gits/make_demo_clip/car_detection_detectron2/detectron2/detectron2/engine/defaults.py", line 429, in run_step
    self._trainer.run_step()
  File "/home/jake/Gits/make_demo_clip/car_detection_detectron2/detectron2/detectron2/engine/train_loop.py", line 228, in run_step
    loss_dict = self.model(data)
  File "/home/jake/venv_11.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/jake/Gits/make_demo_clip/car_detection_detectron2/detectron2/detectron2/modeling/meta_arch/rcnn.py", line 157, in forward
    features = self.backbone(images.tensor)
  File "/home/jake/venv_11.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/jake/Gits/make_demo_clip/car_detection_detectron2/detectron2/detectron2/modeling/backbone/fpn.py", line 127, in forward
    bottom_up_features = self.bottom_up(x)
  File "/home/jake/venv_11.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/jake/Gits/make_demo_clip/car_detection_detectron2/detectron2/detectron2/modeling/backbone/resnet.py", line 438, in forward
    x = stage(x)
  File "/home/jake/venv_11.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/jake/venv_11.1/lib/python3.6/site-packages/torch/nn/modules/container.py", line 117, in forward
    input = module(input)
  File "/home/jake/venv_11.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/jake/Gits/make_demo_clip/car_detection_detectron2/detectron2/detectron2/modeling/backbone/resnet.py", line 196, in forward
    out = self.conv1(x)
  File "/home/jake/venv_11.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/jake/Gits/make_demo_clip/car_detection_detectron2/detectron2/detectron2/layers/wrappers.py", line 80, in forward
    x = self.norm(x)
  File "/home/jake/venv_11.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/jake/venv_11.1/lib/python3.6/site-packages/torch/nn/modules/batchnorm.py", line 519, in forward
    world_size = torch.distributed.get_world_size(process_group)
  File "/home/jake/venv_11.1/lib/python3.6/site-packages/torch/distributed/distributed_c10d.py", line 625, in get_world_size
    return _get_group_size(group)
  File "/home/jake/venv_11.1/lib/python3.6/site-packages/torch/distributed/distributed_c10d.py", line 220, in _get_group_size
    _check_default_pg()
  File "/home/jake/venv_11.1/lib/python3.6/site-packages/torch/distributed/distributed_c10d.py", line 211, in _check_default_pg
    "Default process group is not initialized"
AssertionError: Default process group is not initialized

RuntimeError: The size of tensor a (135) must match the size of tensor b (136) at non-singleton dimension 3

I am using the ResNeSt101 model for object detection and it works perfectly if when doing inference using the whole model but I get an error when I do inference using only the backbone (because I want to inspect the features extracted from the backbone).

import detectron2.data.transforms as T
from detectron2.data import (
    MetadataCatalog,
    build_detection_test_loader,
    build_detection_train_loader,
)
from detectron2.modeling import build_model
from detectron2.checkpoint import DetectionCheckpointer
import torch
import random
from detectron2.utils.visualizer import Visualizer
import cv2
import matplotlib.pyplot as plt
from detectron2.utils.visualizer import ColorMode
import matplotlib.patches as patches
for d in random.sample(dataset_dicts, 1):
    im = cv2.imread(d["file_name"])


input_format = cfg.INPUT.FORMAT
model = build_model(cfg)
model.eval()
metadata = MetadataCatalog.get(cfg.DATASETS.TEST[0])
checkpointer = DetectionCheckpointer(model).load( "output/ResNest101_Faster_RCNN_model_Small_Anchors.pth")
# checkpointer.load(cfg.MODEL.WEIGHTS)
transform_gen = T.ResizeShortestEdge(
            [cfg.INPUT.MIN_SIZE_TEST, cfg.INPUT.MIN_SIZE_TEST], cfg.INPUT.MAX_SIZE_TEST
        )



with torch.no_grad():  # https://github.com/sphinx-doc/sphinx/issues/4258
    # Apply pre-processing to image.
    if input_format == "RGB":
        # whether the model expects BGR inputs or RGB
        original_image = im[:, :, ::-1]
    height, width = original_image.shape[:2]
    image = transform_gen.get_transform(original_image).apply_image(original_image)
    image = torch.as_tensor(image.astype("float32").transpose(2, 0, 1))

    inputs = {"image": image, "height": height, "width": width}
#     predictions = model.backbone(image.unsqueeze(0).cuda())[0]
    
    predictions = model([inputs])[0]

This code works well. This works also well:

with torch.no_grad():
    model.backbone(torch.randn(2, 3, 574, 768))

The problem begins when I use the backbone for predicting the loaded image, which has size (3,800, 1074), which I have converted to (1,3,800,1074) adding the batch dimension.

image = image.unsqueeze(0)
with torch.no_grad():
    model.backbone(image)

Here I get this error:


RuntimeErrorTraceback (most recent call last)
<ipython-input-35-290a6709c3a6> in <module>
      1 with torch.no_grad():
----> 2     model.backbone(image_proba)

/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    530             result = self._slow_forward(*input, **kwargs)
    531         else:
--> 532             result = self.forward(*input, **kwargs)
    533         for hook in self._forward_hooks.values():
    534             hook_result = hook(self, input, result)

/usr/local/lib/python3.6/dist-packages/detectron2/modeling/backbone/fpn.py in forward(self, x)
    131             top_down_features = F.interpolate(prev_features, scale_factor=2, mode="nearest")
    132             lateral_features = lateral_conv(features)
--> 133             prev_features = lateral_features + top_down_features
    134             if self._fuse_type == "avg":
    135                 prev_features /= 2

RuntimeError: The size of tensor a (135) must match the size of tensor b (136) at non-singleton dimension 3

About registering custom datasets

Hello, thanks to your great work! When I used the original detectron2 to train my custom datasets, I just need to add the path of json and images to coco module in ”./detectron2/data/datasets/builtin.py“.

But when I use your code, it doesn't work. I registered the dataset according to https://detectron2.readthedocs.io/tutorials/datasets.html.

There are problems as follows:
KeyError: "Dataset 'tt' 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"

I would like to know if your code has changed the data loading, or maybe you can provide some suggestions to solve this problem. thanks

Is AutoAugment and Mixup used for training detection models as well?

Hi,

I have used AutoAugment to train the Cascade R-CNN + ResNeST 50 models on my custom dataset along with the standard detectron2 augmentations of Random Shortest Range (640 - 800) and HFlip. Unfortunately I have not been able to achieve optimal results. I am trying to add mixup to the training process as well, as recommended in the paper. As per my understanding ResNest models were trained with AutoAugment and Mixup while detection and segmentation models were trained with Random Shortest Range and HFlip.

I would like to get some clarity on whether AutoAugment and Mixup were used to train the Cascade R-CNN + ResNeST 50. Kindly let me know if I have misunderstood the augmentation policy for detection and segmentation models.

KeyError: 'Non-existent config key: MODEL.RESNETS.RADIX'Please read & provide the following

i wanna use the "train_ResNeSt.py"with "ResNeSt" to train my own datasets,but it show this KeyError.

it print:
(pytorch1.4.0) root@111:~/detectron2-ResNeSt/maize_img/800600# python train_ResNeSt.py
Traceback (most recent call last):
File "train_ResNeSt.py", line 17, in
cfg.merge_from_file("/root/detectron2-ResNeSt/configs/COCO-InstanceSegmentation/mask_rcnn_ResNeSt_50_FPN_syncBN_1x_weights_dir_change.yaml") #original
File "/root/anaconda3/envs/pytorch1.4.0/lib/python3.6/site-packages/detectron2/config/config.py", line 47, in merge_from_file
self.merge_from_other_cfg(loaded_cfg)
File "/root/anaconda3/envs/pytorch1.4.0/lib/python3.6/site-packages/fvcore/common/config.py", line 118, in merge_from_other_cfg
return super().merge_from_other_cfg(cfg_other)
File "/root/anaconda3/envs/pytorch1.4.0/lib/python3.6/site-packages/yacs/config.py", line 217, in merge_from_other_cfg
_merge_a_into_b(cfg_other, self, self, [])
File "/root/anaconda3/envs/pytorch1.4.0/lib/python3.6/site-packages/yacs/config.py", line 464, in _merge_a_into_b
_merge_a_into_b(v, b[k], root, key_list + [k])
File "/root/anaconda3/envs/pytorch1.4.0/lib/python3.6/site-packages/yacs/config.py", line 464, in _merge_a_into_b
_merge_a_into_b(v, b[k], root, key_list + [k])
File "/root/anaconda3/envs/pytorch1.4.0/lib/python3.6/site-packages/yacs/config.py", line 477, in _merge_a_into_b
raise KeyError("Non-existent config key: {}".format(full_key))
KeyError: 'Non-existent config key: MODEL.RESNETS.RADIX'

my train_ResNeSt.py :
import random
from detectron2.utils.visualizer import Visualizer
from detectron2.data.catalog import MetadataCatalog, DatasetCatalog
import maize_img
import cv2
from detectron2.engine import DefaultTrainer
from detectron2.config import get_cfg
from detectron2.utils.logger import setup_logger
import os
setup_logger()

if name == "main":
cfg = get_cfg()

**cfg.merge_from_file("/root/detectron2-ResNeSt/configs/COCO-InstanceSegmentation/mask_rcnn_ResNeSt_50_FPN_syncBN_1x.yaml")** 

cfg.DATASETS.TRAIN = ("maize_img",)

cfg.DATASETS.TEST = ()  # no metrics implemented for this dataset
cfg.DATALOADER.NUM_WORKERS = 2

**cfg.MODEL.WEIGHTS = '/root/detectron2/pretrain_model/COCO_InstanceSegmentation_Baselines_with_MaskR-CNN/R50-FPN-3x/model_final_f10217.pkl'**

cfg.SOLVER.IMS_PER_BATCH = 2
cfg.SOLVER.BASE_LR = 0.0025
cfg.SOLVER.MAX_ITER = (2000)  

cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = (128)  # faster, and good enough for this toy dataset
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 3  # 3 classes (data, fig, hazelnut)
os.makedirs(cfg.OUTPUT_DIR, exist_ok=True)
trainer = DefaultTrainer(cfg)
trainer.resume_or_load(resume=False)
trainer.train()

how can i solve this problem ?please help me

Pre-trained ResNeSt-101 with dcnv2 model?

Hello, Thanks for your awesome work.
Did you test ResNeSt-101 with dcnv2? Because detectron2 faster-rcnn gets the best mAP with dcnv2_ResNeXt-101, ResNeSt-101 with dcnv2 may be really good too.

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.