LisaAnne / ECCV2016

Code to replicate "Generating Visual Explanations"
Other
47 stars 27 forks source link

AttributeError: Assignment not allowed (no field "layer" in protocol message object). #4

Closed chandru4ni closed 6 years ago

chandru4ni commented 6 years ago

We have downloaded your ECCV2016 code from your git repository and were able to successfully install the code. We were able to run the demo of coco-caption-eval in data/coco/coco-caption-eval successfully. Post that we executed the below steps from examples/ECCV2016 folder and were successful.

Getting Started

Please clone my git repo. My code for generating visual explanations is in /examples/ECCV2016. You will need to use my version of caffe.
Download data using the "download_data.sh" script. This will also preprocess the CUB sentences. All my ECCV 2016 models will be put in "gve_models"

But we got stuck on the building the models using below instructions.

Building the models

All the models are generated using NetSpec. Please build them by running "build_nets.sh". "build_nets.sh" will also generate bash scripts you can use to train models.

We are getting errors, details of which are given below. We are debugging from our end by understanding your implementation. But due to time constraint we wanted to check if you can through some light on these errors which can help us to proceed further.

./build_nets.sh .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] In main and parsing arguments Traceback (most recent call last): File "build_nets.py", line 218, in float(args.lstm_drop)) File "build_nets.py", line 130, in caption_classifier model_train.caption_classifier(save_file_train, accuracy=False, loss=True, embed_drop=embed_drop, lstm_drop=lstm_drop) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/lrcn.py", line 160, in caption_classifier self.write_net(save_file) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/caffe_net.py", line 32, in write_net write_proto = self.n.to_proto() File "../../python/caffe/net_spec.py", line 178, in to_proto top._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 92, in _to_proto return self.fn._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 153, in _to_proto assign_proto(layer, k, v) File "../../python/caffe/net_spec.py", line 74, in assign_proto setattr(proto, name, val) AttributeError: Assignment not allowed (no field "layer" in protocol message object). .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] In main and parsing arguments Traceback (most recent call last): File "build_nets.py", line 203, in build_sentence_generation_model('definition', True, False) File "build_nets.py", line 102, in build_sentence_generation_model model_train.make_sentence_generation_net(save_file_train, accuracy=False, loss=True) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/lrcn.py", line 116, in make_sentence_generation_net self.write_net(save_file) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/caffe_net.py", line 32, in write_net write_proto = self.n.to_proto() File "../../python/caffe/net_spec.py", line 178, in to_proto top._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 92, in _to_proto return self.fn._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 153, in _to_proto assign_proto(layer, k, v) File "../../python/caffe/net_spec.py", line 74, in assign_proto setattr(proto, name, val) AttributeError: Assignment not allowed (no field "layer" in protocol message object). .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] In main and parsing arguments Traceback (most recent call last): File "build_nets.py", line 205, in build_sentence_generation_model('description', False, True) File "build_nets.py", line 102, in build_sentence_generation_model model_train.make_sentence_generation_net(save_file_train, accuracy=False, loss=True) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/lrcn.py", line 116, in make_sentence_generation_net self.write_net(save_file) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/caffe_net.py", line 32, in write_net write_proto = self.n.to_proto() File "../../python/caffe/net_spec.py", line 178, in to_proto top._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 92, in _to_proto return self.fn._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 153, in _to_proto assign_proto(layer, k, v) File "../../python/caffe/net_spec.py", line 74, in assign_proto setattr(proto, name, val) AttributeError: Assignment not allowed (no field "layer" in protocol message object). .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] In main and parsing arguments Traceback (most recent call last): File "build_nets.py", line 207, in build_sentence_generation_model('explanation-label', True, True) File "build_nets.py", line 102, in build_sentence_generation_model model_train.make_sentence_generation_net(save_file_train, accuracy=False, loss=True) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/lrcn.py", line 116, in make_sentence_generation_net self.write_net(save_file) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/caffe_net.py", line 32, in write_net write_proto = self.n.to_proto() File "../../python/caffe/net_spec.py", line 178, in to_proto top._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 92, in _to_proto return self.fn._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 153, in _to_proto assign_proto(layer, k, v) File "../../python/caffe/net_spec.py", line 74, in assign_proto setattr(proto, name, val) AttributeError: Assignment not allowed (no field "layer" in protocol message object). .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] In main and parsing arguments Traceback (most recent call last): File "build_nets.py", line 211, in sentence_generation_reinforce('explanation-dis', orig_proto='prototxt/description_train.prototxt', classify_model=args.classify_model, classify_weights=args.classify_weights, weights=args.weights, class_conditional=False, lw=80) #Loss weight parameter chosen by parameter search File "build_nets.py", line 169, in sentence_generation_reinforce model_train.lrcn_reinforce(save_name=save_file_train, RL_loss=RL_loss, lw=lw) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/reinforce.py", line 218, in lrcn_reinforce self.write_net(save_name) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/caffe_net.py", line 32, in write_net write_proto = self.n.to_proto() File "../../python/caffe/net_spec.py", line 178, in to_proto top._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 92, in _to_proto return self.fn._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 153, in _to_proto assign_proto(layer, k, v) File "../../python/caffe/net_spec.py", line 74, in assign_proto setattr(proto, name, val) AttributeError: Assignment not allowed (no field "layer" in protocol message object). .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] In main and parsing arguments Traceback (most recent call last): File "build_nets.py", line 213, in sentence_generation_reinforce('explanation', orig_proto='prototxt/explanation-label_train.prototxt', classify_model=args.classify_model, classify_weights=args.classify_weights, weights=args.weights, class_conditional=True, lw=110) #Loss weight parameter chocen by parameter search File "build_nets.py", line 169, in sentence_generation_reinforce model_train.lrcn_reinforce(save_name=save_file_train, RL_loss=RL_loss, lw=lw) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/reinforce.py", line 218, in lrcn_reinforce self.write_net(save_name) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/caffe_net.py", line 32, in write_net write_proto = self.n.to_proto() File "../../python/caffe/net_spec.py", line 178, in to_proto top._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 92, in _to_proto return self.fn._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 153, in _to_proto assign_proto(layer, k, v) File "../../python/caffe/net_spec.py", line 74, in assign_proto setattr(proto, name, val) AttributeError: Assignment not allowed (no field "layer" in protocol message object). .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] In main and parsing arguments Traceback (most recent call last): File "build_nets.py", line 209, in build_sentence_generation_deploy() File "build_nets.py", line 72, in build_sentence_generation_deploy model_train.make_sentence_generation_deploy() File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/lrcn.py", line 59, in make_sentence_generation_deploy self.write_net('prototxt/deploy.prototxt') File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/caffe_net.py", line 32, in write_net write_proto = self.n.to_proto() File "../../python/caffe/net_spec.py", line 178, in to_proto top._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 92, in _to_proto return self.fn._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 153, in _to_proto assign_proto(layer, k, v) File "../../python/caffe/net_spec.py", line 64, in assign_proto proto_item = getattr(proto, name).add() AttributeError: 'LayerParameter' object has no attribute 'shape'

LisaAnne commented 6 years ago

Hi --

Did you recompile with my Caffe?

On Mon, Feb 19, 2018 at 4:33 AM, chandru4ni notifications@github.com wrote:

We have downloaded your ECCV2016 code from your git repository and were able to successfully install the code. We were able to run the demo of coco-caption-eval in data/coco/coco-caption-eval successfully. Post that we executed the below steps from examples/ECCV2016 folder and were successful.

Getting Started

Please clone my git repo. My code for generating visual explanations is in /examples/ECCV2016. You will need to use my version of caffe. Download data using the "download_data.sh" script. This will also preprocess the CUB sentences. All my ECCV 2016 models will be put in "gve_models"

But we got stuck on the building the models using below instructions.

Building the models

All the models are generated using NetSpec. Please build them by running "build_nets.sh". "build_nets.sh" will also generate bash scripts you can use to train models.

We are getting errors, details of which are given below. We are debugging from our end by understanding your implementation. But due to time constraint we wanted to check if you can through some light on these errors which can help us to proceed further.

./build_nets.sh .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] In main and parsing arguments Traceback (most recent call last): File "build_nets.py", line 218, in float(args.lstm_drop)) File "build_nets.py", line 130, in caption_classifier model_train.caption_classifier(save_file_train, accuracy=False, loss=True, embed_drop=embed_drop, lstm_drop=lstm_drop) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/lrcn.py", line 160, in caption_classifier self.write_net(save_file) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ ECCV2016/build_net/caffe_net.py", line 32, in write_net write_proto = self.n.to_proto() File "../../python/caffe/net_spec.py", line 178, in to_proto top._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 92, in _to_proto return self.fn._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 153, in _to_proto assign_proto(layer, k, v) File "../../python/caffe/net_spec.py", line 74, in assign_proto setattr(proto, name, val) AttributeError: Assignment not allowed (no field "layer" in protocol message object). .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] In main and parsing arguments Traceback (most recent call last): File "build_nets.py", line 203, in build_sentence_generation_model('definition', True, False) File "build_nets.py", line 102, in build_sentence_generation_model model_train.make_sentence_generation_net(save_file_train, accuracy=False, loss=True) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/lrcn.py", line 116, in make_sentence_generation_net self.write_net(save_file) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ ECCV2016/build_net/caffe_net.py", line 32, in write_net write_proto = self.n.to_proto() File "../../python/caffe/net_spec.py", line 178, in to_proto top._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 92, in _to_proto return self.fn._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 153, in _to_proto assign_proto(layer, k, v) File "../../python/caffe/net_spec.py", line 74, in assign_proto setattr(proto, name, val) AttributeError: Assignment not allowed (no field "layer" in protocol message object). .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] In main and parsing arguments Traceback (most recent call last): File "build_nets.py", line 205, in build_sentence_generation_model('description', False, True) File "build_nets.py", line 102, in build_sentence_generation_model model_train.make_sentence_generation_net(save_file_train, accuracy=False, loss=True) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/lrcn.py", line 116, in make_sentence_generation_net self.write_net(save_file) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ ECCV2016/build_net/caffe_net.py", line 32, in write_net write_proto = self.n.to_proto() File "../../python/caffe/net_spec.py", line 178, in to_proto top._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 92, in _to_proto return self.fn._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 153, in _to_proto assign_proto(layer, k, v) File "../../python/caffe/net_spec.py", line 74, in assign_proto setattr(proto, name, val) AttributeError: Assignment not allowed (no field "layer" in protocol message object). .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] In main and parsing arguments Traceback (most recent call last): File "build_nets.py", line 207, in build_sentence_generation_model('explanation-label', True, True) File "build_nets.py", line 102, in build_sentence_generation_model model_train.make_sentence_generation_net(save_file_train, accuracy=False, loss=True) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/lrcn.py", line 116, in make_sentence_generation_net self.write_net(save_file) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ ECCV2016/build_net/caffe_net.py", line 32, in write_net write_proto = self.n.to_proto() File "../../python/caffe/net_spec.py", line 178, in to_proto top._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 92, in _to_proto return self.fn._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 153, in _to_proto assign_proto(layer, k, v) File "../../python/caffe/net_spec.py", line 74, in assign_proto setattr(proto, name, val) AttributeError: Assignment not allowed (no field "layer" in protocol message object). .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] In main and parsing arguments Traceback (most recent call last): File "build_nets.py", line 211, in sentence_generation_reinforce('explanation-dis', orig_proto='prototxt/description_train.prototxt', classify_model=args.classify_model, classify_weights=args.classify_weights, weights=args.weights, class_conditional=False, lw=80) #Loss weight parameter chosen by parameter search File "build_nets.py", line 169, in sentence_generation_reinforce model_train.lrcn_reinforce(save_name=save_file_train, RL_loss=RL_loss, lw=lw) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ ECCV2016/build_net/reinforce.py", line 218, in lrcn_reinforce self.write_net(save_name) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ ECCV2016/build_net/caffe_net.py", line 32, in write_net write_proto = self.n.to_proto() File "../../python/caffe/net_spec.py", line 178, in to_proto top._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 92, in _to_proto return self.fn._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 153, in _to_proto assign_proto(layer, k, v) File "../../python/caffe/net_spec.py", line 74, in assign_proto setattr(proto, name, val) AttributeError: Assignment not allowed (no field "layer" in protocol message object). .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] In main and parsing arguments Traceback (most recent call last): File "build_nets.py", line 213, in sentence_generation_reinforce('explanation', orig_proto='prototxt/ explanation-label_train.prototxt', classify_model=args.classify_model, classify_weights=args.classify_weights, weights=args.weights, class_conditional=True, lw=110) #Loss weight parameter chocen by parameter search File "build_nets.py", line 169, in sentence_generation_reinforce model_train.lrcn_reinforce(save_name=save_file_train, RL_loss=RL_loss, lw=lw) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ ECCV2016/build_net/reinforce.py", line 218, in lrcn_reinforce self.write_net(save_name) File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ ECCV2016/build_net/caffe_net.py", line 32, in write_net write_proto = self.n.to_proto() File "../../python/caffe/net_spec.py", line 178, in to_proto top._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 92, in _to_proto return self.fn._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 153, in _to_proto assign_proto(layer, k, v) File "../../python/caffe/net_spec.py", line 74, in assign_proto setattr(proto, name, val) AttributeError: Assignment not allowed (no field "layer" in protocol message object). .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] .........EXECUTING CHILD........... ['/sbin/ldconfig', '-p'] In main and parsing arguments Traceback (most recent call last): File "build_nets.py", line 209, in build_sentence_generation_deploy() File "build_nets.py", line 72, in build_sentence_generation_deploy model_train.make_sentence_generation_deploy() File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ECCV2016/build_net/lrcn.py", line 59, in make_sentence_generation_deploy self.write_net('prototxt/deploy.prototxt') File "/home/chandra/LisaAnne/ECCV2016-ECCV2016/examples/ ECCV2016/build_net/caffe_net.py", line 32, in write_net write_proto = self.n.to_proto() File "../../python/caffe/net_spec.py", line 178, in to_proto top._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 92, in _to_proto return self.fn._to_proto(layers, names, autonames) File "../../python/caffe/net_spec.py", line 153, in _to_proto assign_proto(layer, k, v) File "../../python/caffe/net_spec.py", line 64, in assign_proto proto_item = getattr(proto, name).add() AttributeError: 'LayerParameter' object has no attribute 'shape'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/LisaAnne/ECCV2016/issues/4, or mute the thread https://github.com/notifications/unsubscribe-auth/AFQm2pIVUgk-yd_DT-FEtHa7q61vNOZnks5tWU4HgaJpZM4SKViu .

chandru4ni commented 6 years ago

Yes Lisa, we compiled with your project Caffe. And finally we found that issue was with the version of Ubuntu. We are using 16.x version. Below is the line we changed for the fix.

Replace "param_names = [s for s in dir(layer) if s.endswith('_param')]" with "param_names = [f.name for f in layer.DESCRIPTOR.fields if f.name.endswith('_param')]" in line 36 in file "net_spec.py"

Rgds, Chandra.