torsh-hub
Model hub integration for ToRSh, providing easy access to pre-trained models and datasets.
Overview
ToRSh Hub is a repository of pre-trained models that facilitates research reproducibility. It provides:
- Model Repository: Access to pre-trained models
- Easy Loading: Simple API to load models with weights
- Model Cards: Detailed information about each model
- Version Control: Model versioning and updates
- Caching: Local caching for offline use
Usage
Loading Pre-trained Models
use *;
// Load a pre-trained ResNet model
let model = load?;
// Load with specific revision
let model = load_with_config?;
// Load from URL
let model = load_state_dict_from_url?;
Model Discovery
// List available models
let models = list_models?;
for model in models
// Get model info
let info = get_model_info?;
println!;
println!;
Publishing Models
use *;
// Create model card
let model_card = new
.name
.description
.task
.dataset
.metrics
.add_tag
.add_tag;
// Publish model
publish?;
Custom Model Registry
// Define custom model
// Register with hub
;
// Now loadable via hub
let model = load?;
Model Configuration
use *;
// Load model with configuration
let config = from_pretrained?;
let model = from_config?;
// Modify configuration
let mut config = default;
config.num_classes = 100;
config.dropout = 0.5;
let model = from_config?;
Caching and Offline Mode
// Set cache directory
set_dir?;
// Download for offline use
download?;
// Use in offline mode
set_offline_mode;
let model = load?; // Uses cache
Integration with HuggingFace Hub
// Load from HuggingFace
let model = from_huggingface?;
// Convert and upload
let torch_model = load_pytorch_model?;
let torsh_model = convert_from_pytorch?;
push_to_huggingface?;
Model Versioning
// Load specific version
let model_v1 = load?;
let model_latest = load?;
// Update model
update_model?;
Model Zoo
use *;
// Vision models
let resnet = resnet50?;
let efficientnet = efficientnet_b0?;
let vit = vit_base_patch16_224?;
// NLP models
let bert = bert_base_uncased?;
let gpt2 = gpt2_small?;
// Audio models
let wav2vec = wav2vec2_base?;
Security and Verification
// Verify model integrity
let verification = verify_model?;
assert!;
assert!;
// Load with security checks
let model = load_secure?;
Environment Variables
TORSH_HUB_DIR: Override default cache directoryTORSH_HUB_OFFLINE: Enable offline modeTORSH_HUB_TOKEN: Authentication token for private models
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.