[Fix] Fix no revert_sync_batchnorm in image_demo of master branch (#2489)

Fix: https://github.com/open-mmlab/mmsegmentation/issues/2478
This commit is contained in:
MengzhangLI 2023-01-16 15:40:29 +08:00 committed by GitHub
parent ed83982876
commit ba7608cefe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,8 @@
# Copyright (c) OpenMMLab. All rights reserved.
from argparse import ArgumentParser
from mmcv.cnn.utils.sync_bn import revert_sync_batchnorm
from mmseg.apis import inference_segmentor, init_segmentor, show_result_pyplot
from mmseg.core.evaluation import get_palette
@ -26,6 +28,8 @@ def main():
# build the model from a config file and a checkpoint file
model = init_segmentor(args.config, args.checkpoint, device=args.device)
if args.device == 'cpu':
model = revert_sync_batchnorm(model)
# test a single image
result = inference_segmentor(model, args.img)
# show the results