请问用OFA进行ocr训练任务时,如何安排图片、标签文件的层次结构,以及如何使用MsDataset.load语句将图片和对应的标签传递到train_dataset中呢?
import os
import pandas as pd
import chardet
from PIL import Image
from datasets import Dataset
import tempfile
from modelscope.msdatasets import MsDataset
from modelscope.metainfo import Trainers
from modelscope.trainers import build_trainer
from modelscope.utils.constant import DownloadMode
with open('./ocr_labels_modelscope.csv', 'rb') as f:
result = chardet.detect(f.read())
data = pd.read_csv('./ocr_labels_modelscope.csv', encoding=result['encoding'])
ds = Dataset.from_pandas(data)
ds = MsDataset(ds)
print(next(iter(ds)))
文件格式:
image_id,text,image
000000000,硖,/mnt/workspace/images/000000000.jpg
000000001,饰,/mnt/workspace/images/000000001.jpg
000000002,晟,/mnt/workspace/images/000000002.jpg
同问,请问在文本行识别中如何使用MsDataset.load语句将图片和对应的标签传递到train_dataset中呢?