Namkoy commited on
Commit
aa013f1
1 Parent(s): b0e9f31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -10,6 +10,7 @@ from transformers import (
10
  from peft import PeftModel, PeftConfig
11
 
12
  os.environ["CUDA_VISIBLE_DEVICES"] = "0"
 
13
 
14
  peft_model_id = "Namkoy/whisper_peft_vi_nam"
15
  language = "vietnamese"
@@ -17,7 +18,7 @@ task = "transcribe"
17
  peft_config = PeftConfig.from_pretrained(peft_model_id)
18
  model = WhisperForConditionalGeneration.from_pretrained(
19
  peft_config.base_model_name_or_path, load_in_8bit=True, device_map="auto"
20
- )
21
 
22
  model = PeftModel.from_pretrained(model, peft_model_id)
23
  tokenizer = WhisperTokenizer.from_pretrained(peft_config.base_model_name_or_path, language=language, task=task)
 
10
  from peft import PeftModel, PeftConfig
11
 
12
  os.environ["CUDA_VISIBLE_DEVICES"] = "0"
13
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
14
 
15
  peft_model_id = "Namkoy/whisper_peft_vi_nam"
16
  language = "vietnamese"
 
18
  peft_config = PeftConfig.from_pretrained(peft_model_id)
19
  model = WhisperForConditionalGeneration.from_pretrained(
20
  peft_config.base_model_name_or_path, load_in_8bit=True, device_map="auto"
21
+ ).to(device)
22
 
23
  model = PeftModel.from_pretrained(model, peft_model_id)
24
  tokenizer = WhisperTokenizer.from_pretrained(peft_config.base_model_name_or_path, language=language, task=task)