modelscope / modelscope Goto Github PK
View Code? Open in Web Editor NEWModelScope: bring the notion of Model-as-a-Service to life.
Home Page: https://www.modelscope.cn/
License: Apache License 2.0
ModelScope: bring the notion of Model-as-a-Service to life.
Home Page: https://www.modelscope.cn/
License: Apache License 2.0
示例来源 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
https://modelscope.cn/models/damo/cv_resnet_facedetection_scrfd10gkps/summary
The above site introduces the improved model V2 (34g_gnkps_v2).
'damo/cv_resnet_facedetection_scrfd10gkps' mentioned in the usage code Is this model SCRFD_34G_GNKPS_v2?
If not, how can I use it?
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)
modelscope/utils/multi_modal/fp16/fp16util.py
http://on-demand.gputechconf.com/gtc/2018/video/S81012/
地址 404 - Not Found
这个里面只是 交代了模型的下载 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))
使用以下代码,本地运行:
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)
请问如何解决?
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!
这个问题已经在1.0.3版本中发现,后续会在新版本中迭代改进。
目前用户可以直接在configuration.json中进行调整,改成正确的pipeline type 进行推理。
您好!
我按照官方的教程进行环境安装,但是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版本是多少?或者能否直接提供安装的链接?
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,日志信息为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])
check official doc, only found a 128x128 model .
unittest 失败信息
https://github.com/modelscope/modelscope/actions/runs/3607072488/jobs/6078852334
from .._constraints import (
File "/opt/conda/lib/python3.7/site-packages/scipy/optimize/_constraints.py", line 8, in
from numpy.testing import suppress_warnings
ModuleNotFoundError: No module named 'numpy.testing'
您好,我想请问下,离线没有网的Linux环境,如何通过源码安装?我仅需要audio相关的模块;
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
根据官方文档安装:https://modelscope.cn/docs/%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
p = pipeline('image-classification', 'damo/cv_vit-base_image-classification_Dailylife-labels')
ENV:
modelscope version: 1.1.1
阿里云 ubuntu 4 vCPU
15 GiB
200 Mbps
GPU:NVIDIA T4
I noticed it is nearly impossible to retrieve the pip pakckages (https://github.com/modelscope/modelscope/blob/master/docker/rcfiles/pip.conf.tsinghua) and the docker images
(https://github.com/modelscope/modelscope/blob/master/docker/Dockerfile.ubuntu#L1) outside China.
For example, I cannot download easyasr>=0.0.2
from tsinghua pip source, but I cannot find it elsewhere.
Can you please provide yet another docker file for the users living overseas?
MovieSceneSegmentationModel class 的 inference function有问题, 在batch inference时,计算 batch迭代次数时有小bug,当bs== input.size(0)时会error, cnt = shot_num // bs + 1
-> cat = math.ceil(shot_num/bs)
input:东阳草肌醇复合物
output: 东阳 肌醇 复合物
能否直接发布各子模块的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)
本地运行时每次结果都不一样,请问应该怎样修改
I'm currently trying to finetune asr model, when downloading the model the dl speed very slow, I think because of server location, I hope can programmatically change to use different url or let me download manually from google cloud like this issue
tinyvision/DAMO-YOLO#52
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.'
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和双塔召回模型很像,但是好像并不能像一般的bert模型一样导出句向量,目前句向量的生成模型都太大了,速度慢不适合做召回用。如果sructbert 像cross bert一样不能输出句向量。是否能够提供一些能输出句向量的tiny模型
请问我该如何获取到该镜像
reg.docker.alibaba-inc.com/modelscope/ubuntu:20.04-cuda11.3.0-cudnn8-devel
训练时希望修改下损失函数,但是没有看到相关的文档可以参考。
想请教下是否有相关的小demo 代码可以参考?
以及修改了损失函数后是否还是得使用 build_trainer的接口进行后续的训练?
你好, 我在尝试movie_scene_segmentation task时,不能正常pip install shotdetect_scenedetect_lgss. 目前暂未在公开源find这个library。
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.
pip install "modelscope[multi-modal]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
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 %
(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
对于image caption任务, ofa的其他模型,huggingface上可以找到,并且有一个参数 num_return_sequences 可以控制给定一张图片生成的句子个数,但是对于最大的模型ofa_image-caption_coco_6b_en只有mindscope才有,当我们使用pipline时能否一张图片生成多个句子?mindscope是否有相关参数?
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
$ 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-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“ 错误。随便写个参数,加进去,好像还缺少另外的参数。
官方的样例貌似不完整。
初始化pipeline的时候,请问可以指定哪张gpu吗?
看到开源了好多模型,甚是欣慰。想问问后续会开源模型的代码实现吗
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.
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.
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:一个具有良好内控制度的企业,进行科学的企业管理是十分必要的。
但是在示例句子上结果是一致的。即:这洋的话,下一年的福气来到自己身上。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.