Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
978 B
9
Indexable
import torch
import torch.nn as nn
import torch.nn.functional as F
import os
from thop import profile
import torch
from transformers import AutoFeatureExtractor, WhisperModel, WhisperForConditionalGeneration
from datasets import load_dataset

model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny")
feature_extractor = AutoFeatureExtractor.from_pretrained("openai/whisper-tiny")
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
inputs = feature_extractor(ds[0]["audio"]["array"], return_tensors="pt")
input_features = inputs.input_features
decoder_input_ids = torch.tensor([[1, 1]]) * model.config.decoder_start_token_id
# last_hidden_state = model(input_features, decoder_input_ids=decoder_input_ids).last_hidden_state
# out = model(input_features, decoder_input_ids=decoder_input_ids)
macs, params = profile(model(input_features, decoder_input_ids=decoder_input_ids), inputs=(input_features,decoder_input_ids))
Leave a Comment