I'm trying to use Donut model for document classification using my custom dataset (format similar to RVL-CDIP). When I train the model and run model inference (using model.generate() method) in the training loop for model evaluation, it is normal (inference for each image takes about 0.2s).
However, if after training, I save the model to checkpoint using the save_pretrained method, and then I load the checkpoint using the from_pretrained method, the model.generate() run extremely slow (6s ~ 7s).
Here is the code I use for inference (the code for inference in the training loop is exactly the same):
I'm trying to use Donut model for document classification using my custom dataset (format similar to RVL-CDIP). When I train the model and run model inference (using
model.generate()
method) in the training loop for model evaluation, it is normal (inference for each image takes about 0.2s).However, if after training, I save the model to checkpoint using the
save_pretrained
method, and then I load the checkpoint using thefrom_pretrained
method, themodel.generate()
run extremely slow (6s ~ 7s).Here is the code I use for inference (the code for inference in the training loop is exactly the same):
I run the model on a NVIDIA A100 40GB GPU. I used an Anaconda environment with the following requirements:
Can you have a look at this issue @NielsRogge. Thank you very much.