Traceback (most recent call last):
File "C:\Users\user\.conda\envs\ocr\Lib\site-packages\torch\utils\data\dataloader.py", line 631, in __next__
data = self._next_data()
^^^^^^^^^^^^^^^^^
File "C:\Users\user\.conda\envs\ocr\Lib\site-packages\torch\utils\data\dataloader.py", line 675, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\.conda\envs\ocr\Lib\site-packages\torch\utils\data\_utils\fetch.py", line 51, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\.conda\envs\ocr\Lib\site-packages\torch\utils\data\_utils\fetch.py", line 51, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
~~~~~~~~~~~~^^^^^
File "C:\Users\user\.conda\envs\ocr\Lib\site-packages\modelscope\msdatasets\dataset_cls\custom_datasets\torch_custom_dataset.py", line 25, in __getitem__
return self.preprocessor(
^^^^^^^^^^^^^^^^^^
File "C:\Users\user\.conda\envs\ocr\Lib\site-packages\modelscope\models\cv\ocr_recognition\preprocessor.py", line 75, in __call__
raise TypeError(
TypeError: inputs should be either (a list of) str, PIL.Image, np.array, but got <class 'dict'>
源代码如下:
model_dir = "R:/AI_models"
model_id = "iic/cv_convnextTiny_ocr-recognition-general_damo"
dataset_dir = "R:/dataset"
ICDAR_dataset_id = "damo/ICDAR13_HCTR_Dataset"
PEOPLE_dataset_id = "iic/people_daily_ner_1998_tiny"
FUNDAN_dataset_id = "modelscope/ocr_fudanvi_zh"
work_dir = "..//OCR//work"
def _cfg_modify_fn(cfg):
cfg.train.max_epochs = 30
return cfg
train_dataset = MsDataset.load(cache_dir=dataset_dir,
dataset_name=FUNDAN_dataset_id, subset_name='scene', split='train')
test_dataset = MsDataset.load(cache_dir=dataset_dir,
dataset_name=FUNDAN_dataset_id, subset_name='scene', split='test')
kwargs = dict(
model=path_concat(model_dir, model_id),
train_dataset=train_dataset,
eval_dataset=test_dataset,
work_dir=work_dir,
cfg_modify_fn=_cfg_modify_fn)
trainer = build_trainer(name=Trainers.ocr_recognition, default_args=kwargs)
trainer.train()
ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!欢迎加入技术交流群:微信公众号:魔搭ModelScope社区,钉钉群号:44837352