open-mmlab/mmsegmentation

[KeyError: 'PALETTE'] while loading model after retraining

Open

#2.039 geöffnet am 7. Sept. 2022

Auf GitHub ansehen
 (5 Kommentare) (0 Reaktionen) (1 zugewiesene Person)Python (2.386 Forks)batch import
help wanted

Repository-Metriken

Stars
 (6.867 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Hi, I am getting following error while loading the model after retraining on my custom dataet.

mmseg/apis/inference.py:36, in init_segmentor(config, checkpoint, device)
     34     checkpoint = load_checkpoint(model, checkpoint, map_location='cpu')
     35     model.CLASSES = checkpoint['meta']['CLASSES']
---> 36     model.PALETTE = checkpoint['meta']['PALETTE']
     37 model.cfg = config  # save the config in the model for convenience
     38 model.to(device)

KeyError: 'PALETTE'

I checked the keys in my saved model which are these

dict_keys(['epoch', 'iter', 'mmcv_version', 'time', 'CLASSES'])

Did training with following code

# Build the detector
model = build_segmentor(cfg.model)
# Add an attribute for visualization convenience
model.CLASSES = datasets[0].CLASSES
model.PALETTE = datasets[0].PALETTE

# Create work_dir
mmcv.mkdir_or_exist(osp.abspath(cfg.work_dir))
train_segmentor(model, datasets, cfg, distributed=False, validate=True, 
                meta=dict())

Contributor Guide