Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Fix preprocess_model_config for CIFAR dataset #1659

Merged
merged 2 commits into from
Jan 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions mmdeploy/codebase/mmcls/deploy/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,27 @@ def process_model_config(model_cfg: Config,
if cfg.test_pipeline[0]['type'] == 'LoadImageFromFile':
cfg.test_pipeline.pop(0)
# check whether input_shape is valid
if 'CIFAR' in cfg.dataset_type:
# cifar dataset needs input image (32, 32)
cfg.test_pipeline.insert(-1, dict(type='Resize', scale=(32, 32)))
if input_shape is not None:
if 'crop_size' in cfg.test_pipeline[2]:
crop_size = cfg.test_pipeline[2]['crop_size']
if tuple(input_shape) != (crop_size, crop_size):
logger = get_root_logger()
logger.warning(
f'`input shape` should be equal to `crop_size`: {crop_size},\
but given: {input_shape}')
for pipeline_component in cfg.test_pipeline:
if 'Crop' in pipeline_component['type']:
if 'crop_size' in pipeline_component:
crop_size = pipeline_component['crop_size']
if tuple(input_shape) != (crop_size, crop_size):
logger = get_root_logger()
logger.warning(
f'`input shape` should be equal to `crop_size`: {crop_size},\
but given: {input_shape}')
if 'Resize' in pipeline_component['type']:
if 'scale' in pipeline_component:
size = pipeline_component['scale']
if tuple(input_shape) != size:
logger = get_root_logger()
logger.warning(
f'`input shape` should be equal to `shape`: {size},\
but given: {input_shape}')
return cfg


Expand Down