modelscope /modelscope

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

★ 9,218⑂ 977👁 79⑃ 856● 972▤ 80
PythonApache-2.0Created 2022-07-25www.modelscope.cn/
下载:v1.40.3v1.40.3 ↓1.40.32026-11-09
+4
日增长
9,218
stars
977
forks
79
watchers
856
prs
972
issues
80
releases

README

Discord






    
      English |
         中文  |
         日本語 
    




 简介

ModelScope 是一个 “模型即服务”(MaaS) 平台,旨在汇集来自 AI 社区的最先进的机器学习模型,并简化在实际应用中使用 AI 模型的流程。ModelScope 库使开发人员能够通过丰富的 API 设计执行推理、训练和评估,从而促进跨不同 AI 领域的最先进模型的统一体验。

ModelScope Library 为模型贡献者提供了必要的分层 API,以便将来自 CV、NLP、语音、多模态以及科学计算的模型集成到 ModelScope 生态系统中。所有这些不同模型的实现都以一种简单统一访问的方式进行封装,用户只需几行代码即可完成模型推理、微调和评估。同时,灵活的模块化设计使得在必要时也可以自定义模型训练推理过程中的不同组件。

除了包含各种模型的实现之外,ModelScope Library 还支持与 ModelScope 后端服务进行必要的交互,特别是与 Model-Hub 和 Dataset-Hub 的交互。这种交互促进了模型和数据集的管理在后台无缝执行,包括模型数据集查询、版本控制、缓存管理等。

 部分模型和在线体验

ModelScope 开源了数百个 (当前 700+) 模型,涵盖自然语言处理、计算机视觉、语音、多模态、科学计算等,其中包含数百个 SOTA 模型。用户可以进入 ModelScope 网站 (modelscope.cn) 的模型中心零门槛在线体验,或者 Notebook 方式体验模型。


    
    
    


示例如下:

大模型:

 Yi-1.5-34B-Chat

 Qwen1.5-110B-Chat

 DeepSeek-V2-Chat

 Ziya2-13B-Chat

 Meta-Llama-3-8B-Instruct

 Phi-3-mini-128k-instruct

多模态:

 Qwen-VL-Chat

 Yi-VL-6B

 InternVL-Chat-V1-5

 deepseek-vl-7b-chat

 OpenSoraPlan

 OpenSora

 I2VGen-XL

计算机视觉:

 DamoFD 人脸检测关键点模型-0.5G

 BSHM 人像抠图

 DCT-Net 人像卡通化-3D

 DCT-Net 人像卡通化模型-3D

 读光-文字识别-行识别模型-中英-通用领域

 读光-文字识别-行识别模型-中英-通用领域

 LaMa 图像填充

语音:

 Paraformer 语音识别-中文-通用-16k-离线-大型-长音频版本

 FSMN 声音端点检测-中文-通用-16k-onnx

 Monotonic-Aligner 语音时间戳预测-16k-离线

 CT-Transformer 标点-中文-通用-onnx

 语音合成-中文-多情绪领域-16k-多发言人

 CAM++ 说话人验证-中文-通用-200k-发言人

科学计算:

 Uni-Fold-Monomer 开源的蛋白质单体结构预测模型

 Uni-Fold-Multimer 开源的蛋白质复合物结构预测模型

 快速上手

我们针对不同任务提供了统一的使用接口, 使用 pipeline 进行模型推理、使用 Trainer 进行微调和评估。

对于任意类型输入(图像、文本、音频、视频...)的任何任务,只需 3 行代码即可加载模型并获得推理结果,如下所示:

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


给定一张图片,你可以使用如下代码进行人像抠图.

!image

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


输出图像如下
!image

对于微调和评估模型, 你需要通过十多行代码构建 dataset 和 trainer,调用 trainer.train () 和 trainer.evaluate () 即可。

例如我们利用 gpt3 1.3B 的模型,加载是诗歌数据集进行 finetune,可以完成古诗生成模型的训练。

python
 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 ()


 为什么要用 ModelScope Library

1. 针对不同任务、不同模型抽象了统一简洁的用户接口,3 行代码完成推理,10 行代码完成模型训练,方便用户使用 Mo

Top issues

Discussions

Latest release

v1.40.3 v1.40.3 2026-11-09
Enhance
- Requires modelscope-hub=0.7.0.
- New modelscope.utils.file_utils.get_hub_cache_root(); modelscope.hub.cache_manager re-exports get_cache_root and resolve_cached_snapshot. MS_CACHE_HOME is normalised to an absolute path when bridged into the hub config.

Fix
- model_file_download(..., local_files_only=True) no longer calls the API to resolve the default revision, so offline downloads from cache work without network access or credentials.
- ms clear-cache lists every resolved target before deleting and delegates to modelscope-hub's scoped cache APIs; cache deletion via FileSystem

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON