{"id":2591,"library":"modelscope","title":"ModelScope","description":"ModelScope is an open-source model-as-a-service (MaaS) platform from Alibaba Damo Academy, providing a wide range of AI models (vision, NLP, audio, multimodal) for easy deployment and use. It abstracts complex AI model inference into a simple API and offers functionalities for model discovery, download, and fine-tuning. The library is actively developed, with its current version at 1.35.3 and frequent releases.","status":"active","version":"1.35.3","language":"en","source_language":"en","source_url":"https://github.com/modelscope/modelscope","tags":["AI","ML","models","modelhub","inference","nlp","cv","audio","multimodal","alibaba"],"install":[{"cmd":"pip install modelscope","lang":"bash","label":"Base Installation"},{"cmd":"pip install 'modelscope[cv]' # For computer vision tasks\npip install 'modelscope[nlp]' # For natural language processing tasks\npip install 'modelscope[audio]' # For audio tasks","lang":"bash","label":"With Task-Specific Dependencies (Optional)"}],"dependencies":[{"reason":"Core dependency for many NLP models and a common source of compatibility issues, as addressed in multiple releases.","package":"transformers","optional":false},{"reason":"Crucial for dataset handling and the `ms_dataset` module, with significant refactoring to support 4.x versions.","package":"datasets","optional":false},{"reason":"Often required as the deep learning backend for many models.","package":"torch","optional":true},{"reason":"Can be an alternative deep learning backend for some models.","package":"tensorflow","optional":true}],"imports":[{"symbol":"pipeline","correct":"from modelscope.pipelines import pipeline"},{"symbol":"Tasks","correct":"from modelscope.utils.constant import Tasks"},{"symbol":"snapshot_download","correct":"from modelscope.hub.snapshot_download import snapshot_download"},{"symbol":"Model","correct":"from modelscope.models import Model"},{"note":"The dataset module was refactored, use `msdatasets`.","wrong":"from modelscope.datasets import MsDataset","symbol":"MsDataset","correct":"from modelscope.msdatasets import MsDataset"}],"quickstart":{"code":"import os\nfrom modelscope.pipelines import pipeline\nfrom modelscope.utils.constant import Tasks\n\n# Initialize an image classification pipeline\nclassifier = pipeline(task=Tasks.image_classification, model='damo/cv_resnest50_image-classification_damo')\n\n# Example input image URL\nimage_url = 'https://modelscope.cn/api/v1/models/damo/cv_resnest50_image-classification_damo/repo/files/animal.JPEG'\n\n# Perform inference\nresult = classifier(image_url)\nprint(f\"Image classification result: {result}\")\n\n# You can also download a model first\n# from modelscope.hub.snapshot_download import snapshot_download\n# model_dir = snapshot_download('damo/cv_resnest50_image-classification_damo')\n# local_classifier = pipeline(task=Tasks.image_classification, model=model_dir)\n# print(f\"Local inference result: {local_classifier(image_url)}\")","lang":"python","description":"This quickstart demonstrates how to use ModelScope to perform image classification using a pre-trained model. It initializes a `pipeline` for a specific task and model, then processes an input image from a URL. Models are automatically downloaded and cached locally upon first use. For tasks requiring authentication (e.g., uploading to the Hub or accessing private models), ensure your ModelScope token is set via `os.environ['MS_TOKEN']` or passed explicitly."},"warnings":[{"fix":"Upgrade `datasets` to >=4.0.0 and review usage of `modelscope.msdatasets` for API changes. For example, `from modelscope.datasets` changed to `from modelscope.msdatasets`.","message":"The `ms_dataset` module underwent significant refactoring to align with `datasets` library 4.x. If you're using dataset functionalities, ensure your `datasets` library is updated to version 4.0 or above, or fix potential breaking changes in your code.","severity":"breaking","affected_versions":">=1.35.0"},{"fix":"Avoid using these methods. If repository deletion is critical, consult ModelScope documentation for alternative, authenticated methods or use the web interface.","message":"For security reasons, `delete_repo`, `delete_model`, and `delete_dataset` methods within the `HubApi` have been temporarily deprecated. Calling these methods will now issue a `DeprecationWarning`.","severity":"deprecated","affected_versions":">=1.34.0"},{"fix":"Explicitly pass the `token` parameter to `HubApi` methods or `pipeline` initializations if you wish to override tokens set in environment variables or instance attributes.","message":"Hub API authentication token priority changed in v1.34.0. The token priority is now: function parameter > instance attribute > environment variable (`MS_TOKEN`). Be explicit if your application relies on a specific token source.","severity":"gotcha","affected_versions":">=1.34.0"},{"fix":"Upgrade to ModelScope v1.35.1 or later, which includes fixes for these dependency issues. Ensure `packaging` and `oss2` are correctly installed if needed for specific functionalities (e.g., cloud storage interaction).","message":"Users encountering `ModuleNotFoundError` for `packaging` or issues with `oss2` (e.g., global import conflicts) in versions prior to 1.35.1 might experience unexpected runtime errors or installation failures.","severity":"gotcha","affected_versions":"<1.35.1"},{"fix":"Upgrade to ModelScope v1.34.0 or later, which includes a refactored OSS utility with automatic temporary credential refresh. This ensures dataset downloads can complete without interruption due to token expiration.","message":"Long-running dataset downloads using OSS (Object Storage Service) previously suffered from STS token expiration issues. This has been addressed, but older versions might still be susceptible.","severity":"gotcha","affected_versions":"<1.34.0"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}