Skip to main content

A simple modelscope client for Python.

Project description

shiertier_modelscope

English | 中文

Introduction

shiertier_modelscope is a Python client for interacting with the ModelScope platform. It provides a simple interface for downloading and uploading models, with support for automatic login using environment variables. This library is designed to streamline the process of managing models on ModelScope.

Installation

You can install shiertier_modelscope via pip:

pip install git+https://github.com/shiertier/shiertier_modelscope.git

Please note that this project is still under development.

Usage

Downloading Models

You can download models from ModelScope using the download method. This method requires the repository name and the directory where the model files should be saved. You can also specify a specific file to download using the file_path parameter. Downloading models from public repositories does not require a token.

from shiertier_modelscope import easy_modelscope

# Download the entire repository
easy_modelscope.download(repo_name='my_public_model_repo', save_dir='path/to/save_directory')

# Download a specific file from the repository
easy_modelscope.download(repo_name='my_public_model_repo', save_dir='path/to/save_directory', file_path='path/to/file_in_repo')

# Download from a private repository (requires token)
client = ModelScopeClient(MODELSCOPE_TOKEN='your_token_here')
client.download(repo_name='my_private_model_repo', save_dir='path/to/save_directory')

Uploading Models

You can upload models to ModelScope using the upload_models method. This method requires the local directory containing the model files and the repository name. Note that uploading models requires a valid token.

from shiertier_modelscope import ModelScopeClient

# Initialize with a token
client = ModelScopeClient(MODELSCOPE_TOKEN='your_token_here')

# Upload models
client.upload_models(model_dir='path/to/model_directory', repo_name='my_model_repo')

Initialization

To use the ModelScopeClient, you need to initialize it with your ModelScope token. If the token is not provided during initialization, it will attempt to retrieve it from the MODELSCOPE_TOKEN environment variable.

from shiertier_modelscope import ModelScopeClient, easy_modelscope

# Initialize with a token
client = ModelScopeClient(MODELSCOPE_TOKEN='your_token_here')

# Or use the easy_modelscope shortcut
# easy_modelscope

Environment Variables

  • MODELSCOPE_TOKEN: The token used for authentication with the ModelScope platform. If not provided during initialization, the client will attempt to retrieve it from this environment variable.

Dependencies

  • modelscope

License

This project is released under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shiertier_modelscope-0.0.3.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shiertier_modelscope-0.0.3-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file shiertier_modelscope-0.0.3.tar.gz.

File metadata

  • Download URL: shiertier_modelscope-0.0.3.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for shiertier_modelscope-0.0.3.tar.gz
Algorithm Hash digest
SHA256 748855455072c1c5b8af536124e01851928e2ca4821bab230d5eb545c4c8c9c4
MD5 53f005cba5b0c1df514498a69cc8941b
BLAKE2b-256 59f94fb6ca60cae69f1cef102d005034ee98051c90287c0ec384570ae509d9f7

See more details on using hashes here.

File details

Details for the file shiertier_modelscope-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for shiertier_modelscope-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 382aecf99c3b0853a95e6ed2407e3780be01d3d2e10ef638543b7def71dd983a
MD5 9b06a8834c9b7eb00477eb645ff8207e
BLAKE2b-256 724a5d64202a26c1bc0aed2d96afb4c2b6c25dfa0fcf19c715fe22ddd22ce9af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page