Views
No views yet
model.py. The configuration is in config.json.model.py in your working directory.1from huggingface_hub import hf_hub_download
2import torch
3from model import VisionTransformer
4import json
5
6# Your repository ID
7repo_id = "heissanjay/vit-cifar10"
8
9# Download model files
10config_path = hf_hub_download(repo_id=repo_id, filename="config.json")
11model_path = hf_hub_download(repo_id=repo_id, filename="pytorch_model.bin")
12# You also need to download model.py or have it locally
13# hf_hub_download(repo_id=repo_id, filename="model.py")
14
15
16# Load config
17with open(config_path) as f:
18 config = json.load(f)
19
20# Instantiate model
21model = VisionTransformer(**config)
22model.load_state_dict(torch.load(model_path))
23
24# Now you can use the model for inference