Views
No views yet
1from transformers import AutoProcessor, Wav2Vec2BertForCTC
2import torch
3
4processor = AutoProcessor.from_pretrained("ghananlpcommunity/w2v-bert-2.0_twi_alpha_v1-pytorch-int8")
5model = Wav2Vec2BertForCTC.from_pretrained("ghananlpcommunity/w2v-bert-2.0_twi_alpha_v1-pytorch-int8", torch_dtype=torch.float32)
6model = torch.quantization.quantize_dynamic(model, {torch.nn.Linear}, dtype=torch.qint8)
7
8state_dict = torch.hub.load_state_dict_from_url(
9 f"https://huggingface.co/ghananlpcommunity/w2v-bert-2.0_twi_alpha_v1-pytorch-int8/resolve/main/quantized_model_int8.pt",
10 map_location="cpu",
11)
12model.load_state_dict(state_dict)
13model.eval()