Visual-Behavior / detr-tensorflow

Tensorflow implementation of DETR : Object Detection with Transformers
MIT License
169 stars 53 forks source link

ValueError: No such layer: position_embedding_sine #20

Closed dmoham1476 closed 3 years ago

dmoham1476 commented 3 years ago

I trained the model on a custom dataset using python finetune_.py script. I see this error when I try to load the finetuned model and use it with webcam.py. Does the code here need to be fixed? Or is there a training knob that I missed during training to have this layer?

detr = get_detr_model(config, include_top=False, nb_class=7, weights=None) detr.load_weights("model_dir/detr-model.ckpt")

networks/detr.py in get_detr_model(config, include_top, nb_class, weights, tf_backbone, num_decoder_layers, num_encoder_layers) 151 transformer = detr.get_layer("transformer") 152 # Positional embedding of the feature map --> 153 position_embedding_sine = detr.get_layer("position_embedding_sine") 154 # Used to project the feature map before to fit in into the encoder 155 input_proj = detr.get_layer('input_proj')

PhanTask commented 3 years ago

Yes, we need to add name="position_embedding_sine" and name="re_lu" to Line 42 and Line 54 in detr.py. I have created a pull request. https://github.com/Visual-Behavior/detr-tensorflow/pull/27