EdjeElectronics / TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10

How to train a TensorFlow Object Detection Classifier for multiple object detection on Windows
Apache License 2.0
2.92k stars 1.3k forks source link

Incompatible argument to the tf.image.resize_images function within preprocessor.py? #258

Open monocongo opened 5 years ago

monocongo commented 5 years ago

I am now to the point where I am running the training of the model on my dataset of images. In order to get this to run I first needed to overcome an error with the file models\research\object_detection\core\preprocessor.py. In that file there is usage of the function tf.image.resize_images which uses the argument preserve_aspect_ratio, and this argument appears to be valid in the latest TensorFlow API. However I needed to comment out this argument in the above mentioned preprocessor.py file in order to get the training to run (see error below). Can anyone comment as to whether or not this indicates that I've somehow managed to install the wrong version of TensorFlow, pulled in an older/incomapatible version of the faster_rcnn_inception_v2_coco_2018_01_28 model, or some other configuration misstep?

Thanks in advance for any suggestions, and a HUGE thanks to @EdjeElectronics for making this tutorial available. Excellent work, kudos!


$ python train.py --logtostderr --train_dir=training/ --pipeline_config_path=tra ining/faster_rcnn_inception_v2_pets.config
WARNING:tensorflow:From C:\home\miniconda\envs\tensorflow_cpu\lib\site-packages\tensorflow\python\platform\app.py:125: main (from __main__) is deprecated and will be removed in a future version.
Instructions for updating:
Use object_detection/model_main.py.
WARNING:tensorflow:From C:\home\git\object_detection_tensorflow\TensorFlow\models\research\object_detection\legacy\trainer.py:266: create_global_step (from tensorflow.contrib.framework.python.ops.variables) is deprecated and will be removed  in a future version.
Instructions for updating:
Please switch to tf.train.create_global_step
WARNING:tensorflow:num_readers has been reduced to 1 to match input file shards. Traceback (most recent call last):
File "train.py", line 184, in tf.app.run()
File "C:\home\miniconda\envs\tensorflow_cpu\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run _sys.exit(main(argv))
File "C:\home\miniconda\envs\tensorflow_cpu\lib\site-packages\tensorflow\python\util\deprecation.py", line 250, in new_func
return func(*args, **kwargs)
File "train.py", line 180, in main graph_hook_fn=graph_rewriter_fn)
File  "C:\home\git\object_detection_tensorflow\TensorFlow\models\research\object_detection\legacy\trainer.py", line 291, in train
clones = model_deploy.create_clones(deploy_config, model_fn, [input_queue])
File "C:\home\git\object_detection_tensorflow\TensorFlow\models\research\slim\deployment\model_deploy.py", line 193, in create_clones
outputs = model_fn(*args, **kwargs)
File "C:\home\git\object_detection_tensorflow\TensorFlow\models\research\object_detection\legacy\trainer.py", line 186, in _create_losses
resized_image, true_image_shape = detection_model.preprocess(image)
File "C:\home\git\object_detection_tensorflow\TensorFlow\models\research\object_detection\meta_architectures\faster_rcnn_meta_arch.py", line 543, in preproces s
parallel_iterations=self._parallel_iterations)
File "C:\home\git\object_detection_tensorflow\TensorFlow\models\research\object_detection\utils\shape_utils.py", line 237, in static_or_dynamic_map_fn
outputs = [fn(arg) for arg in tf.unstack(elems)]
File "C:\home\git\object_detection_tensorflow\TensorFlow\models\research\object_detection\utils\shape_utils.py", line 237, in 
outputs = [fn(arg) for arg in tf.unstack(elems)]
File "C:\home\git\object_detection_tensorflow\TensorFlow\models\research\object_detection\core\preprocessor.py", line 2264, in resize_to_range
lambda: _resize_portrait_image(image))
File "C:\home\miniconda\envs\tensorflow_cpu\lib\site-packages\tensorflow\python\util\deprecation.py", line 432, in new_func
return func(*args, **kwargs)
File "C:\home\miniconda\envs\tensorflow_cpu\lib\site-packages\tensorflow\python\ops\control_flow_ops.py", line 2040, in cond
orig_res_t, res_t = context_t.BuildCondBranch(true_fn)
File "C:\home\miniconda\envs\tensorflow_cpu\lib\site-packages\tensorflow\python\ops\control_flow_ops.py", line 1890, in BuildCondBranch
original_result = fn()
File "C:\home\git\object_detection_tensorflow\TensorFlow\models\research\object_detection\core\preprocessor.py", line 2263, in lambda:
_resize_landscape_image(image),
File "C:\home\git\object_detection_tensorflow\TensorFlow\models\research\object_detection\core\preprocessor.py", line 2245, in _resize_landscape_image
align_corners=align_corners, preserve_aspect_ratio=True)
TypeError: resize_images() got an unexpected keyword argument 'preserve_aspect_ratio'
monocongo commented 5 years ago

Possible duplicate of issue #256

iqrammm commented 5 years ago

I followed the #256 but cannot seem to find the coreprocessor.py, any solution? do kindly advice on this matter.