asdrty123 commited on
Commit
cac8931
·
verified ·
1 Parent(s): f9f3c9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -10,6 +10,7 @@ import gradio as gr
10
  import librosa
11
  import torch
12
  from fairseq import checkpoint_utils
 
13
 
14
  from config import Config
15
  from lib.infer_pack.models import (
@@ -100,19 +101,17 @@ def model_data(model_name):
100
 
101
  def load_hubert():
102
  global hubert_model
103
- models, _, _ = checkpoint_utils.load_model_ensemble_and_task(
104
- ["hubert_base.pt"],
105
- suffix="",
106
- )
 
 
107
  hubert_model = models[0]
108
  hubert_model = hubert_model.to(config.device)
109
- if config.is_half:
110
- hubert_model = hubert_model.half()
111
- else:
112
- hubert_model = hubert_model.float()
113
  return hubert_model.eval()
114
 
115
-
116
  print("Loading hubert model...")
117
  hubert_model = load_hubert()
118
  print("Hubert model loaded.")
 
10
  import librosa
11
  import torch
12
  from fairseq import checkpoint_utils
13
+ from fairseq.data import dictionary
14
 
15
  from config import Config
16
  from lib.infer_pack.models import (
 
101
 
102
  def load_hubert():
103
  global hubert_model
104
+ safe_globals = [dictionary.Dictionary] # allow this class
105
+ with torch.serialization.safe_globals(safe_globals):
106
+ models, _, _ = checkpoint_utils.load_model_ensemble_and_task(
107
+ ["hubert_base.pt"],
108
+ suffix="",
109
+ )
110
  hubert_model = models[0]
111
  hubert_model = hubert_model.to(config.device)
112
+ hubert_model = hubert_model.half() if config.is_half else hubert_model.float()
 
 
 
113
  return hubert_model.eval()
114
 
 
115
  print("Loading hubert model...")
116
  hubert_model = load_hubert()
117
  print("Hubert model loaded.")