henghuiding / Vision-Language-Transformer

[ICCV2021 & TPAMI2023] Vision-Language Transformer and Query Generation for Referring Segmentation
MIT License
347 stars 23 forks source link

Problem: AttributeError: 'tuple' object has no attribute 'layer' #9

Open FioPio opened 2 years ago

FioPio commented 2 years ago

Whenever I try to train, test or whatever I get allways the same error, I have the code setup as you explain, but I keep getting the same error:

(ultimate) @fio:Vision-Language-Transformer> python vlt.py train config.yaml
Using TensorFlow backend.
batch_size: 128
embed_dim: 300
epoches: 50
evaluate_model: ./models/test_map.h5
evaluate_set: ./data/data_v2/anns/refcocog/val.json
free_body: 1
hidden_dim: 256
image_path: ./data/images/train2014
input_size: 416
jemb_dim: 1024
lang_att: True
log_images: 0
log_path: ./log/refcocog
lr: 0.001
lr_scheduler: step
max_queue_size: 10
multi_thres: False
num_query: 16
pretrained_weights: ./data/weights/yolov3_480000.h5
query_balance: True
rnn_bidirectional: True
rnn_drop_out: 0.1
rnn_hidden_size: 1024
seed: 10010
seg_gt_path: ./data/data_v2/masks/refcocog
seg_out_stride: 2
segment_thresh: 0.35
start_epoch: 0
steps: [40, 45, 50]
train_set: ./data/data_v2/anns/refcocog/train.json
transformer_decoder_num: 2
transformer_encoder_num: 2
transformer_head_num: 8
transformer_hidden_dim: 256
word_embed: en_vectors_web_lg
word_len: 20
workers: 32

--------------------------
PHASE:train

1 GPUs detected:
['/device:GPU:0']
Dataset Loaded: evaluate_set,  Len: 5000
Dataset Loaded: train_set,  Len: 44822
Creating model...
Traceback (most recent call last):
  File "vlt.py", line 54, in <module>
    trainer = Trainer(config, log_path, GPUS=GPU_COUNTS, debug=args.debug, verbose=args.verbose)
  File "/home/fio/Documents/UMU/semestre4TFM/code/demos/LG/test2/Vision-Language-Transformer/executor.py", line 117, in __init__
    super(Trainer, self).__init__(config, **kwargs)
  File "/home/fio/Documents/UMU/semestre4TFM/code/demos/LG/test2/Vision-Language-Transformer/executor.py", line 39, in __init__
    self.yolo_model, self.yolo_body, self.yolo_body_single = self.create_model()
  File "/home/fio/Documents/UMU/semestre4TFM/code/demos/LG/test2/Vision-Language-Transformer/executor.py", line 54, in create_model
    model_body = yolo_body(image_input, q_input, self.config)
  File "/home/fio/Documents/UMU/semestre4TFM/code/demos/LG/test2/Vision-Language-Transformer/model/vlt_model.py", line 162, in yolo_body
    mask_out = make_multitask_braches(Fv, fq, fq_word, config)
  File "/home/fio/Documents/UMU/semestre4TFM/code/demos/LG/test2/Vision-Language-Transformer/model/vlt_model.py", line 79, in make_multitask_braches
    mask_out = vlt_transformer(F_tf, fq_word, query_out, config)
  File "/home/fio/Documents/UMU/semestre4TFM/code/demos/LG/test2/Vision-Language-Transformer/model/vlt_model.py", line 100, in vlt_transformer
    head_num=config.transformer_head_num)
  File "/home/fio/Documents/UMU/semestre4TFM/code/demos/LG/test2/Vision-Language-Transformer/model/transfromer_model.py", line 78, in lang_tf_enc
    )(lang_input)
  File "/home/fio/anaconda3/envs/ultimate/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 881, in __call__
    inputs, outputs, args, kwargs)
  File "/home/fio/anaconda3/envs/ultimate/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 2043, in _set_connectivity_metadata_
    input_tensors=inputs, output_tensors=outputs, arguments=arguments)
  File "/home/fio/anaconda3/envs/ultimate/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 2059, in _add_inbound_node
    input_tensors)
  File "/home/fio/anaconda3/envs/ultimate/lib/python3.6/site-packages/tensorflow_core/python/util/nest.py", line 536, in map_structure
    structure[0], [func(*x) for x in entries],
  File "/home/fio/anaconda3/envs/ultimate/lib/python3.6/site-packages/tensorflow_core/python/util/nest.py", line 536, in <listcomp>
    structure[0], [func(*x) for x in entries],
  File "/home/fio/anaconda3/envs/ultimate/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 2058, in <lambda>
    inbound_layers = nest.map_structure(lambda t: t._keras_history.layer,
AttributeError: 'tuple' object has no attribute 'layer'

I have installed all the versions you specify with the requirements, and I am able to run the data_process_v2 script without any problem. Do you know what is happening?

Thank you in advance,

Ferriol

yeluo80808 commented 2 years ago

Hi, did you solve it? I has the same problem as you

FioPio commented 2 years ago

No, I haven't solved it, I more or less know the issue, but I did not test it yet

yeluo80808 commented 2 years ago

can you tell me why

changliu19 commented 2 years ago

Hi Ferriol and yeluo,

We do not have this error in our environment - but such kind of error (no attribute 'layer') usually indicates the incompatibility between keras and tf.keras. Our code use the standalone keras package, so please make sure all of your codes and their dependencies also use keras only.

fawnliu commented 2 years ago

Hi @ntuLC,

I have the same problem. Can you release your Dockerfile in a github link?

Galaxfyos commented 2 years ago

Hi @ntuLC,

I have the same problem. Can you release your Dockerfile in a github link?

I have the same problem,have you solved it?

zghehejun233 commented 1 year ago

I have the same problem, and I'm wondering how this function called tensorflow_lite. Have you solved it? I urgently need some of these data now.

freshpearYoon commented 1 year ago

I also have same problem. Is there anyone who solved it? I've done pip install -r requirement.txt , and done data preprocessing as suggested on readme.md

freshpearYoon commented 1 year ago

i fixed this error by installing tensorflow 2.11 and changing from keras import Layer to tensorflow.keras!