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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
748855455072c1c5b8af536124e01851928e2ca4821bab230d5eb545c4c8c9c4
|
|
| MD5 |
53f005cba5b0c1df514498a69cc8941b
|
|
| BLAKE2b-256 |
59f94fb6ca60cae69f1cef102d005034ee98051c90287c0ec384570ae509d9f7
|
File details
Details for the file shiertier_modelscope-0.0.3-py3-none-any.whl.
File metadata
- Download URL: shiertier_modelscope-0.0.3-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
382aecf99c3b0853a95e6ed2407e3780be01d3d2e10ef638543b7def71dd983a
|
|
| MD5 |
9b06a8834c9b7eb00477eb645ff8207e
|
|
| BLAKE2b-256 |
724a5d64202a26c1bc0aed2d96afb4c2b6c25dfa0fcf19c715fe22ddd22ce9af
|