Giter Club home page Giter Club logo

modelscope's Introduction



PyPI

license open issues GitHub pull-requests GitHub latest commit Leaderboard

English | 中文 | 日本語

Introduction

ModelScope is built upon the notion of “Model-as-a-Service” (MaaS). It seeks to bring together most advanced machine learning models from the AI community, and streamlines the process of leveraging AI models in real-world applications. The core ModelScope library open-sourced in this repository provides the interfaces and implementations that allow developers to perform model inference, training and evaluation.

In particular, with rich layers of API-abstraction, the ModelScope library offers unified experience to explore state-of-the-art models spanning across domains such as CV, NLP, Speech, Multi-Modality, and Scientific-computation. Model contributors of different areas can integrate models into the ModelScope ecosystem through the layered-APIs, allowing easy and unified access to their models. Once integrated, model inference, fine-tuning, and evaluations can be done with only a few lines of codes. In the meantime, flexibilities are also provided so that different components in the model applications can be customized wherever necessary.

Apart from harboring implementations of a wide range of different models, ModelScope library also enables the necessary interactions with ModelScope backend services, particularly with the Model-Hub and Dataset-Hub. Such interactions facilitate management of various entities (models and datasets) to be performed seamlessly under-the-hood, including entity lookup, version control, cache management, and many others.

Models and Online Accessibility

Hundreds of models are made publicly available on ModelScope (700+ and counting), covering the latest development in areas such as NLP, CV, Audio, Multi-modality, and AI for Science, etc. Many of these models represent the SOTA in their specific fields, and made their open-sourced debut on ModelScope. Users can visit ModelScope(modelscope.cn) and experience first-hand how these models perform via online experience, with just a few clicks. Immediate developer-experience is also possible through the ModelScope Notebook, which is backed by ready-to-use CPU/GPU development environment in the cloud - only one click away on ModelScope.



Some representative examples include:

NLP:

Multi-Modal:

CV:

Audio:

AI for Science:

Note: Most models on ModelScope are public and can be downloaded without account registration on modelscope website(www.modelscope.cn), please refer to instructions for model download, for dowloading models with api provided by modelscope library or git.

QuickTour

We provide unified interface for inference using pipeline, fine-tuning and evaluation using Trainer for different tasks.

For any given task with any type of input (image, text, audio, video...), inference pipeline can be implemented with only a few lines of code, which will automatically load the underlying model to get inference result, as is exemplified below:

>>> from modelscope.pipelines import pipeline
>>> word_segmentation = pipeline('word-segmentation',model='damo/nlp_structbert_word-segmentation_chinese-base')
>>> word_segmentation('今天天气不错,适合出去游玩')
{'output': '今天 天气 不错 , 适合 出去 游玩'}

Given an image, portrait matting (aka. background-removal) can be accomplished with the following code snippet:

image

>>> import cv2
>>> from modelscope.pipelines import pipeline

>>> portrait_matting = pipeline('portrait-matting')
>>> result = portrait_matting('https://modelscope.oss-cn-beijing.aliyuncs.com/test/images/image_matting.png')
>>> cv2.imwrite('result.png', result['output_img'])

The output image with the background removed is: image

Fine-tuning and evaluation can also be done with a few more lines of code to set up training dataset and trainer, with the heavy-lifting work of training and evaluation a model encapsulated in the implementation of traner.train() and trainer.evaluate() interfaces.

For example, the gpt3 base model (1.3B) can be fine-tuned with the chinese-poetry dataset, resulting in a model that can be used for chinese-poetry generation.

>>> from modelscope.metainfo import Trainers
>>> from modelscope.msdatasets import MsDataset
>>> from modelscope.trainers import build_trainer

>>> train_dataset = MsDataset.load('chinese-poetry-collection', split='train'). remap_columns({'text1': 'src_txt'})
>>> eval_dataset = MsDataset.load('chinese-poetry-collection', split='test').remap_columns({'text1': 'src_txt'})
>>> max_epochs = 10
>>> tmp_dir = './gpt3_poetry'

>>> kwargs = dict(
     model='damo/nlp_gpt3_text-generation_1.3B',
     train_dataset=train_dataset,
     eval_dataset=eval_dataset,
     max_epochs=max_epochs,
     work_dir=tmp_dir)

>>> trainer = build_trainer(name=Trainers.gpt3_trainer, default_args=kwargs)
>>> trainer.train()

Why should I use ModelScope library

  1. A unified and concise user interface is abstracted for different tasks and different models. Model inferences and training can be implemented by as few as 3 and 10 lines of code, respectively. It is convenient for users to explore models in different fields in the ModelScope community. All models integrated into ModelScope are ready to use, which makes it easy to get started with AI, in both educational and industrial settings.

  2. ModelScope offers a model-centric development and application experience. It streamlines the support for model training, inference, export and deployment, and facilitates users to build their own MLOps based on the ModelScope ecosystem.

  3. For the model inference and training process, a modular design is put in place, and a wealth of functional module implementations are provided, which is convenient for users to customize their own model inference, training and other processes.

  4. For distributed model training, especially for large models, it provides rich training strategy support, including data parallel, model parallel, hybrid parallel and so on.

Installation

Docker

ModelScope Library currently supports popular deep learning framework for model training and inference, including PyTorch, TensorFlow and ONNX. All releases are tested and run on Python 3.7+, Pytorch 1.8+, Tensorflow1.15 or Tensorflow2.0+.

To allow out-of-box usage for all the models on ModelScope, official docker images are provided for all releases. Based on the docker image, developers can skip all environment installation and configuration and use it directly. Currently, the latest version of the CPU image and GPU image can be obtained from:

CPU docker image

# py37
registry.cn-hangzhou.aliyuncs.com/modelscope-repo/modelscope:ubuntu20.04-py37-torch1.11.0-tf1.15.5-1.6.1

# py38
registry.cn-hangzhou.aliyuncs.com/modelscope-repo/modelscope:ubuntu20.04-py38-torch2.0.1-tf2.13.0-1.9.5

GPU docker image

# py37
registry.cn-hangzhou.aliyuncs.com/modelscope-repo/modelscope:ubuntu20.04-cuda11.3.0-py37-torch1.11.0-tf1.15.5-1.6.1

# py38
registry.cn-hangzhou.aliyuncs.com/modelscope-repo/modelscope:ubuntu20.04-cuda11.8.0-py38-torch2.0.1-tf2.13.0-1.9.5

Setup Local Python Environment

One can also set up local ModelScope environment using pip and conda. ModelScope supports python3.7 and above. We suggest anaconda for creating local python environment:

conda create -n modelscope python=3.8
conda activate modelscope

PyTorch or TensorFlow can be installed separately according to each model's requirements.

  • Install pytorch doc
  • Install tensorflow doc

After installing the necessary machine-learning framework, you can install modelscope library as follows:

If you only want to play around with the modelscope framework, of trying out model/dataset download, you can install the core modelscope components:

pip install modelscope

If you want to use multi-modal models:

pip install modelscope[multi-modal]

If you want to use nlp models:

pip install modelscope[nlp] -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

If you want to use cv models:

pip install modelscope[cv] -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

If you want to use audio models:

pip install modelscope[audio] -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

If you want to use science models:

pip install modelscope[science] -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

Notes:

  1. Currently, some audio-task models only support python3.7, tensorflow1.15.4 Linux environments. Most other models can be installed and used on Windows and Mac (x86).

  2. Some models in the audio field use the third-party library SoundFile for wav file processing. On the Linux system, users need to manually install libsndfile of SoundFile(doc link). On Windows and MacOS, it will be installed automatically without user operation. For example, on Ubuntu, you can use following commands:

    sudo apt-get update
    sudo apt-get install libsndfile1
  3. Some models in computer vision need mmcv-full, you can refer to mmcv installation guide, a minimal installation is as follows:

    pip uninstall mmcv # if you have installed mmcv, uninstall it
    pip install -U openmim
    mim install mmcv-full

Learn More

We provide additional documentations including:

License

This project is licensed under the Apache License (Version 2.0).

modelscope's People

Contributors

afalf avatar bincard avatar cathy0908 avatar ccyhxg avatar co63oc avatar firmament-cyou avatar foocker avatar ganjinzero avatar huangshenno1 avatar jiangyuxzy avatar jintao-huang avatar jxst539246 avatar kangzhao2 avatar lauragpt avatar liuyhwangyh avatar lyblsgo avatar mushenl avatar pengzhendong avatar shuaigezhu avatar slin000111 avatar suluyana avatar tastelikefeet avatar ttcoding avatar wangqiang9 avatar wangxingjun778 avatar wenmengzhou avatar xianzhexu avatar yfchenmodelscope avatar yingdachen avatar zzhangpurdue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modelscope's Issues

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

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')

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)

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

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.'

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)

请问如何解决?

StructBERT是否能生成句向量,

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

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

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/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/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))

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

此页面

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)

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

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

已经训练好了一个模型,想要加载模型,修改对应的配置文件进行继续训练,但没有看到对应的用法教程
例如 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")
似乎没有正常进入训练流程

'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 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.

官方案例报错

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

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!

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

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

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

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.'

docker镜像

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

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 % 

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 ?

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

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

docker镜像

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

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“ 错误。随便写个参数,加进去,好像还缺少另外的参数。

官方的样例貌似不完整。

使用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])

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版本是多少?或者能否直接提供安装的链接?

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.