问题一:下载模型文件报错:TypeError: __init__() got an unexpected k
modelscope 下载模型文件报错:TypeError: init() got an unexpected keyword argument 'allowed_methods' /usr/local/lib/python3.8/dist-packages/modelscope/hub/file_download.py in http_get_file(url, local_dir, file_name, cookies, headers) 208 logger.info('downloading %s to %s', url, temp_file.name) 209 # retry sleep 0.5s, 1s, 2s, 4s --> 210 retry = Retry( 211 total=API_FILE_DOWNLOAD_RETRY_TIMES, 212 backoff_factor=1,
TypeError: init() got an unexpected keyword argument 'allowed_methods'
参考回答:
您好,应该是您这边urllib3和requests两个库版本低导致的,可以尝试更新下这两个库
pip install urllib3 --upgrade pip install requests --upgrade
关于本问题的更多回答可点击原文查看:https://developer.aliyun.com/ask/486522?spm=a2c6h.14164896.0.0.66ae508eu7VAlR
问题二:Paraformer长音频版-识别过程中报错killed
使用的Modelscope的模型是 Paraformer语音识别-中文-通用-16k-离线-large-长音频版
正常比较短的音频,可以正常识别。
使用一个较长的音频,时长10小时,大小1.3GB,结果在执行过程中报错,显示killed,不知道有解决的办法吗? 音频格式,采样率等,都是符合要求的。
日志输出如下:
2023-02-15 15:33:34,371 - modelscope - INFO - Decoding with wav files ... 2023-02-15 15:33:34,371 (asr_inference_pipeline:387) INFO: Decoding with wav files ... Killed
参考回答:
初看到你提出的问题时,1.3GB的音频文件,个人觉得应该是音频文件太大,modelscope解析超时进程自动结束了,然后去modelscope你说的这个训练模型:https://modelscope.cn/models/damo/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch/summary 看到训练模型的整个说明文档并没有限制音频大小或者是时长,如果你的音频解析失败的话,可以现在模型的在线体验地方上传一下试试,不行的话再问一下在线技术支持当前模型支持的最大音频文件大小。
关于本问题的更多回答可点击原文查看:https://developer.aliyun.com/ask/485151?spm=a2c6h.14164896.0.0.66ae508eu7VAlR
在运行时,使用ocr识别的模型damo/cv_convnextTiny_ocr-recognition-general_damo,其读取的字典文件label_dict.txt的编码为utf-8,但是在windows下默认以gbk读取,导致报错,无法进行后续推理。请问官方能否将modelscope库中以下代码 with open(label_path, 'r') as f:
修改为例如: with open(label_path, 'r', encoding='utf8') as f: 的方式,明确指定以utf-8方式读取,以便解决默认发布的模型库问题?
参考回答:
通常情况下,OCR识别的label_dict.txt文件应该使用UTF-8编码,而不是GBK编码。如果您的Windows系统默认使用GBK编码来读取该文件,可能会导致读取错误。
解决这个问题的方法是,将Windows系统的默认编码设置为UTF-8,以便正确读取label_dict.txt文件。您可以按照以下步骤进行操作:
打开“控制面板”,并选择“时间、语言和区域”。 选择“区域和语言”,然后在弹出的窗口中,选择“更改时区”按钮。 在“区域和语言设置”窗口中,选择“中文(中华人民共和国)”下的“详细信息”按钮。 在“语言区域”下,选择“英语(美国)”并单击“确定”。 现在将文件关闭,然后将标签_dict.txt复制到一个文本编辑器中,并将其保存为UTF-8编码。 再次打开Windows资源管理器,您应该能够正确读取该文件了。 如果以上方法无法解决问题,您可以尝试使用文本编辑器(如记事本)打开label_dict.txt文件,并将其另存为UTF-8编码。
关于本问题的更多回答可点击原文查看:https://developer.aliyun.com/ask/468991?spm=a2c6h.14164896.0.0.66ae508eu7VAlR
代码是这个链接的示例代码 https://modelscope.cn/models/damo/cv_resnet_carddetection_scrfd34gkps/quickstart 环境配置好后,运行报错如下:
参考回答:
你好,前段时间maaslib升级导致报错,目前已修复,抱歉!
关于本问题的更多回答可点击原文查看:https://developer.aliyun.com/ask/479229?spm=a2c6h.14164896.0.0.66ae508eu7VAlR
将模型configuration.json里面的device设置为"cuda",运行官网提供的训练脚本,报张量不在同一设备的问题。 版本:
python 3.8.16 modelscope 1.3.0 torch 1.10.0 torchaudio 0.10.0 torchvision 0.11.0
configuration.json:
"device": "cuda", # 只修改了这一项
log:
2023-03-17 10:33:42,503 - modelscope - INFO - PyTorch version 1.10.0 Found. 2023-03-17 10:33:42,504 - modelscope - INFO - Loading ast index from /home/xuc/.cache/modelscope/ast_indexer 2023-03-17 10:33:42,529 - modelscope - INFO - Loading done! Current index file version is 1.3.0, with md5 6087da66a93f94dc2d05987df0e603c5 and a total number of 746 components indexed 2023-03-17 10:33:44,606 - modelscope - INFO - No subset_name specified, defaulting to the default Using custom data configuration modelscope-6e91f528cf9cd8e0 Downloading and preparing dataset ChineseText2SQL/modelscope to /home/xuc/.cache/modelscope/hub/datasets/modelscope/ChineseText2SQL/master/meta/modelscope___dataset_builder/modelscope-6e91f528cf9cd8e0/master/train_test... Downloading data: 100%|██████████████████████████████████████████████████████████████████████| 6.79k/6.79k [00:00<00:00, 10.7MB/s] Downloading data: 100%|██████████████████████████████████████████████████████████████████████| 1.19k/1.19k [00:00<00:00, 3.01MB/s] Downloading data files: 100%|███████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 2.97it/s] Extracting data files: 100%|███████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 782.30it/s] Downloading data files: 100%|███████████████████████████████████████████████████████████████████████| 2/2 [00:01<00:00, 1.79it/s] Extracting data files: 100%|████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 17.19it/s] Dataset chinese_text2_sql downloaded and prepared to /home/xuc/.cache/modelscope/hub/datasets/modelscope/ChineseText2SQL/master/meta/modelscope___dataset_builder/modelscope-6e91f528cf9cd8e0/master/train_test. Subsequent calls will reuse this data. 100%|██████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 772.57it/s] size of training set 500 size of evaluation set 100 2023-03-17 10:33:47,756 - modelscope - INFO - Model revision not specified, use the latest revision: v1.0.3 2023-03-17 10:33:47,939 - modelscope - INFO - File configuration.json already in cache, skip downloading! 2023-03-17 10:33:47,939 - modelscope - INFO - File pytorch_model.bin already in cache, skip downloading! 2023-03-17 10:33:47,939 - modelscope - INFO - File README.md already in cache, skip downloading! 2023-03-17 10:33:47,939 - modelscope - INFO - File star.jpg already in cache, skip downloading! 2023-03-17 10:33:47,939 - modelscope - INFO - File star.png already in cache, skip downloading! 2023-03-17 10:33:47,940 - modelscope - INFO - File synonym.txt already in cache, skip downloading! 2023-03-17 10:33:47,940 - modelscope - INFO - File table.json already in cache, skip downloading! 2023-03-17 10:33:47,940 - modelscope - INFO - File table1.json already in cache, skip downloading! 2023-03-17 10:33:47,940 - modelscope - INFO - File table2.json already in cache, skip downloading! 2023-03-17 10:33:47,940 - modelscope - INFO - File table3.json already in cache, skip downloading! 2023-03-17 10:33:47,940 - modelscope - INFO - File table4.json already in cache, skip downloading! 2023-03-17 10:33:47,940 - modelscope - INFO - File table5.json already in cache, skip downloading! 2023-03-17 10:33:47,940 - modelscope - INFO - File vocab.txt already in cache, skip downloading! 2023-03-17 10:33:47,940 - modelscope - INFO - initialize model from /home/xuc/.cache/modelscope/hub/damo/nlp_convai_text2sql_pretrain_cn Traceback (most recent call last): File "train.py", line 39, in <module> trainer.train( File "/home/xuc/.conda/envs/ms_env/lib/python3.8/site-packages/modelscope/trainers/nlp/table_question_answering_trainer.py", line 501, in train self.model.get_bert_output( File "/home/xuc/.conda/envs/ms_env/lib/python3.8/site-packages/modelscope/models/nlp/space_T_cn/table_question_answering.py", line 613, in get_bert_output all_encoder_layer, pooled_output = model_bert( File "/home/xuc/.conda/envs/ms_env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/home/xuc/.conda/envs/ms_env/lib/python3.8/site-packages/modelscope/models/nlp/space_T_cn/backbone.py", line 842, in forward embedding_output = self.embeddings( File "/home/xuc/.conda/envs/ms_env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/home/xuc/.conda/envs/ms_env/lib/python3.8/site-packages/modelscope/models/nlp/space_T_cn/backbone.py", line 115, in forward words_embeddings = self.word_embeddings(input_ids) File "/home/xuc/.conda/envs/ms_env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/home/xuc/.conda/envs/ms_env/lib/python3.8/site-packages/torch/nn/modules/sparse.py", line 158, in forward return F.embedding( File "/home/xuc/.conda/envs/ms_env/lib/python3.8/site-packages/torch/nn/functional.py", line 2044, in embedding return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse) RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper__index_select)
关于本问题的更多回答可点击原文查看:https://developer.aliyun.com/ask/491734?spm=a2c6h.14164896.0.0.66ae508eu7VAlR