training the CRNNImage2Text model #149
-
Hi, I am trying to finetune the 'hezarai/crnn-fa-printed-96-long' model. But I am getting this error while running trainer.train: Also my dataset have 'image_path' and 'text' fields. Where I should give the trainer 'pixel_values'? Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Hi @kghezelbash, can you share your training script? or any other details about how you're constructing the dataset class? |
Beta Was this translation helpful? Give feedback.
-
Of course. from transformers import default_data_collator trainer = Trainer( trainer.train() And this is how I make my dataset: keys = list(data_dict.keys()) train_data = {"image_path": [], "text": []} test_data = {"image_path": [], "text": []} Create Dataset objectstrain_dataset = Dataset.from_dict(train_data) Create DatasetDictdataset_dict = DatasetDict({"train": train_dataset, "test": test_dataset}) |
Beta Was this translation helpful? Give feedback.
-
@kghezelbash Got it, you're only creating a dataset from raw inputs. But the correct way to do it is to firstly, transform the images in the dataset which includes resizing, normalization, scaling, etc and converting to torch.tensor and that is your hezar/hezar/data/datasets/ocr_dataset.py Line 190 in 39763bd |
Beta Was this translation helpful? Give feedback.
@kghezelbash Got it, you're only creating a dataset from raw inputs. But the correct way to do it is to firstly, transform the images in the dataset which includes resizing, normalization, scaling, etc and converting to torch.tensor and that is your
pixel_values
. Secondly, you have to also construct your label tensors which would be yourlabels
. You can take a look at the code starting from below:hezar/hezar/data/datasets/ocr_dataset.py
Line 190 in 39763bd