Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Colab Notebook detectron2 compatibility #4

Closed
yqtl opened this issue Dec 2, 2020 · 1 comment
Closed

Colab Notebook detectron2 compatibility #4

yqtl opened this issue Dec 2, 2020 · 1 comment

Comments

@yqtl
Copy link

yqtl commented Dec 2, 2020

When running Colab Notebook https://colab.research.google.com/drive/1QIoL2g0jdt5E-vYKCIojkIz21j3jyEvo?usp=sharing
I encountered this error:
ValueError: Unknown pooler type


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-2f4b93b9ad6c> in <module>()
----> 1 segmenter = get_pointrend_predictor()
      2 instances = segmenter(image)["instances"]
      3 vis = PointRendVisualizer(image, metadata=MetadataCatalog.get("coco_2017_val"))
      4 Image.fromarray(vis.draw_instance_predictions(instances.to("cpu")).get_image())

11 frames
/content/phosa/pointrend.py in get_pointrend_predictor(min_confidence, image_format)
     30     cfg.MODEL.WEIGHTS = POINTREND_MODEL_WEIGHTS
     31     cfg.INPUT.FORMAT = image_format
---> 32     return DefaultPredictor(cfg)
     33 
     34 

/usr/local/lib/python3.6/dist-packages/detectron2/engine/defaults.py in __init__(self, cfg)
    180     def __init__(self, cfg):
    181         self.cfg = cfg.clone()  # cfg can be modified by model
--> 182         self.model = build_model(self.cfg)
    183         self.model.eval()
    184         if len(cfg.DATASETS.TEST):

/usr/local/lib/python3.6/dist-packages/detectron2/modeling/meta_arch/build.py in build_model(cfg)
     19     """
     20     meta_arch = cfg.MODEL.META_ARCHITECTURE
---> 21     model = META_ARCH_REGISTRY.get(meta_arch)(cfg)
     22     model.to(torch.device(cfg.MODEL.DEVICE))
     23     return model

/usr/local/lib/python3.6/dist-packages/detectron2/config/config.py in wrapped(self, *args, **kwargs)
    145 
    146         if _called_with_cfg(*args, **kwargs):
--> 147             explicit_args = _get_args_from_config(from_config_func, *args, **kwargs)
    148             init_func(self, **explicit_args)
    149         else:

/usr/local/lib/python3.6/dist-packages/detectron2/config/config.py in _get_args_from_config(from_config_func, *args, **kwargs)
    178             if name not in supported_arg_names:
    179                 extra_kwargs[name] = kwargs.pop(name)
--> 180         ret = from_config_func(*args, **kwargs)
    181         # forward the other arguments to __init__
    182         ret.update(extra_kwargs)

/usr/local/lib/python3.6/dist-packages/detectron2/modeling/meta_arch/rcnn.py in from_config(cls, cfg)
     77             "backbone": backbone,
     78             "proposal_generator": build_proposal_generator(cfg, backbone.output_shape()),
---> 79             "roi_heads": build_roi_heads(cfg, backbone.output_shape()),
     80             "input_format": cfg.INPUT.FORMAT,
     81             "vis_period": cfg.VIS_PERIOD,

/usr/local/lib/python3.6/dist-packages/detectron2/modeling/roi_heads/roi_heads.py in build_roi_heads(cfg, input_shape)
     41     """
     42     name = cfg.MODEL.ROI_HEADS.NAME
---> 43     return ROI_HEADS_REGISTRY.get(name)(cfg, input_shape)
     44 
     45 

/usr/local/lib/python3.6/dist-packages/detectron2/config/config.py in wrapped(self, *args, **kwargs)
    145 
    146         if _called_with_cfg(*args, **kwargs):
--> 147             explicit_args = _get_args_from_config(from_config_func, *args, **kwargs)
    148             init_func(self, **explicit_args)
    149         else:

/usr/local/lib/python3.6/dist-packages/detectron2/config/config.py in _get_args_from_config(from_config_func, *args, **kwargs)
    178             if name not in supported_arg_names:
    179                 extra_kwargs[name] = kwargs.pop(name)
--> 180         ret = from_config_func(*args, **kwargs)
    181         # forward the other arguments to __init__
    182         ret.update(extra_kwargs)

/usr/local/lib/python3.6/dist-packages/detectron2/modeling/roi_heads/roi_heads.py in from_config(cls, cfg, input_shape)
    553             ret.update(cls._init_box_head(cfg, input_shape))
    554         if inspect.ismethod(cls._init_mask_head):
--> 555             ret.update(cls._init_mask_head(cfg, input_shape))
    556         if inspect.ismethod(cls._init_keypoint_head):
    557             ret.update(cls._init_keypoint_head(cfg, input_shape))

/usr/local/lib/python3.6/dist-packages/detectron2/modeling/roi_heads/roi_heads.py in _init_mask_head(cls, cfg, input_shape)
    614             scales=pooler_scales,
    615             sampling_ratio=sampling_ratio,
--> 616             pooler_type=pooler_type,
    617         )
    618         ret["mask_head"] = build_mask_head(

/usr/local/lib/python3.6/dist-packages/detectron2/modeling/poolers.py in __init__(self, output_size, scales, sampling_ratio, pooler_type, canonical_box_size, canonical_level)
    169             )
    170         else:
--> 171             raise ValueError("Unknown pooler type: {}".format(pooler_type))
    172 
    173         # Map scale (defined as 1 / stride) to its feature map level under the

ValueError: Unknown pooler type: 

Step 5: Install NMR, detectron2, FrankMocap

Should change to:
$# Install detectron2
$!mkdir -p external
$!git clone --branch v0.2.1 https://github.com/facebookresearch/detectron2.git external/detectron2
$!python -m pip install -e external/detectron2

@jasonyzhang
Copy link
Contributor

Hi,

You can either install Pytorch 1.5/1.6 and use the fix for NMR in #3 or clone v0.2.1 of detectron2 which still has Pytorch 1.4 support. I've added the latter to the colab notebook, so re-running it from the top should work.

Best,
Jason

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants