Git Product home page Git Product logo

modelscope / modelscope Goto Github PK

View Code? Open in Web Editor NEW
6.5K 69.0 677.0 54.1 MB

ModelScope: bring the notion of Model-as-a-Service to life.

Home Page: https://www.modelscope.cn/

License: Apache License 2.0

Shell 0.12% Makefile 0.01% Python 98.60% Dockerfile 0.01% Vim Script 0.01% JavaScript 0.01% C++ 0.39% Cuda 0.86% Smarty 0.02%
nlp cv speech multi-modal science deep-learning machine-learning python

modelscope's Issues

官方示例出错

示例来源 https://modelscope.cn/datasets/modelscope/Alimeeting4MUG/summary
示例代码

from modelscope.hub.api import HubApi
from modelscope.msdatasets import MsDataset
from modelscope.utils.constant import DownloadMode
api = HubApi()
sdk_token = "-----------"  # 必填, 从modelscope WEB端个人中心获取
api.login(sdk_token)  # online
input_config_kwargs = {'delimiter': '\t'}
data = MsDataset.load(
    'Alimeeting4MUG',
    namespace='modelscope',
    download_mode=DownloadMode.FORCE_REDOWNLOAD,
    subset_name="only_topic_segmentation",
    **input_config_kwargs)
    
print(data["test"][0])

错误返回

Traceback (most recent call last):
  File "SpokenNLP/test.py", line 13, in <module>
    **input_config_kwargs)
  File "/anaconda3/envs/nlp/lib/python3.7/site-packages/modelscope/msdatasets/ms_dataset.py", line 202, in load
    **config_kwargs)
  File "/anaconda3/envs/nlp/lib/python3.7/site-packages/modelscope/msdatasets/ms_dataset.py", line 252, in _load_ms_dataset
    **config_kwargs)
  File "/anaconda3/envs/nlp/lib/python3.7/site-packages/datasets/load.py", line 1681, in load_dataset
    **config_kwargs,
  File "/anaconda3/envs/nlp/lib/python3.7/site-packages/datasets/load.py", line 1453, in load_dataset_builder
    data_files=data_files,
  File "/anaconda3/envs/nlp/lib/python3.7/site-packages/datasets/load.py", line 1105, in dataset_module_factory
    path, data_dir=data_dir, data_files=data_files, download_mode=download_mode
  File "/anaconda3/envs/nlp/lib/python3.7/site-packages/datasets/load.py", line 631, in get_module
    allowed_extensions=ALL_ALLOWED_EXTENSIONS,
  File "/anaconda3/envs/nlp/lib/python3.7/site-packages/datasets/data_files.py", line 801, in from_local_or_remote
    if not isinstance(patterns_for_key, DataFilesList)
  File "/anaconda3/envs/nlp/lib/python3.7/site-packages/datasets/data_files.py", line 763, in from_local_or_remote
    data_files = resolve_patterns_locally_or_by_urls(base_path, patterns, allowed_extensions)
  File "/anaconda3/envs/nlp/lib/python3.7/site-packages/datasets/data_files.py", line 368, in resolve_patterns_locally_or_by_urls
    raise FileNotFoundError(error_msg)
FileNotFoundError: Unable to resolve any data file that matches '['**[-._ 0-9/]test[-._ 0-9]*', 'test[-._ 0-9]*', '**[-._ 0-9/]testing[-._ 0-9]*', 'testing[-._ 0-9]*', '**[-._ 0-9/]eval[-._ 0-9]*', 'eval[-._ 0-9]*', '**[-._ 0-9/]evaluation[-._ 0-9]*', 'evaluation[-._ 0-9]*']' at /Users/shenchengen/source/nlp/SpokenNLP/Alimeeting4MUG with any supported extension ['csv', 'tsv', 'json', 'jsonl', 'parquet', 'txt', 'blp', 'bmp', 'dib', 'bufr', 'cur', 'pcx', 'dcx', 'dds', 'ps', 'eps', 'fit', 'fits', 'fli', 'flc', 'ftc', 'ftu', 'gbr', 'gif', 'grib', 'h5', 'hdf', 'png', 'apng', 'jp2', 'j2k', 'jpc', 'jpf', 'jpx', 'j2c', 'icns', 'ico', 'im', 'iim', 'tif', 'tiff', 'jfif', 'jpe', 'jpg', 'jpeg', 'mpg', 'mpeg', 'msp', 'pcd', 'pxr', 'pbm', 'pgm', 'ppm', 'pnm', 'psd', 'bw', 'rgb', 'rgba', 'sgi', 'ras', 'tga', 'icb', 'vda', 'vst', 'webp', 'wmf', 'emf', 'xbm', 'xpm', 'BLP', 'BMP', 'DIB', 'BUFR', 'CUR', 'PCX', 'DCX', 'DDS', 'PS', 'EPS', 'FIT', 'FITS', 'FLI', 'FLC', 'FTC', 'FTU', 'GBR', 'GIF', 'GRIB', 'H5', 'HDF', 'PNG', 'APNG', 'JP2', 'J2K', 'JPC', 'JPF', 'JPX', 'J2C', 'ICNS', 'ICO', 'IM', 'IIM', 'TIF', 'TIFF', 'JFIF', 'JPE', 'JPG', 'JPEG', 'MPG', 'MPEG', 'MSP', 'PCD', 'PXR', 'PBM', 'PGM', 'PPM', 'PNM', 'PSD', 'BW', 'RGB', 'RGBA', 'SGI', 'RAS', 'TGA', 'ICB', 'VDA', 'VST', 'WEBP', 'WMF', 'EMF', 'XBM', 'XPM', 'aiff', 'au', 'avr', 'caf', 'flac', 'htk', 'svx', 'mat4', 'mat5', 'mpc2k', 'ogg', 'paf', 'pvf', 'raw', 'rf64', 'sd2', 'sds', 'ircam', 'voc', 'w64', 'wav', 'nist', 'wavex', 'wve', 'xi', 'mp3', 'opus', 'AIFF', 'AU', 'AVR', 'CAF', 'FLAC', 'HTK', 'SVX', 'MAT4', 'MAT5', 'MPC2K', 'OGG', 'PAF', 'PVF', 'RAW', 'RF64', 'SD2', 'SDS', 'IRCAM', 'VOC', 'W64', 'WAV', 'NIST', 'WAVEX', 'WVE', 'XI', 'MP3', 'OPUS', 'zip']

modelscope == 1.1.0

SCRFD人脸检测关键点模型 示例報錯

import cv2
from modelscope.pipelines import pipeline
from modelscope.utils.constant import  Tasks

face_detection = pipeline(task=Tasks.face_detection, model='damo/cv_resnet_facedetection_scrfd10gkps')
img_path = 'https://modelscope.oss-cn-beijing.aliyuncs.com/test/images/face_detection2.jpeg'
result = face_detection(img_path)

# if you want to show the result, you can run
from modelscope.utils.cv.image_utils import draw_face_detection_result
from modelscope.preprocessors.image import LoadImage
img = LoadImage.convert_to_ndarray(img_path)
cv2.imwrite('srcImg.jpg', img)
img_draw = draw_face_detection_result('srcImg.jpg', result)
import matplotlib.pyplot as plt
plt.imshow(img_draw)

螢幕快照 2023-01-04 18-22-30

官方案例报错

image
image
image
以上代码在modelscope集成的notebook里面运行没问题,自己配的环境就报一堆错,太奇怪了

模型下载下来后,怎么在本地用起来?

这个里面只是 交代了模型的下载 https://modelscope.cn/docs/%E6%A8%A1%E5%9E%8B%E7%9A%84%E4%B8%8B%E8%BD%BD

而我看模型的加载例子只有类似这种, 搞个model id load进去 , 没有说怎么在本地使用的例子

from modelscope.pipelines import pipeline
pipeline_ins = pipeline('fill-mask', model='damo/nlp_structbert_fill-mask_english-large')
input = 'Everything in [MASK] you call reality is really [MASK] a reflection of your [MASK].'
print(pipeline_ins(input))

TextToImageSynthesisPipeline: function takes exactly 5 arguments (1 given)

使用以下代码,本地运行:

import cv2
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

text2image = pipeline(Tasks.text_to_image_synthesis, 'damo/cv_diffusion_text-to-image-synthesis_tiny')
result = text2image({'text': '山水画'})

cv2.imwrite('result.png', result['output_img'])```

但是提示:
TypeError: TextToImageSynthesisPipeline: function takes exactly 5 arguments (1 given)

请问如何解决?

error

I run face_2d_keypoints task but it has an error:bboxes, scores, labels = bboxes[inds], scores[inds], labels[inds] RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu). It seems that it has bug in detection!

megatron库的安装问题

您好!
我按照官方的教程进行环境安装,但是megatron库的版本始终不对,报错如下:
ImportError: cannot import name 'get_global_memory_buffer' from 'megatron.global_vars' (/opt/anaconda3/envs/modelscope/lib/python3.7/site-packages/megatron/global_vars.py)
请问你们的megatron版本是多少?或者能否直接提供安装的链接?

img变量未定义

modelscope/pipelines/cv/face_recognition_pipeline.py
91行 img变量未定义
if top_face > 1 and center_face and bboxes.shape[0] > 1: img_center = [img.shape[1] // 2, img.shape[0] // 2] min_dist = float('inf')

使用modelscope测试image caption无法调用GPU

您好,我在使用ModelScope进行测试image caption,代码如下,但是无法调用GPU,日志信息为2022-11-11 13:43:22,300 - modelscope - INFO - cuda is not available, using cpu instead. 环境是按照官网文档配置的,并且PyTorch是可以调用cuda的,想请问一下是否是我使用有误或者有方法可以指导一下,感谢!

from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
from modelscope.outputs import OutputKeys

img_captioning = pipeline(Tasks.image_captioning, model='damo/ofa_image-caption_coco_large_en', device='gpu:0')
result = img_captioning('https://shuangqing-public.oss-cn-zhangjiakou.aliyuncs.com/donuts.jpg')
print(result[OutputKeys.CAPTION])

情感分类模型没有输出结果

2022-11-09 09:35:05,501 - modelscope - INFO - All model checkpoint weights were used when initializing SequenceClassificationModel.

2022-11-09 09:35:05 | INFO | modelscope | All model checkpoint weights were used when initializing SequenceClassificationModel.

2022-11-09 09:35:05,501 - modelscope - INFO - All the weights of SequenceClassificationModel were initialized from the model checkpoint If your task is similar to the task the model of the checkpoint was trained on, you can already use SequenceClassificationModel for predictions without further training.
2022-11-09 09:35:05 | INFO | modelscope | All the weights of SequenceClassificationModel were initialized from the model checkpoint If your task is similar to the task the model of the checkpoint was trained on, you can already use SequenceClassificationModel for predictions without further training.
The tokenizer class you load from this checkpoint is not the same type as the class this function is called from. It may result in unexpected tokenization.
The tokenizer class you load from this checkpoint is 'BertTokenizer'.
The class this function is called from is 'SbertTokenizer'.
2022-11-09 09:35:05,531 - modelscope - INFO - The key of sentence1: first_sequence, The key of sentence2: None, The key of label: label
2022-11-09 09:35:05 | INFO | modelscope | The key of sentence1: first_sequence, The key of sentence2: None, The key of label: label
D:\Anaconda\envs\modelscope\lib\site-packages\transformers\modeling_utils.py:764: FutureWarning: The device argument is deprecated and will be removed in v5 of Transformers.
"The device argument is deprecated and will be removed in v5 of Transformers.", FutureWarning

movie_scene_segmentation bug

MovieSceneSegmentationModel class 的 inference function有问题, 在batch inference时,计算 batch迭代次数时有小bug,当bs== input.size(0)时会error, cnt = shot_num // bs + 1 -> cat = math.ceil(shot_num/bs)

docker镜像

能否直接发布各子模块的docker镜像,配置环境花费了太长的时间,感觉这不利于用户体验和大批量推广,十分感谢

官方示例每次句向量生成结果不一样

此页面

from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

# 获取句子向量表示,可用于构建向量索引;
pipeline = pipeline(Tasks.faq_question_answering, 'damo/nlp_structbert_faq-question-answering_chinese-base')
sentence_vecs = pipeline.get_sentence_embedding(['如何使用优惠券', '今天有免费的10元无门槛吗', '购物评级怎么看'], max_len=30)

本地运行时每次结果都不一样,请问应该怎样修改

When I want to export hand-static model as onnx

model_id = 'damo/cv_mobileface_hand-static'
model = Model.from_pretrained(model_id)
output_files = Exporter.from_model(model).export_onnx(shape=(1, 310,310,3), opset=13, output_dir='/tmp')
print(output_files)

Traceback (most recent call last):
File "/home/luolab/yin/modelscope/test_modelscope.py", line 15, in
output_files = Exporter.from_model(model).export_onnx(shape=(1, 310,310,3), opset=13, output_dir='/tmp')
File "/home/luolab/anaconda3/envs/modelscope/lib/python3.8/site-packages/modelscope/exporters/base.py", line 39, in from_model
exporter = build_exporter(export_cfg, task_name, kwargs)
File "/home/luolab/anaconda3/envs/modelscope/lib/python3.8/site-packages/modelscope/exporters/builder.py", line 20, in build_exporter
return build_from_cfg(
File "/home/luolab/anaconda3/envs/modelscope/lib/python3.8/site-packages/modelscope/utils/registry.py", line 197, in build_from_cfg
raise KeyError(
KeyError: 'hand-static is not in the exporters registry group hand-static. Please make sure the correct version of ModelScope library is used.'

Missing optimizer and scheduler

I run some examples from docs . but i found some optimizers and schedulers missed which is used in configrations . such as "AdamW". in official docs ,it may casued by that my modelscope is too low .but my version is 1.1.0. it is nearly most new one. if i want to use "AdamW" , Should I code and register it by my self ?

如何加载已经训练好的模型继续训练

已经训练好了一个模型,想要加载模型,修改对应的配置文件进行继续训练,但没有看到对应的用法教程
例如 bert-base训练好了一个模型,有了output文件夹,和pth文件,我试下了build_trainer的方法

kwargs = dict(
model=model_id,
train_dataset=train_dataset,
eval_dataset=eval_dataset,
work_dir=WORK_DIR,
cfg_modify_fn=cfg_modify_fn)

trainer = build_trainer(name='nlp-base-trainer', default_args=kwargs)
trainer.train()
或者 ttainer.train("<模型名称>.pth")
似乎没有正常进入训练流程

StructBERT是否能生成句向量,

感觉structBert和双塔召回模型很像,但是好像并不能像一般的bert模型一样导出句向量,目前句向量的生成模型都太大了,速度慢不适合做召回用。如果sructbert 像cross bert一样不能输出句向量。是否能够提供一些能输出句向量的tiny模型

docker镜像

请问我该如何获取到该镜像
reg.docker.alibaba-inc.com/modelscope/ubuntu:20.04-cuda11.3.0-cudnn8-devel

如何使用自定义的损失函数训练模型?

训练时希望修改下损失函数,但是没有看到相关的文档可以参考。
想请教下是否有相关的小demo 代码可以参考?
以及修改了损失函数后是否还是得使用 build_trainer的接口进行后续的训练?

ERROR: Cannot install modelscope[audio,cv,multi-modal,nlp,science]==0.2.3, modelscope[audio,cv,multi-modal,nlp,science]==0.2.4,

Sytem: MacbookPro 2020 intel CPU, 32G Ram, macOS Ventura 13.0

When install include audio will return error:

ERROR: Cannot install modelscope[audio,cv,multi-modal,nlp,science]==0.2.3, modelscope[audio,cv,multi-modal,nlp,science]==0.2.4, modelscope[audio,cv,multi-modal,nlp,science]==0.2.5, modelscope[audio,cv,multi-modal,nlp,science]==0.3.1, modelscope[audio,cv,multi-modal,nlp,science]==0.3.2, modelscope[audio,cv,multi-modal,nlp,science]==0.3.3, modelscope[audio,cv,multi-modal,nlp,science]==0.3.4, modelscope[audio,cv,multi-modal,nlp,science]==0.3.5, modelscope[audio,cv,multi-modal,nlp,science]==0.3.6, modelscope[audio,cv,multi-modal,nlp,science]==0.3.7, modelscope[audio,cv,multi-modal,nlp,science]==0.4.0, modelscope[audio,cv,multi-modal,nlp,science]==0.4.1, modelscope[audio,cv,multi-modal,nlp,science]==0.4.2, modelscope[audio,cv,multi-modal,nlp,science]==0.4.3, modelscope[audio,cv,multi-modal,nlp,science]==0.4.4, modelscope[audio,cv,multi-modal,nlp,science]==0.4.5, modelscope[audio,cv,multi-modal,nlp,science]==0.4.6, modelscope[audio,cv,multi-modal,nlp,science]==0.4.7, modelscope[audio,cv,multi-modal,nlp,science]==0.5.0, modelscope[audio,cv,multi-modal,nlp,science]==0.5.1, modelscope[audio,cv,multi-modal,nlp,science]==1.0.0, modelscope[audio,cv,multi-modal,nlp,science]==1.0.1 and modelscope[audio,cv,multi-modal,nlp,science]==1.0.2 because these package versions have conflicting dependencies.
    1. Install multi-modal first, it is ok, then install audio return error
      command1 return ok: pip install "modelscope[multi-modal]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
      command2 return error: pip install "modelscope[audio]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

error log:

(modelscope) ppt@pptdeMacBook-Pro Github % pip install "modelscope[audio]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Looking in links: https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
Requirement already satisfied: modelscope[audio] in /Users/ppt/miniconda/envs/modelscope/lib/python3.7/site-packages (1.0.2)

......

Collecting inflect
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/67/e2/bcd7099b31d6a1f7be358f7ef7cf6fc97cc5a66353784fdfa4867e4243fb/inflect-6.0.2-py3-none-any.whl (34 kB)
Requirement already satisfied: matplotlib in /Users/ppt/miniconda/envs/modelscope/lib/python3.7/site-packages (from modelscope[audio]) (3.5.3)
Collecting modelscope[audio]
  Downloading https://modelscope.oss-cn-beijing.aliyuncs.com/releases/v0.2/modelscope-0.2.4-py3-none-any.whl (380 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 380.6/380.6 kB 2.1 MB/s eta 0:00:00
  Downloading https://modelscope.oss-cn-beijing.aliyuncs.com/releases/v0.2/modelscope-0.2.3-py3-none-any.whl (380 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 380.6/380.6 kB 2.7 MB/s eta 0:00:00
ERROR: Cannot install modelscope[audio]==0.2.3, modelscope[audio]==0.2.4, modelscope[audio]==0.2.5, modelscope[audio]==0.3.1, modelscope[audio]==0.3.2, modelscope[audio]==0.3.3, modelscope[audio]==0.3.4, modelscope[audio]==0.3.5, modelscope[audio]==0.3.6, modelscope[audio]==0.3.7, modelscope[audio]==0.4.0, modelscope[audio]==0.4.1, modelscope[audio]==0.4.2, modelscope[audio]==0.4.3, modelscope[audio]==0.4.4, modelscope[audio]==0.4.5, modelscope[audio]==0.4.6, modelscope[audio]==0.4.7, modelscope[audio]==0.5.0, modelscope[audio]==0.5.1, modelscope[audio]==1.0.0, modelscope[audio]==1.0.1 and modelscope[audio]==1.0.2 because these package versions have conflicting dependencies.

The conflict is caused by:
    modelscope[audio] 1.0.2 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 1.0.1 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 1.0.0 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.5.1 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.5.0 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.4.7 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.4.6 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.4.5 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.4.4 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.4.3 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.4.2 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.4.1 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.4.0 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.3.7 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.3.6 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.3.5 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.3.4 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.3.3 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.3.2 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.3.1 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio] 0.2.5 depends on ttsfrd==0.0.2; extra == "audio"
    modelscope[audio] 0.2.4 depends on ttsfrd==0.0.2; extra == "audio"
    modelscope[audio] 0.2.3 depends on ttsfrd==0.0.2; extra == "audio"

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
(modelscope) ppt@pptdeMacBook-Pro Github % 
  • install all the models include everything
    command (modelscope) ppt@pptdeMacBook-Pro Github % pip install "modelscope[audio,cv,nlp,multi-modal,science]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

error log:

(modelscope) ppt@pptdeMacBook-Pro Github % pip install "modelscope[audio,cv,nlp,multi-modal,science]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Looking in links: https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
Collecting modelscope[audio,cv,multi-modal,nlp,science]

......

Collecting modelscope[audio,cv,multi-modal,nlp,science]
  Using cached https://modelscope.oss-cn-beijing.aliyuncs.com/releases/v0.2/modelscope-0.2.4-py3-none-any.whl (380 kB)
WARNING: modelscope 0.2.4 does not provide the extra 'multi-modal'
WARNING: modelscope 0.2.4 does not provide the extra 'science'
  Using cached https://modelscope.oss-cn-beijing.aliyuncs.com/releases/v0.2/modelscope-0.2.3-py3-none-any.whl (380 kB)
WARNING: modelscope 0.2.3 does not provide the extra 'multi-modal'
WARNING: modelscope 0.2.3 does not provide the extra 'science'
ERROR: Cannot install modelscope[audio,cv,multi-modal,nlp,science]==0.2.3, modelscope[audio,cv,multi-modal,nlp,science]==0.2.4, modelscope[audio,cv,multi-modal,nlp,science]==0.2.5, modelscope[audio,cv,multi-modal,nlp,science]==0.3.1, modelscope[audio,cv,multi-modal,nlp,science]==0.3.2, modelscope[audio,cv,multi-modal,nlp,science]==0.3.3, modelscope[audio,cv,multi-modal,nlp,science]==0.3.4, modelscope[audio,cv,multi-modal,nlp,science]==0.3.5, modelscope[audio,cv,multi-modal,nlp,science]==0.3.6, modelscope[audio,cv,multi-modal,nlp,science]==0.3.7, modelscope[audio,cv,multi-modal,nlp,science]==0.4.0, modelscope[audio,cv,multi-modal,nlp,science]==0.4.1, modelscope[audio,cv,multi-modal,nlp,science]==0.4.2, modelscope[audio,cv,multi-modal,nlp,science]==0.4.3, modelscope[audio,cv,multi-modal,nlp,science]==0.4.4, modelscope[audio,cv,multi-modal,nlp,science]==0.4.5, modelscope[audio,cv,multi-modal,nlp,science]==0.4.6, modelscope[audio,cv,multi-modal,nlp,science]==0.4.7, modelscope[audio,cv,multi-modal,nlp,science]==0.5.0, modelscope[audio,cv,multi-modal,nlp,science]==0.5.1, modelscope[audio,cv,multi-modal,nlp,science]==1.0.0, modelscope[audio,cv,multi-modal,nlp,science]==1.0.1 and modelscope[audio,cv,multi-modal,nlp,science]==1.0.2 because these package versions have conflicting dependencies.

The conflict is caused by:
    modelscope[audio,cv,multi-modal,nlp,science] 1.0.2 depends on py-sound-connect>=0.1; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 1.0.1 depends on py-sound-connect>=0.1; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 1.0.0 depends on py-sound-connect>=0.1; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.5.1 depends on py-sound-connect>=0.1; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.5.0 depends on py-sound-connect>=0.1; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.4.7 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.4.6 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.4.5 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.4.4 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.4.3 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.4.2 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.4.1 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.4.0 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.3.7 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.3.6 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.3.5 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.3.4 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.3.3 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.3.2 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.3.1 depends on kwsbp>=0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.2.5 depends on ttsfrd==0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.2.4 depends on ttsfrd==0.0.2; extra == "audio"
    modelscope[audio,cv,multi-modal,nlp,science] 0.2.3 depends on ttsfrd==0.0.2; extra == "audio"

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
(modelscope) ppt@pptdeMacBook-Pro Github % 

情感分类模型没有输出结果

2022-11-09 09:35:05,501 - modelscope - INFO - All model checkpoint weights were used when initializing SequenceClassificationModel.

2022-11-09 09:35:05 | INFO | modelscope | All model checkpoint weights were used when initializing SequenceClassificationModel.

2022-11-09 09:35:05,501 - modelscope - INFO - All the weights of SequenceClassificationModel were initialized from the model checkpoint If your task is similar to the task the model of the checkpoint was trained on, you can already use SequenceClassificationModel for predictions without further training.
2022-11-09 09:35:05 | INFO | modelscope | All the weights of SequenceClassificationModel were initialized from the model checkpoint If your task is similar to the task the model of the checkpoint was trained on, you can already use SequenceClassificationModel for predictions without further training.
The tokenizer class you load from this checkpoint is not the same type as the class this function is called from. It may result in unexpected tokenization.
The tokenizer class you load from this checkpoint is 'BertTokenizer'.
The class this function is called from is 'SbertTokenizer'.
2022-11-09 09:35:05,531 - modelscope - INFO - The key of sentence1: first_sequence, The key of sentence2: None, The key of label: label
2022-11-09 09:35:05 | INFO | modelscope | The key of sentence1: first_sequence, The key of sentence2: None, The key of label: label
D:\Anaconda\envs\modelscope\lib\site-packages\transformers\modeling_utils.py:764: FutureWarning: The device argument is deprecated and will be removed in v5 of Transformers.
"The device argument is deprecated and will be removed in v5 of Transformers.", FutureWarning

unifold cpu 环境有问题

复现环境: modelscope notebook cpu版本

复现方式:
from modelscope.pipelines import pipeline

pipeline_ins = pipeline(
task='protein-structure',
model='DPTech/uni-fold-monomer')
protein = 'LILNLRGGAFVSNTQITMADKQKKFINEIQEGDLVRSYSITDETFQQNAVTSIVKHEADQLCQINFGKQHVVC'
outputs = pipeline_ins(protein)

问题:
image

fail to download the uni fold dataset

when i using the following script to down the unifold dataset:

from modelscope.msdatasets import MsDataset
ds = MsDataset.load(dataset_name='Uni-Fold-Data', namespace='DPTech', split='train')

there is an error:
requests.exceptions.ConnectionError: HTTPConnectionPool(host='www.modelscope.cn', port=80): Max retries exceeded with url: /api/v1/datasets/DPTech/Uni-Fold-Data/oss/tree/?MaxLimit=-1&Revision=master&Recursive=True&FilterDir=True (Caused by ReadTimeoutError("HTTPConnectionPool(host='www.modelscope.cn', port=80): Read timed out. (read timeout=60)"))

how to fix it? thanks

what is the correct version of ModelScope library to use cv_resnet_carddetection_scrfd34gkps

$ docker run -it \
> --gpus '"device=all"' \
> --ipc=host --ulimit memlock=-1 --ulimit stack=-1 \
> registry.cn-hangzhou.aliyuncs.com/modelscope-repo/modelscope:ubuntu20.04-cuda11.3.0-py37-torch1.11.0-tf1.15.5-1.0.2

root@a0957b5bb035:/# python
Python 3.7.13 (default, Mar 29 2022, 02:18:16)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> from modelscope.pipelines import pipeline
2022-11-14 13:25:10,539 - modelscope - INFO - PyTorch version 1.11.0+cu113 Found.
2022-11-14 13:25:10,540 - modelscope - INFO - Loading ast index from /mnt/workspace/.cache/modelscope/ast_indexer
2022-11-14 13:25:10,540 - modelscope - INFO - No valid ast index found from /mnt/workspace/.cache/modelscope/ast_indexer, rebuilding ast index!
2022-11-14 13:25:10,544 - modelscope - INFO - AST-Scaning the path "/opt/conda/lib/python3.7/site-packages/modelscope" with the following sub folders ['models', 'metrics', 'pipelines', 'preprocessors', 'trainers', 'msdatasets']

2022-11-14 13:25:24,640 - modelscope - INFO - Scaning done! A number of 425 files indexed! Time consumed 14.096197605133057s
2022-11-14 13:25:24,651 - modelscope - INFO - Loading done! Current index file version is 1.0.2, with md5 9162426873f519b5f40405e5553297ce
>>>
>>> from modelscope.utils.constant import  Tasks
>>> face_detection_34g = pipeline(Tasks.face_detection, 'damo/cv_resnet_carddetection_scrfd34gkps')
2022-11-14 13:25:55,297 - modelscope - INFO - Model revision not specified, use the latest revision: v1.0.0
2022-11-14 13:25:55,544 - modelscope - INFO - downloading http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=description/card_detect.jpg to /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe/tmp08luyn2i
Downloading: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 523k/523k [00:00<00:00, 2.64MB/s]
2022-11-14 13:25:55,940 - modelscope - INFO - storing http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=description/card_detect.jpg in cache at /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe
2022-11-14 13:25:55,942 - modelscope - INFO - downloading http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=description/card_detection1.jpg to /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe/tmpxrj3oxt1
Downloading: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 249k/249k [00:00<00:00, 1.39MB/s]
2022-11-14 13:25:56,329 - modelscope - INFO - storing http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=description/card_detection1.jpg in cache at /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe
2022-11-14 13:25:56,330 - modelscope - INFO - downloading http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=description/card_detection2.jpg to /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe/tmp794_j45t
Downloading: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 139k/139k [00:00<00:00, 1.10MB/s]
2022-11-14 13:25:56,640 - modelscope - INFO - storing http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=description/card_detection2.jpg in cache at /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe
2022-11-14 13:25:56,641 - modelscope - INFO - downloading http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=description/card_detection3.jpg to /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe/tmpbom8q4xy
Downloading: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 75.0k/75.0k [00:00<00:00, 878kB/s]
2022-11-14 13:25:56,909 - modelscope - INFO - storing http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=description/card_detection3.jpg in cache at /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe
2022-11-14 13:25:56,909 - modelscope - INFO - downloading http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=configuration.json to /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe/tmp4rh0q8sq
Downloading: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 138/138 [00:00<00:00, 832kB/s]
2022-11-14 13:25:57,101 - modelscope - INFO - storing http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=configuration.json in cache at /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe
2022-11-14 13:25:57,101 - modelscope - INFO - downloading http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=mmcv_scrfd.py to /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe/tmpsit250px
Downloading: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 5.92k/5.92k [00:00<00:00, 1.06MB/s]
2022-11-14 13:25:57,282 - modelscope - INFO - storing http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=mmcv_scrfd.py in cache at /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe
2022-11-14 13:25:57,283 - modelscope - INFO - downloading http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=pytorch_model.bin to /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe/tmphvs4vg4d
Downloading: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 76.1M/76.1M [00:13<00:00, 5.91MB/s]
2022-11-14 13:26:10,967 - modelscope - INFO - storing http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=pytorch_model.bin in cache at /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe
2022-11-14 13:26:11,016 - modelscope - INFO - downloading http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=README.md to /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe/tmp4l24x06c
Downloading: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 5.96k/5.96k [00:00<00:00, 942kB/s]
2022-11-14 13:26:11,206 - modelscope - INFO - storing http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=README.md in cache at /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe
2022-11-14 13:26:11,206 - modelscope - INFO - downloading http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=description/traindata.jpg to /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe/tmpfv_3o3mu
Downloading: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 236k/236k [00:00<00:00, 1.46MB/s]
2022-11-14 13:26:11,548 - modelscope - INFO - storing http://www.modelscope.cn/api/v1/models/damo/cv_resnet_carddetection_scrfd34gkps/repo?Revision=v1.0.0&FilePath=description/traindata.jpg in cache at /mnt/workspace/.cache/modelscope/temp/tmpx2airsoe
2022-11-14 13:26:11,554 - modelscope - WARNING - ('PIPELINES', 'face-detection', 'resnet-card-detection-scrfd34gkps') not found in ast index file
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/conda/lib/python3.7/site-packages/modelscope/pipelines/builder.py", line 325, in pipeline
    return build_pipeline(cfg, task_name=task)
  File "/opt/conda/lib/python3.7/site-packages/modelscope/pipelines/builder.py", line 243, in build_pipeline
    cfg, PIPELINES, group_key=task_name, default_args=default_args)
  File "/opt/conda/lib/python3.7/site-packages/modelscope/utils/registry.py", line 198, in build_from_cfg
    f'{obj_type} is not in the {registry.name}'
KeyError: 'resnet-card-detection-scrfd34gkps is not in the pipelines registry group face-detection. Please make sure the correct version of ModelScope library is used.'

GPT样例无法运行

如下是GPT-1.3B的官方样例

if __name__ == '__main__':
    if torch.multiprocessing.get_start_method(allow_none=True) is None:
       torch.multiprocessing.set_start_method('spawn')
    input = '程序员脱发用什么洗发水'
    # model_id = 'damo/nlp_gpt3_text-generation_2.7B'
    model_id = 'damo/nlp_gpt3_text-generation_1.3B'
    pipe = pipeline(Tasks.text_generation, model=model_id)
    pipe.models = []
    print(pipe(input))

当我在服务器上执行 python main.py 的时候程序会告诉我, 在执行Megatron-LM/megatron/arguments.py的时候,会报
”assert args.encoder_seq_length is not None“ 错误。随便写个参数,加进去,好像还缺少另外的参数。

官方的样例貌似不完整。

nlp throw exceptions

Traceback (most recent call last):
File "./comm.py", line 902, in
testModelScopeNlp()
File "./comm.py", line 830, in testModelScopeNlp
task=Tasks.translation, model="damo/nlp_csanmt_translation_zh2en"
File "/data/apps/miniconda3/envs/modelscope-nlp/lib/python3.7/site-packages/modelscope/pipelines/builder.py", line 352, in pipeline
return build_pipeline(cfg, task_name=task)
File "/data/apps/miniconda3/envs/modelscope-nlp/lib/python3.7/site-packages/modelscope/pipelines/builder.py", line 270, in build_pipeline
cfg, PIPELINES, group_key=task_name, default_args=default_args)
File "/data/apps/miniconda3/envs/modelscope-nlp/lib/python3.7/site-packages/modelscope/utils/registry.py", line 215, in build_from_cfg
raise type(e)(f'{obj_cls.name}: {e}')
NotImplementedError: TranslationPipeline: Cannot convert a symbolic Tensor (NmtModel/strided_slice_3:0) to a numpy array.

'gbk' codec can't decode byte 0xa7 in position 4694: illegal multibyte sequence

Collecting easyrobust
Using cached easyrobust-0.2.3.tar.gz (1.5 MB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
Traceback (most recent call last):
File "", line 36, in
File "", line 34, in
File "C:\Users\PS\AppData\Local\Temp\pip-install-jrhihwnw\easyrobust_f9476defb7d148f480bdaebb21665f91\setup.py", line 5, in
readme = f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 4694: illegal multibyte sequence
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

nlp_bart_text-error-correction_chinese bart转换到huggingface使用时和modelscope结果有细微的差别

原因:

modelscope的纠错不支持batch,并且可控性太差,于是想转换至huggingface

转换代码:

def convert_fairseq_to_huggingface():
    hf_model = torch.load("./huggingface_bart_large/pytorch_model.bin")
    # model2 = torch.load("./bart_hf/pytorch_model.bin")
    fairseq_model = torch.load("./modelscope_bart/pytorch_model.pt")
    model2 = OrderedDict()
    for key, value in fairseq_model['model'].items():
        model2["model."+key] = value
    # model2['final_logits_bias'] = hf_model['final_logits_bias']
    # model2['lm_head.weight'] = hf_model['lm_head.weight']
    torch.save(model2, "./bart_hf/pytorch_model.bin")

预测代码:

def predict_modelscope_correction_via_huggingface():
    tokenizer = BertTokenizer.from_pretrained("./bart_hf/", padding=True,
                                              bos_token="<s>", eos_token="</s>",
                                              pad_token="<pad>", unk_token="<unk>",
                                              cls_token="[CLS]", sep_token="[SEP]",
                                              add_special_tokens=False)
    hf_model_0 = BartForConditionalGeneration.from_pretrained("./bart_hf/")
    inputs = tokenizer.tokenize("一个具有良好内控制度的企业,进行科学的企业管理是十分必要的。")
    inputs += [tokenizer.eos_token]
    input_length = len(inputs)
    inputs = [tokenizer.convert_tokens_to_ids(inputs)]
    inputs = {
        "input_ids": torch.LongTensor(inputs),
        "attention_mask": torch.LongTensor([[1] * input_length])
    }
    summary_ids = hf_model_0.generate(inputs["input_ids"], num_beams=5, output_scores=True, output_attentions=True,
                                      min_length=0, max_length=50, return_dict_in_generate=True, pad_token_id=1,
                                      decoder_start_token_id=2, output_hidden_states=True)
    # print(summary_ids)
    print(tokenizer.batch_decode(summary_ids['sequences'], clean_up_tokenization_spaces=False)[0])

我有看modelscope的代码,纠错使用的beam_size=5; decoder_start_id 是 2也就是</s>
然后input_ids 会加入eos_token也就是 </s>
但是使用上面的代码得到的结果和modelscope有较大的差别。
hf: 一个具有良好内控制度的企业,进行科学的企業管理是十分必要的。
ms:一个具有良好内控制度的企业,进行科学的企业管理是十分必要的。
但是在示例句子上结果是一致的。即:这洋的话,下一年的福气来到自己身上。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.