Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to save finetuned model DETR Tensorlfow #30

Open
Protozzzer opened this issue Jul 29, 2021 · 4 comments
Open

How to save finetuned model DETR Tensorlfow #30

Protozzzer opened this issue Jul 29, 2021 · 4 comments

Comments

@Protozzzer
Copy link

A use my own data in csv to finetune DETR tensorflow model. I cant find any implementation in source code how to save tensorflow model after each epoch. I want to implement saving weights, but there are some errors after this. Maybe you have some examples or recommendations how to save finetuned weights during or after training process.

@nathanterroir
Copy link

I am also having an issue saving the model after training using either the Keras API or saved_model formats. The specific error is:
Couldn't save model due to decoder_layer_call_fn(target, memory, target_mask, memory_mask, target_key_padding_mask, memory_key_padding_mask, pos_encoding, query_encoding, training) missing 1 required argument: memory

@Protozzzer , I was able to save model weights using detr.save_weights("save_path") where detr is the model I trained on my custom csv dataset.

@simpad2409
Copy link

Hi @Protozzzer ,
if you need help write me at [email protected] .
I have already solved this problem. Good day.

@Protozzzer
Copy link
Author

Hi @nathanterroir Thx for your answer)
Hi @simpad2409
Can you put here your answer how to solve problem with saving full model ?

@simpad2409
Copy link

simpad2409 commented Jul 31, 2021

@Protozzzer In the finetuning file add :

for epoch_nb in range(180):
    if epoch_nb > 0:
        # After the first epoch, we finetune the transformers and the new layers
        config.train_transformers.assign(True)
        config.transformers_lr.assign(1e-4)
        config.nlayers_lr.assign(1e-3)

    training.eval(detr, valid_dt, config, class_names, evaluation_step=100)
    training.fit(detr, train_dt, optimzers, config, epoch_nb, class_names)

    detr.save_weights("detr-my-model.ckpt")

or, to save each checkpoint, add:
ckp = "detr-my-model-"+str(epoch_nb)+".ckpt"
detr.save_weights(ckp)

@Protozzzer Which dataset are you finetuning on?

I'm doing it on the Crowd Human dataset, but I think I'm doing something wrong ... The model I get is very bad!
Could anyone help me? Thank you so much. I would be immensely grateful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants