Finetuning TrOCR on the IAM dataset
I’m finetuning TrOCR model using Seq2SeqTrainer API, and I’ve taken reference fromthis notebook.My training is completed but there is no model saved, I’ve attached the image of the content in the output directory.snap762×225 26.3 KBAlso, I’ve attached my trainingnotebookfor reference.
2022-08-11T10:37:30Z
Hi,The error you’re getting is:OSError: Can’t load feature extractor for ‘./model’. If you were trying to load it from ‘Models - Hugging Face’, make sure you don’t have a local directory with the same name. Otherwise, make sure ‘./model’ is the correct path to a directory containing a preprocessor_config.json fileThat’s because theSeq2SeqTraineronly saves the model files (namely the weights as apytorch_model.binfile and the configuration as aconfig.jsonfile).However, you’re also loading the processor (TrOCRProcessor) from the directory. A processor combines a feature extractor (for the vision modality) and a tokenizer (for the text modality), hence it requires apreprocessor_config.jsonfile as well as avocab.txtfile for the tokenizer. It seems that you’re just using this one:processor = TrOCRProcessor.from_pretrained("microsoft/trocr-base-handwritten")Hence, you can use this one when performing inference. You can always save its files usingsave_pretrained. You can see the files required here:microsoft/trocr-base-handwritten at main