OA0
OA0 是一个探索 AI 的社区
现在注册
已注册用户请  登录
OA0  ›  代码  ›  ModelScope — 覆盖模型、数据集与应用的开源 AI 社区平台

ModelScope — 覆盖模型、数据集与应用的开源 AI 社区平台

 
  nova ·  2026-06-25 11:00:15 · 17 次点击  · 0 条评论  



[![PyPI](https://img.shields.io/pypi/v/modelscope)](https://pypi.org/project/modelscope/) [![license](https://img.shields.io/github/license/modelscope/modelscope.svg)](https://github.com/modelscope/modelscope/blob/master/LICENSE) [![open issues](https://isitmaintained.com/badge/open/modelscope/modelscope.svg)](https://github.com/modelscope/modelscope/issues) [![GitHub pull-requests](https://img.shields.io/github/issues-pr/modelscope/modelscope.svg)](https://GitHub.com/modelscope/modelscope/pull/) [![GitHub latest commit](https://badgen.net/github/last-commit/modelscope/modelscope)](https://GitHub.com/modelscope/modelscope/commit/) [![Leaderboard](https://img.shields.io/badge/ModelScope-Check%20Your%20Contribution-orange)](https://opensource.alibaba.com/contribution_leaderboard/details?projectValue=modelscope) [Discord](https://discord.gg/FMupRv4jUR)

modelscope%2Fmodelscope | Trendshift

English | 中文 | 日本語

# 简介 [ModelScope](https://www.modelscope.cn) 基于"模型即服务"(MaaS)的理念构建,旨在汇集 AI 社区最先进的机器学习模型,并简化 AI 模型在实际应用中的使用流程。本仓库开源的 ModelScope 核心库提供了接口和实现,使开发者能够执行模型推理、训练和评估。 特别是,通过丰富的 API 抽象层,ModelScope 库为探索跨领域(如 CV、NLP、语音、多模态和科学计算)的最先进模型提供了统一体验。不同领域的模型贡献者可以通过分层 API 将模型集成到 ModelScope 生态系统中,从而轻松统一地访问他们的模型。集成后,只需几行代码即可完成模型推理、微调和评估。同时,还提供了灵活性,以便在需要时自定义模型应用中的不同组件。 除了托管各种不同模型的实现外,ModelScope 库还支持与 ModelScope 后端服务(特别是模型中心和数据集中心)进行必要的交互。这些交互有助于无缝管理各种实体(模型和数据集),包括实体查找、版本控制、缓存管理等。 # 模型与在线访问 数百个模型已在 [ModelScope](https://www.modelscope.cn) 上公开发布(700+ 且持续增长),涵盖 NLP、CV、音频、多模态和 AI for Science 等领域的最新发展。其中许多模型代表了其特定领域的最先进水平,并在 ModelScope 上首次开源发布。用户可以访问 ModelScope([modelscope.cn](http://www.modelscope.cn)),通过在线体验只需点击几下即可亲身感受这些模型的性能。通过 ModelScope Notebook,用户还可以立即获得开发者体验,该 Notebook 由云端即用型 CPU/GPU 开发环境支持——在 [ModelScope](https://www.modelscope.cn) 上只需一键即可启动。



一些代表性示例包括: **LLM:** * [Yi-1.5-34B-Chat](https://modelscope.cn/models/01ai/Yi-1.5-34B-Chat/summary) * [Qwen1.5-110B-Chat](https://modelscope.cn/models/qwen/Qwen1.5-110B-Chat/summary) * [DeepSeek-V2-Chat](https://modelscope.cn/models/deepseek-ai/DeepSeek-V2-Chat/summary) * [Ziya2-13B-Chat](https://modelscope.cn/models/Fengshenbang/Ziya2-13B-Chat/summary) * [Meta-Llama-3-8B-Instruct](https://modelscope.cn/models/LLM-Research/Meta-Llama-3-8B-Instruct/summary) * [Phi-3-mini-128k-instruct](https://modelscope.cn/models/LLM-Research/Phi-3-mini-128k-instruct/summary) **多模态:** * [Qwen-VL-Chat](https://modelscope.cn/models/qwen/Qwen-VL-Chat/summary) * [Yi-VL-6B](https://modelscope.cn/models/01ai/Yi-VL-6B/summary) * [InternVL-Chat-V1-5](https://modelscope.cn/models/AI-ModelScope/InternVL-Chat-V1-5/summary) * [deepseek-vl-7b-chat](https://modelscope.cn/models/deepseek-ai/deepseek-vl-7b-chat/summary) * [OpenSoraPlan](https://modelscope.cn/models/AI-ModelScope/Open-Sora-Plan-v1.0.0/summary) * [OpenSora](https://modelscope.cn/models/luchentech/OpenSora-STDiT-v1-HQ-16x512x512/summary) * [I2VGen-XL](https://modelscope.cn/models/iic/i2vgen-xl/summary) **CV (计算机视觉):** * [DamoFD 人脸检测关键点模型 - 0.5G](https://modelscope.cn/models/damo/cv_ddsar_face-detection_iclr23-damofd/summary) * [BSHM 人像抠图](https://modelscope.cn/models/damo/cv_unet_image-matting/summary) * [DCT-Net 人像卡通化 - 3D](https://modelscope.cn/models/damo/cv_unet_person-image-cartoon-3d_compound-models/summary) * [DCT-Net 人像卡通化模型 - 3D](https://modelscope.cn/models/damo/face_chain_control_model/summary) * [DuGuang - 文字识别 - 行识别模型 - 中英文 - 通用领域](https://modelscope.cn/models/damo/cv_convnextTiny_ocr-recognition-general_damo/summary) * [DuGuang - 文字识别 - 行识别模型 - 中英文 - 通用领域](https://modelscope.cn/models/damo/cv_resnet18_ocr-detection-line-level_damo/summary) * [LaMa 图像修复](https://modelscope.cn/models/damo/cv_fft_inpainting_lama/summary) **音频:** * [Paraformer 语音识别 - 中文 - 通用 - 16k - 离线 - 大型 - 长音频版本](https://modelscope.cn/models/damo/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch/summary) * [FSMN 语音端点检测 - 中文 - 通用 - 16k - onnx](https://modelscope.cn/models/damo/speech_fsmn_vad_zh-cn-16k-common-onnx/summary) * [Monotonic-Aligner 语音时间戳预测 - 16k - 离线](https://modelscope.cn/models/damo/speech_timestamp_prediction-v1-16k-offline/summary) * [CT-Transformer 标点 - 中文 - 通用 - onnx](https://modelscope.cn/models/damo/punc_ct-transformer_zh-cn-common-vocab272727-onnx/summary) * [语音合成 - 中文 - 多情感领域 - 16k - 多说话人](https://modelscope.cn/models/damo/speech_sambert-hifigan_tts_zh-cn_16k/summary) * [CAM++ 说话人验证 - 中文 - 通用 - 200k-说话人](https://modelscope.cn/models/damo/speech_campplus_sv_zh-cn_16k-common/summary) **AI for Science:** * [uni-fold-monomer](https://modelscope.cn/models/DPTech/uni-fold-monomer/summary) * [uni-fold-multimer](https://modelscope.cn/models/DPTech/uni-fold-multimer/summary) **注意:** ModelScope 上的大多数模型都是公开的,可以直接从[网站](https://modelscope.cn/)下载。请参考[模型下载](https://modelscope.cn/docs/%E6%A8%A1%E5%9E%8B%E7%9A%84%E4%B8%8B%E8%BD%BD)说明,了解如何使用 modelscope 库或 git 提供的 API 下载模型。 # 快速入门 我们为不同任务提供了统一的推理接口 `pipeline`,以及使用 `Trainer` 进行微调和评估的接口。 对于任何给定任务和任何类型的输入(图像、文本、音频、视频...),推理 pipeline 只需几行代码即可实现,它会自动加载底层模型以获取推理结果,如下例所示:

>>> from modelscope.pipelines import pipeline
>>> word_segmentation = pipeline('word-segmentation',model='damo/nlp_structbert_word-segmentation_chinese-base')
>>> word_segmentation('今天天气不错,适合出去游玩')
{'output': '今天 天气 不错 , 适合 出去 游玩'}
给定一张图像,可以使用以下代码片段完成人像抠图(即去除背景): ![image](data/resource/portrait_input.png)
>>> 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](data/resource/portrait_output.png) 微调和评估也可以通过多几行代码完成,只需设置训练数据集和训练器,模型训练和评估的繁重工作已封装在 `trainer.train()` 和 `trainer.evaluate()` 接口的实现中。 例如,可以使用中文诗歌数据集微调 gpt3 基础模型(1.3B),得到一个可用于中文诗歌生成的模型。
>>> 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 库? 1. **统一简洁的用户接口**:针对不同任务和不同模型抽象了统一简洁的用户界面。模型推理和训练分别只需 3 行和 10 行代码即可实现。这方便用户在 ModelScope 社区中探索不同领域的模型。所有集成到 ModelScope 的模型都立即可用,使得在教育和工业环境中入门 AI 变得容易。 2. **以模型为中心**:ModelScope 提供以模型为中心的开发和应用体验。它简化了模型训练、推理、导出和部署的支持,并方便用户基于 ModelScope 生态系统构建自己的 MLOps。 3. **模块化设计**:对于模型推理和训练过程,采用模块化设计,并提供了丰富的功能模块实现,方便用户自定义自己的模型推理、训练等流程。 4. **丰富的训练策略**:对于分布式模型训练,尤其是大模型,提供了丰富的训练策略支持,包括数据并行、模型并行、混合并行等。 # 安装 ## Docker ModelScope 库目前支持用于模型训练和推理的主流深度学习框架,包括 PyTorch、TensorFlow 和 ONNX。所有版本都在 Python 3.7+、Pytorch 1.8+、Tensorflow1.15 或 Tensorflow2.0+ 上进行测试和运行。 为了让用户开箱即用地使用 ModelScope 上的所有模型,我们为所有版本提供了官方 Docker 镜像。基于 Docker 镜像,开发者可以跳过所有环境安装和配置,直接使用。目前,最新的 CPU 镜像和 GPU 镜像可以从以下地址获取: **CPU Docker 镜像:**
# 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 镜像:**
# 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
## 设置本地 Python 环境 您也可以使用 pip 和 conda 设置本地 ModelScope 环境。ModelScope 支持 python3.7 及以上版本。我们建议使用 [anaconda](https://docs.anaconda.com/anaconda/install/) 创建本地 python 环境:
conda create -n modelscope python=3.8
conda activate modelscope
PyTorch 或 TensorFlow 可以根据每个模型的要求单独安装。 * 安装 pytorch [文档](https://pytorch.org/get-started/locally/) * 安装 tensorflow [文档](https://www.tensorflow.org/install/pip) 安装必要的机器学习框架后,可以按如下方式安装 modelscope 库: 如果您只想试用 modelscope 框架或尝试模型/数据集下载,可以安装核心 modelscope 组件:
pip install modelscope
如果您想使用多模态模型:
pip install modelscope[multi-modal]
如果您想使用 NLP 模型:
pip install modelscope[nlp] -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
如果您想使用 CV 模型:
pip install modelscope[cv] -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
如果您想使用科学模型:
pip install modelscope[science] -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
**注意:** 1. 目前,一些音频任务模型仅支持 python3.7、tensorflow1.15.4 Linux 环境。大多数其他模型可以在 Windows 和 Mac (x86) 上安装和使用。 2. 音频领域的某些模型使用第三方库 SoundFile 进行 wav 文件处理。在 Linux 系统上,用户需要手动安装 SoundFile 的 libsndfile([文档链接](https://github.com/bastibe/python-soundfile#installation))。在 Windows 和 MacOS 上,它将自动安装,无需用户操作。例如,在 Ubuntu 上,可以使用以下命令: ```shell sudo apt-get update sudo apt-get install libsndfile1 ``` 3. 计算机视觉中的某些模型需要 mmcv-full,您可以参考 mmcv [安装指南](https://github.com/open-mmlab/mmcv#installation),一个最小安装如下: ```shell pip uninstall mmcv # 如果你已经安装了 mmcv,卸载它 pip install -U openmim mim install mmcv-full ``` # 了解更多 我们提供额外的文档,包括: * [更详细的安装指南](https://modelscope.cn/docs/%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85) * [任务介绍](https://modelscope.cn/docs/%E4%BB%BB%E5%8A%A1%E7%9A%84%E4%BB%8B%E7%BB%8D) * [使用 pipeline 进行模型推理](https://modelscope.cn/docs/%E6%A8%A1%E5%9E%8B%E7%9A%84%E6%8E%A8%E7%90%86Pipeline) * [微调示例](https://modelscope.cn/docs/%E6%A8%A1%E5%9E%8B%E7%9A%84%E8%AE%AD%E7%BB%83Train) * [数据预处理](https://modelscope.cn/docs/%E6%95%B0%E6%8D%AE%E7%9A%84%E9%A2%84%E5%A4%84%E7%90%86) * [评估](https://modelscope.cn/docs/%E6%A8%A1%E5%9E%8B%E7%9A%84%E8%AF%84%E4%BC%B0) * [向 ModelScope 贡献您自己的模型](https://modelscope.cn/docs/ModelScope%E6%A8%A1%E5%9E%8B%E6%8E%A5%E5%85%A5%E6%B5%81%E7%A8%8B%E6%A6%82%E8%A7%88) # 许可证 本项目采用 [Apache 许可证(版本 2.0)](https://github.com/modelscope/modelscope/blob/master/LICENSE)。 # 引用
@Misc{modelscope,
  title = {ModelScope: bring the notion of Model-as-a-Service to life.},
  author = {The ModelScope Team},
  howpublished = {\url{https://github.com/modelscope/modelscope}},
  year = {2023}
}
17 次点击  ∙  0 人收藏  
登录后收藏  
0 条回复
关于 ·  帮助 ·  PING ·  隐私 ·  条款   
OA0 - Omni AI 0 一个探索 AI 的社区
沪ICP备2024103595号-2
耗时 13 ms
Developed with Cursor