yekeren / ADVISE-Image_ads_understanding

ADVISE model for the Automatic Understanding of Visual Advertisements challenge. Please refer to our ECCV paper "ADVISE: Symbolism and External Knowledge for Decoding Advertisements".
https://evalai.cloudcv.org/web/challenges/challenge-page/86/overview
26 stars 12 forks source link

arg_scope #3

Open joey1993 opened 5 years ago

joey1993 commented 5 years ago

I ran into an error when executing "sh train.sh" for a toy model. Before this step, I generated all the features. Any idea on debugging this?

Traceback (most recent call last):
  File "train/eval.py", line 265, in <module>
    app.run()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "train/eval.py", line 178, in main
    predictions = model.build_evaluation_graph(examples)
  File "/workspace/ADVISE/models/advise_model.py", line 313, in build_evaluation_graph
    examples['img_features'], examples['roi_features'])
  File "/workspace/ADVISE/models/advise_model.py", line 92, in encode_image
    roi_features_reshaped, model_proto.image_encoder, is_training)
  File "/workspace/ADVISE/models/utils.py", line 67, in encode_feature
    with slim.arg_scope(hp):
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 144, in arg_scope
    raise TypeError('list_ops_or_scope must either be a list/tuple or reused '
TypeError: list_ops_or_scope must either be a list/tuple or reused scope (i.e. dict)
Pg-Man commented 5 years ago

Did you fix it ?

yekeren commented 5 years ago

Please check the implementation of https://github.com/tensorflow/models/blob/c92a7e169f03c8672a21e6c2172bc8e5d174115b/research/object_detection/builders/hyperparams_builder.py#L178.

The hyperparameter_builder.build() function now returns a function. However, for the previous OBJECT_DETECTION version, the build function returns a list/tuple (I cannot remember clearly).

Please refer https://github.com/tensorflow/models/blob/c92a7e169f03c8672a21e6c2172bc8e5d174115b/research/object_detection/predictors/convolutional_box_predictor.py#L145 to use. That is, call the returned function.

yekeren commented 5 years ago

I ran into an error when executing "sh train.sh" for a toy model. Before this step, I generated all the features. Any idea on debugging this?

Traceback (most recent call last):
  File "train/eval.py", line 265, in <module>
    app.run()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "train/eval.py", line 178, in main
    predictions = model.build_evaluation_graph(examples)
  File "/workspace/ADVISE/models/advise_model.py", line 313, in build_evaluation_graph
    examples['img_features'], examples['roi_features'])
  File "/workspace/ADVISE/models/advise_model.py", line 92, in encode_image
    roi_features_reshaped, model_proto.image_encoder, is_training)
  File "/workspace/ADVISE/models/utils.py", line 67, in encode_feature
    with slim.arg_scope(hp):
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 144, in arg_scope
    raise TypeError('list_ops_or_scope must either be a list/tuple or reused '
TypeError: list_ops_or_scope must either be a list/tuple or reused scope (i.e. dict)

Please let me know if the solution works.

yekeren commented 5 years ago

Did you fix it ?

Please see my suggestions.

Pg-Man commented 5 years ago

When my code changed to this,

`if not isinstance(config, utils_pb2.FCEncoder): raise ValueError('The config has to be an instance of FCEncoder.')

hp = hyperparams_builder.build(config.fc_hyperparams, is_training=is_training)

node = features node = slim.dropout(node, config.input_dropout_keep_prob, is_training=is_training) with slim.arg_scope(hp()): node = slim.fully_connected(node, config.num_outputs, scope=config.scope, reuse=reuse) node = slim.dropout(node, config.output_dropout_keep_prob, is_training=is_training)`

it didn't report the previous error, but a new error occurred.

File "train/eval.py", line 266, in <module> app.run() File "/home/ypj/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "train/eval.py", line 179, in main predictions = model.build_evaluation_graph(examples) File "/home/ypj/文档/ADVISE/ADVISE/models/vse_model.py", line 120, in build_evaluation_graph statement_strings_reshaped, statement_lengths_reshaped) File "/home/ypj/文档/ADVISE/ADVISE/text_encoders/bow_encoder.py", line 110, in encode self._set_init_fn(embedding_weights, model_proto.init_emb_matrix_path) File "/home/ypj/文档/ADVISE/ADVISE/text_encoders/bow_encoder.py", line 46, in _set_init_fn embedding_weights.op.name: word2vec} ) File "/home/ypj/.local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 508, in assign_from_values feed_dict[placeholder_value] = var_value.reshape(var.get_shape()) ValueError: cannot reshape array of size 5066200 into shape (25333,200)

yekeren commented 5 years ago

Your vocabulary size is wrong.

On Sat, Aug 3, 2019 at 6:46 AM Pg-Man notifications@github.com wrote:

When my code changed to this,

`if not isinstance(config, utils_pb2.FCEncoder): raise ValueError('The config has to be an instance of FCEncoder.')

hp = hyperparams_builder.build(config.fc_hyperparams, is_training=is_training)

node = features node = slim.dropout(node, config.input_dropout_keep_prob, is_training=is_training) with slim.arg_scope(hp()): node = slim.fully_connected(node, config.num_outputs, scope=config.scope, reuse=reuse) node = slim.dropout(node, config.output_dropout_keep_prob, is_training=is_training)`

it didn't report the previous error, but a new error occurred.

File "train/eval.py", line 266, in app.run() File "/home/ypj/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "train/eval.py", line 179, in main predictions = model.build_evaluation_graph(examples) File "/home/ypj/文档/ADVISE/ADVISE/models/vse_model.py", line 120, in build_evaluation_graph statement_strings_reshaped, statement_lengths_reshaped) File "/home/ypj/文档/ADVISE/ADVISE/text_encoders/bow_encoder.py", line 110, in encode self._set_init_fn(embedding_weights, model_proto.init_emb_matrix_path) File "/home/ypj/文档/ADVISE/ADVISE/text_encoders/bow_encoder.py", line 46, in _set_init_fn embedding_weights.op.name: word2vec} ) File "/home/ypj/.local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 508, in assign_from_values feed_dict[placeholder_value] = var_value.reshape(var.get_shape()) ValueError: cannot reshape array of size 5066200 into shape (25333,200)

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/yekeren/ADVISE-Image_ads_understanding/issues/3?email_source=notifications&email_token=AA6CPAIVYIK7GOLWN6BKQ33QCUER7A5CNFSM4ICTNBH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3PG7KY#issuecomment-517894059, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6CPAPHJ5SFGJNT3FWG3G3QCUER7ANCNFSM4ICTNBHQ .

-- Thanks, best regards.

Keren

Pg-Man commented 5 years ago

Your vocabulary size is wrong. On Sat, Aug 3, 2019 at 6:46 AM Pg-Man @.***> wrote: When my code changed to this, if not isinstance(config, utils_pb2.FCEncoder): raise ValueError('The config has to be an instance of FCEncoder.') hp = hyperparams_builder.build(config.fc_hyperparams, is_training=is_training) node = features node = slim.dropout(node, config.input_dropout_keep_prob, is_training=is_training) with slim.arg_scope(hp()): node = slim.fully_connected(node, config.num_outputs, scope=config.scope, reuse=reuse) node = slim.dropout(node, config.output_dropout_keep_prob, is_training=is_training) it didn't report the previous error, but a new error occurred. File "train/eval.py", line 266, in app.run() File "/home/ypj/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "train/eval.py", line 179, in main predictions = model.build_evaluation_graph(examples) File "/home/ypj/文档/ADVISE/ADVISE/models/vse_model.py", line 120, in build_evaluation_graph statement_strings_reshaped, statement_lengths_reshaped) File "/home/ypj/文档/ADVISE/ADVISE/text_encoders/bow_encoder.py", line 110, in encode self._set_init_fn(embedding_weights, model_proto.init_emb_matrix_path) File "/home/ypj/文档/ADVISE/ADVISE/text_encoders/bow_encoder.py", line 46, in _set_init_fn embedding_weights.op.name: word2vec} ) File "/home/ypj/.local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 508, in assign_from_values feed_dict[placeholder_value] = var_value.reshape(var.get_shape()) ValueError: cannot reshape array of size 5066200 into shape (25333,200) — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#3?email_source=notifications&email_token=AA6CPAIVYIK7GOLWN6BKQ33QCUER7A5CNFSM4ICTNBH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3PG7KY#issuecomment-517894059>, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6CPAPHJ5SFGJNT3FWG3G3QCUER7ANCNFSM4ICTNBHQ . -- Thanks, best regards. Keren

Dear Sir, I am very happy to hear from you that I am vocabulary size set incorrectly.

In fact, In fact, I also found the problem of vocabulary size because 25333*200 =5066600>5066200. Since I am learning the way to image recognition, it is difficult to find out which file to change the relevant code in. After I cloned your code from github, I didn't change them, so I don't know why there was this error. Sincerely like you for help, please tell me which file to modify and how to modify it. Forgive me for your harassment.

Thanks,best regards.

PG-Man

yekeren commented 5 years ago

You could modify https://github.com/yekeren/ADVISE-Image_ads_understanding/blob/2ea5e1405b1ab178b95f9c2cd9158b16847ac6a3/configs/advise.baseline.pbtxt#L110 based on your generated files in the output directory.

On Sun, Aug 4, 2019 at 3:07 PM Pg-Man notifications@github.com wrote:

Your vocabulary size is wrong. On Sat, Aug 3, 2019 at 6:46 AM Pg-Man @.***> wrote: When my code changed to this, if not isinstance(config, utils_pb2.FCEncoder): raise ValueError('The config has to be an instance of FCEncoder.') hp = hyperparams_builder.build(config.fc_hyperparams, is_training=is_training) node = features node = slim.dropout(node, config.input_dropout_keep_prob, is_training=is_training) with slim.arg_scope(hp()): node = slim.fully_connected(node, config.num_outputs, scope=config.scope, reuse=reuse) node = slim.dropout(node, config.output_dropout_keep_prob, is_training=is_training) it didn't report the previous error, but a new error occurred. File "train/eval.py", line 266, in app.run() File "/home/ypj/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "train/eval.py", line 179, in main predictions = model.build_evaluation_graph(examples) File "/home/ypj/文档/ADVISE/ADVISE/models/vse_model.py", line 120, in build_evaluation_graph statement_strings_reshaped, statement_lengths_reshaped) File "/home/ypj/文档/ADVISE/ADVISE/text_encoders/bow_encoder.py", line 110, in encode self._set_init_fn(embedding_weights, model_proto.init_emb_matrix_path) File "/home/ypj/文档/ADVISE/ADVISE/text_encoders/bow_encoder.py", line 46, in _set_init_fn embedding_weights.op.name: word2vec} ) File "/home/ypj/.local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 508, in assign_from_values feed_dict[placeholder_value] = var_value.reshape(var.get_shape()) ValueError: cannot reshape array of size 5066200 into shape (25333,200) — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#3 https://github.com/yekeren/ADVISE-Image_ads_understanding/issues/3?email_source=notifications&email_token=AA6CPAIVYIK7GOLWN6BKQ33QCUER7A5CNFSM4ICTNBH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3PG7KY#issuecomment-517894059>, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6CPAPHJ5SFGJNT3FWG3G3QCUER7ANCNFSM4ICTNBHQ . -- Thanks, best regards. Keren

Dear Sir, I am very happy to hear from you that I am vocabulary size set incorrectly.

In fact, In fact, I also found the problem of vocabulary size because 25333*200 =5066600>5066200. Since I am learning the way to image recognition, it is difficult to find out which file to change the relevant code in. After I cloned your code from github, I didn't change them, so I don't know why there was this error. Sincerely like you for help, please tell me which file to modify and how to modify it. Forgive me for your harassment.

Thanks,best regards.

PG-Man

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/yekeren/ADVISE-Image_ads_understanding/issues/3?email_source=notifications&email_token=AA6CPAILSLAPZYQFC4ZDAV3QC3IB3A5CNFSM4ICTNBH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3QBO5Q#issuecomment-518002550, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6CPAOZNPVZV2FF2XNGVFDQC3IB3ANCNFSM4ICTNBHQ .

-- Thanks, best regards.

Keren