I’m trying to fine-tune a MobileNetv2 model from a checkpoint (https://github.com/tensorflow/models/tree/master/research/slim/nets/mobilenet, see “float_v2_1.4_224” under “Mobilenet V2 Imagenet Checkpoints”) for the task of Image Segmentation with Deeplabv3. I’ve followed the approach described on the deeplab repo by replacing the pascal VOC dataset with my own, made up of images sized 224×224 (same size as the images used to train that checkpoint) and then used this script as reference for which flags to set for training mobilenetv2.(https://github.com/tensorflow/models/blob/master/research/deeplab/local_test_mobilenetv2.sh)
This is the command I’m using:
python deeplab/train.py
--logtostderr
--train_split="train"
--model_variant="mobilenet_v2"
--output_stride=16
--train_crop_size="225,225" #images are 224x224, so it's set to this as per the tensorflow/research/deeplab FAQs
--train_batch_size=4
--training_number_of_steps=100
--fine_tune_batch_norm=true
--dataset="custom" #defined properly as its own dataset
--tf_initial_checkpoint="./deeplab/data_resized/initial_checkpoint/mobilenet_v2_1.4_224.ckpt"
--train_logdir="./deeplab/data_resized/checkpoint"
--dataset_dir="./deeplab/data_resized/ltfrecord"
But I keep on getting the following error:
Traceback (most recent call last):
File "deeplab/train.py", line 464, in <module>
tf.app.run()
File "C:UsersLuca.pyenvpyenv-winversions3.7.6libsite-packagestensorflow_corepythonplatformapp.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "C:UsersLuca.pyenvpyenv-winversions3.7.6libsite-packagesabslapp.py", line 308, in run
_run_main(main, args)
File "C:UsersLuca.pyenvpyenv-winversions3.7.6libsite-packagesabslapp.py", line 254, in _run_main
sys.exit(main(argv))
File "deeplab/train.py", line 444, in main
ignore_missing_vars=True)
File "C:UsersLucaDocumentsmarathonfacade_mltraining_gitclonemodels-masterresearchdeeplabutilstrain_utils.py", line 221, in get_model_init_fn
ignore_missing_vars=ignore_missing_vars)
File "C:UsersLuca.pyenvpyenv-winversions3.7.6libsite-packagestensorflow_corecontribframeworkpythonopsvariables.py", line 690, in assign_from_checkpoint
(ckpt_name, str(ckpt_value.shape), str(var.get_shape())))
ValueError: Total size of new array must be unchanged for MobilenetV2/Conv/weights lh_shape: [(3, 3, 3, 48)], rh_shape: [(3, 3, 3, 32)]
I’ve tried changing other configuration values such as “initialize_last_layer” to false and “last_layers_contain_logits_only” to false but this has not helped.
Thank you for your help.