dwb2023 commited on
Commit
35c87e9
·
verified ·
1 Parent(s): 755f3a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -12
app.py CHANGED
@@ -21,21 +21,14 @@ YT_LENGTH_LIMIT_S = 4800 # 1 hour 20 minutes
21
 
22
  device = 0 if torch.cuda.is_available() else "cpu"
23
 
24
-
25
- # Quantization
26
- bnb_config=BitsAndBytesConfig(
27
- load_in_4bit=True
28
- )
29
 
30
  # Load the model
31
- model = WhisperForConditionalGeneration.from_pretrained(
32
- MODEL_NAME, load_in_4bit=True, device_map="auto"
33
- )
34
-
35
- tokenizer = WhisperTokenizer.from_pretrained(MODEL_NAME)
36
 
37
- # Initialize the pipeline with the quantized model
38
- pipe = pipeline(task="automatic-speech-recognition", model=model, tokenizer=tokenizer, chunk_length_s=30, device=device)
39
 
40
  # Define paths and create directory if not exists
41
  JSON_DATASET_DIR = Path("json_dataset")
 
21
 
22
  device = 0 if torch.cuda.is_available() else "cpu"
23
 
24
+ # Load model with bitsandbytes quantization
25
+ bnb_config = BitsAndBytesConfig(load_in_4bit=True)
 
 
 
26
 
27
  # Load the model
28
+ model = model_class.from_pretrained(model_name, config=bnb_config)
 
 
 
 
29
 
30
+ # bnb_config = bnb.QuantizationConfig(bits=4)
31
+ pipe = pipeline(task="automatic-speech-recognition", model=model, chunk_length_s=30, device=device)
32
 
33
  # Define paths and create directory if not exists
34
  JSON_DATASET_DIR = Path("json_dataset")