Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow error: TypeError: __init__() got an unexpected keyword argument 'dct_method' [closed]

When running the Tensorflow Object Detection API with the current release of Tensorflow-Gpu (1.5), the following error gets thrown, when trying to train on a custom set of images.

INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:Scale of 0 disables regularizer.
WARNING:tensorflow:From C:\tensorflow1\models\research\object_detection\trainer.py:228: 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
Traceback (most recent call last):
  File "train.py", line 167, in <module>
    tf.app.run()
  File "C:\Users\Vic-10-3\AppData\Local\Continuum\anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\platform\app.py", line 124, in run
    _sys.exit(main(argv))
  File "train.py", line 163, in main
    worker_job_name, is_chief, FLAGS.train_dir)
  File "C:\tensorflow1\models\research\object_detection\trainer.py", line 235, in train
    train_config.prefetch_queue_capacity, data_augmentation_options)
  File "C:\tensorflow1\models\research\object_detection\trainer.py", line 59, in create_input_queue
    tensor_dict = create_tensor_dict_fn()
  File "train.py", line 120, in get_next
    dataset_builder.build(config)).get_next()
  File "C:\tensorflow1\models\research\object_detection\builders\dataset_builder.py", line 138, in build
    label_map_proto_file=label_map_proto_file)
  File "C:\tensorflow1\models\research\object_detection\data_decoders\tf_example_decoder.py", line 110, in __init__
    dct_method=dct_method),
TypeError: __init__() got an unexpected keyword argument 'dct_method'

The expected behavior would be to run the actual training, but apparently something became incompatible with the latest release.

Instruction for reproducing the error: Follow the tutorial and train on a custom dataset.

like image 838
Traviccc Avatar asked Feb 22 '18 06:02

Traviccc


1 Answers

This error is due to the incompatibility of file tf_example_decoder.py with the Tensorflow installed.

In file models/research/object_detection/data_decoders/tf_example_decoder.py:

line 28:

slim_example_decoder = tf.contrib.slim.tfexample_decoder

line 104:

self.items_to_handlers = {
    fields.InputDataFields.image:
        slim_example_decoder.Image(
            image_key='image/encoded',
            format_key='image/format',
            channels=3,
            dct_method=dct_method),....
            .....
            ....
            ..
            .
            }

slim_example_decoder.Image is tf.contrib.slim.tfexample_decoder.Image

In Tensorflow 1.5 source code tf.contrib.slim.tfexample_decoder.Image doesn't have dct_method argument. Therefore when dct_method argument is passed it throws an error.

A simple hack would be to not pass this argument. So edit tf_example_decoder.py line 110 to remove dct_method=dct_method. I tried this and it worked and didn't had any effect on training.

like image 169
user2358715 Avatar answered Nov 17 '22 16:11

user2358715