dpressel / rude-carnie

Age detection in Tensorflow
937 stars 342 forks source link

Pre-trained gender model produces error, while pre-trained age model works #84

Closed Cloudmersive closed 6 years ago

Cloudmersive commented 6 years ago

Here is what happens when running the pre-trained age model:

**$ python guess.py --model_type inception --model_dir /home/adm101/rude-carnie/cmx/22801 --filename ./cmx/woman-car.jpg**
2018-07-22 08:33:33.473733: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Executing on /cpu:0
selected (fine-tuning) inception model
/home/adm101/rude-carnie/cmx/22801/checkpoint-14999
['./cmx/woman-car.jpg']
Running file ./cmx/woman-car.jpg
Running multi-cropped image
Guess @ 1 (25, 32), prob = 0.59
Guess @ 2 (48, 53), prob = 0.13

Here is what happens when running the pre-trained gender model:

**$ python guess.py --model_type inception --model_dir /home/adm101/rude-carnie/cmx/21936 --filename ./cmx/woman-car.jpg**
2018-07-22 08:31:54.820247: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Executing on /cpu:0
selected (fine-tuning) inception model
/home/adm101/rude-carnie/cmx/21936/checkpoint-14999
Traceback (most recent call last):
  File "guess.py", line 207, in <module>
    tf.app.run()
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "guess.py", line 166, in main
    saver.restore(sess, model_checkpoint_path)
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1752, in restore
    {self.saver_def.filename_tensor_name: save_path})
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 900, in run
    run_metadata_ptr)
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1135, in _run
    feed_dict_tensor, options, run_metadata)
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1316, in _do_run
    run_metadata)
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1335, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [8] rhs shape= [2]
         [[Node: save/Assign_376 = Assign[T=DT_FLOAT, _class=["loc:@output/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](output/biases, save/RestoreV2:376)]]

Caused by op u'save/Assign_376', defined at:
  File "guess.py", line 207, in <module>
    tf.app.run()
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "guess.py", line 165, in main
    saver = tf.train.Saver()
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1284, in __init__
    self.build()
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1296, in build
    self._build(self._filename, build_save=True, build_restore=True)
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1333, in _build
    build_save=build_save, build_restore=build_restore)
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 781, in _build_internal
    restore_sequentially, reshape)
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 422, in _AddRestoreOps
    assign_ops.append(saveable.restore(saveable_tensors, shapes))
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 113, in restore
    self.op.get_shape().is_fully_defined())
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/ops/state_ops.py", line 219, in assign
    validate_shape=validate_shape)
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/ops/gen_state_ops.py", line 60, in assign
    use_locking=use_locking, name=name)
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3414, in create_op
    op_def=op_def)
  File "/home/adm101/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1740, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [8] rhs shape= [2]
         [[Node: save/Assign_376 = Assign[T=DT_FLOAT, _class=["loc:@output/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](output/biases, save/RestoreV2:376)]]

Any idea why the gender one is not working?

dpressel commented 6 years ago

Yes, it doesnt look like you are passing --class_type gender. Please see the README.md for more info