dvlab-research/PanopticFCN

Inference on Cityscapes

Closed this issue · 2 comments

Hello, I trained a model on Cityscapes dataset using PanopticFCN cityscapes implementation. Now I want to use the demo.py from detectron2 to see the result of my trained model on a new image. I've already imported panoptic fcn in the demo.py and also added the panoptic fcn configuration in init.py.

from panopticfcn.config import add_panopticfcn_config  # noqa
add_panopticfcn_config(cfg)
_PROJECTS = {
    "point_rend": "PointRend",
    "deeplab": "DeepLab",
    "panoptic_deeplab": "Panoptic-DeepLab",
    "panopticfcn": "PanopticFCN",
}

But when I try to use the demo.py like this:

python demo/demo.py --config-file projects/PanopticFCN/configs/cityscapes/PanopticFCN-R50-cityscapes.yaml
--input projects/PanopticFCN/images/image1.png
--output projects/PanopticFCN/results
--opts MODEL.WEIGHTS projects/PanopticFCN/model/model_final.pth

I've got the following error. What do I still need to do, to be able to run the demo.py?

File "demo/demo.py", line 100, in
cfg = setup_cfg(args)
File "demo/demo.py", line 29, in setup_cfg
cfg.merge_from_file(args.config_file)
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/config.py", line 69, in merge_from_file
self.merge_from_other_cfg(loaded_cfg)
File "/usr/local/lib/python3.7/dist-packages/fvcore/common/config.py", line 132, in merge_from_other_cfg
return super().merge_from_other_cfg(cfg_other)
File "/usr/local/lib/python3.7/dist-packages/yacs/config.py", line 217, in merge_from_other_cfg
_merge_a_into_b(cfg_other, self, self, [])
File "/usr/local/lib/python3.7/dist-packages/yacs/config.py", line 478, in _merge_a_into_b
_merge_a_into_b(v, b[k], root, key_list + [k])
File "/usr/local/lib/python3.7/dist-packages/yacs/config.py", line 491, in _merge_a_into_b
raise KeyError("Non-existent config key: {}".format(full_key))
KeyError: 'Non-existent config key: MODEL.LOSS_WEIGHT'

Hi, after some reruns, now I've got this error.

Traceback (most recent call last):
File "demo/demo.py", line 114, in
predictions, visualized_output = demo.run_on_image(img)
File "/content/drive/MyDrive/Detectron2/detectron2/demo/predictor.py", line 48, in run_on_image
predictions = self.predictor(image)
File "/usr/local/lib/python3.7/dist-packages/detectron2/engine/defaults.py", line 317, in call
predictions = self.model([inputs])[0]
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/content/drive/MyDrive/Detectron2/detectron2/demo/panopticfcn/panoptic_seg.py", line 109, in forward
return self.inference(batched_inputs, images, pred_centers, pred_regions, pred_weights, encode_feat)
File "/usr/local/lib/python3.7/dist-packages/torch/autograd/grad_mode.py", line 28, in decorate_context
return func(*args, **kwargs)
File "/content/drive/MyDrive/Detectron2/detectron2/demo/panopticfcn/panoptic_seg.py", line 417, in inference
self.panoptic_inst_thrs)
File "/usr/local/lib/python3.7/dist-packages/torch/autograd/grad_mode.py", line 28, in decorate_context
return func(*args, **kwargs)
File "/content/drive/MyDrive/Detectron2/detectron2/demo/panopticfcn/panoptic_seg.py", line 538, in combine_thing_and_stuff
category_id = self.meta.thing_train_id2contiguous_id[thing_category_id]
File "/usr/local/lib/python3.7/dist-packages/detectron2/data/catalog.py", line 132, in getattr
f"Attribute '{key}' does not exist in the metadata of dataset '{self.name}': "

AttributeError: Attribute 'thing_train_id2contiguous_id' does not exist in the metadata of dataset 'cityscapes_fine_panoptic_train_separated': metadata is empty.

@razvanbarbura I am having the same problem, could you tell me what was the solution at the end ?