Update README.md
Browse files
README.md
CHANGED
@@ -28,6 +28,27 @@ Trained on RTX 3070 for 30 hours using SwissDial all Dialects with following gui
|
|
28 |
|
29 |
## Uses
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
from transformers import AutomaticSpeechRecognitionPipeline
|
32 |
import torch
|
33 |
pipe = AutomaticSpeechRecognitionPipeline(model=model, tokenizer=tokenizer, feature_extractor=feature_extractor)
|
|
|
28 |
|
29 |
## Uses
|
30 |
|
31 |
+
|
32 |
+
from peft import PeftModel, PeftConfig
|
33 |
+
from transformers import WhisperForConditionalGeneration, Seq2SeqTrainer
|
34 |
+
|
35 |
+
peft_model_id = "Flurin17/whisper-large-v3-peft-swiss-german" # Use the same model ID as before.
|
36 |
+
peft_config = PeftConfig.from_pretrained(peft_model_id)
|
37 |
+
model = WhisperForConditionalGeneration.from_pretrained(
|
38 |
+
peft_config.base_model_name_or_path, load_in_8bit=True, device_map="auto"
|
39 |
+
)
|
40 |
+
model = PeftModel.from_pretrained(model, peft_model_id)
|
41 |
+
model.config.use_cache = True
|
42 |
+
|
43 |
+
|
44 |
+
from transformers import WhisperFeatureExtractor
|
45 |
+
|
46 |
+
feature_extractor = WhisperFeatureExtractor.from_pretrained(peft_model_id)
|
47 |
+
|
48 |
+
from transformers import WhisperTokenizer
|
49 |
+
|
50 |
+
tokenizer = WhisperTokenizer.from_pretrained(peft_model_id, language=language, task=task)
|
51 |
+
|
52 |
from transformers import AutomaticSpeechRecognitionPipeline
|
53 |
import torch
|
54 |
pipe = AutomaticSpeechRecognitionPipeline(model=model, tokenizer=tokenizer, feature_extractor=feature_extractor)
|