diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/image_utils.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/image_utils.cc index 93190b1b0cc..6c40b78751b 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/image_utils.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/image_utils.cc @@ -214,7 +214,12 @@ static Status JpegReadScanlines(jpeg_decompress_struct *const cinfo, int max_sca std::vector scanline(scanline_size); JSAMPLE *scanline_ptr = &scanline[0]; while (cinfo->output_scanline < static_cast(max_scanlines_to_read)) { - int num_lines_read = jpeg_read_scanlines(cinfo, &scanline_ptr, 1); + int num_lines_read = 0; + try { + num_lines_read = jpeg_read_scanlines(cinfo, &scanline_ptr, 1); + } catch (std::runtime_error &e) { + RETURN_STATUS_UNEXPECTED("jpeg_read_scanlines error."); + } if (cinfo->out_color_space == JCS_CMYK && num_lines_read > 0) { for (int i = 0; i < crop_w; ++i) { int cmyk_pixel = 4 * i + offset; diff --git a/model_zoo/official/cv/nasnet/train.py b/model_zoo/official/cv/nasnet/train.py index 9bc6f53a761..5d2fd67e553 100755 --- a/model_zoo/official/cv/nasnet/train.py +++ b/model_zoo/official/cv/nasnet/train.py @@ -25,6 +25,7 @@ from mindspore.train.callback import ModelCheckpoint, CheckpointConfig, LossMoni from mindspore.train.model import Model from mindspore.train.serialization import load_checkpoint, load_param_into_net from mindspore.common import set_seed +from mindspore.common import dtype as mstype from src.config import nasnet_a_mobile_config_gpu as cfg from src.dataset import create_dataset