Skip to content

Commit f8fe731

Browse files
committed
add meta
1 parent cabd80f commit f8fe731

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

tools/test.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,16 @@ def main():
122122
if fp16_cfg is not None:
123123
wrap_fp16_model(model)
124124
checkpoint = load_checkpoint(model, args.checkpoint, map_location='cpu')
125-
model.CLASSES = checkpoint['meta']['CLASSES']
126-
model.PALETTE = checkpoint['meta']['PALETTE']
125+
if 'CLASSES' in checkpoint.get('meta', {}):
126+
model.CLASSES = checkpoint['meta']['CLASSES']
127+
else:
128+
print('"CLASSES" not found in meta, use dataset.CLASSES instead')
129+
model.CLASSES = dataset.CLASSES
130+
if 'PALETTE' in checkpoint.get('meta', {}):
131+
model.PALETTE = checkpoint['meta']['PALETTE']
132+
else:
133+
print('"PALETTE" not found in meta, use dataset.PALETTE instead')
134+
model.PALETTE = dataset.PALETTE
127135

128136
efficient_test = False
129137
if args.eval_options is not None:

tools/train.py

+2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ def main():
149149
PALETTE=datasets[0].PALETTE)
150150
# add an attribute for visualization convenience
151151
model.CLASSES = datasets[0].CLASSES
152+
# passing checkpoint meta for saving best checkpoint
153+
meta.update(cfg.checkpoint_config.meta)
152154
train_segmentor(
153155
model,
154156
datasets,

0 commit comments

Comments
 (0)