sssssungk commited on
Commit
d59198b
·
verified ·
1 Parent(s): 18d9abd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -117,8 +117,8 @@ def real_fake_check(list_dir, path, model):
117
  prob = {}
118
  for i in list_dir: # real / fake 선택
119
  input_data = extract_mfcc_path(os.path.join(path, i))
120
- #input_data = torch.tensor(input_data).unsqueeze(0).to('cuda') # 배치 차원을 추가하여 (1, input_dim, sequence_length)로 맞춤
121
- input_data = torch.tensor(input_data).unsqueeze(0).to('cpu')
122
  result = model(input_data.float())
123
  probabilities = F.softmax(result, dim=1)
124
  prob[i]='%.2f'%probabilities[0][1].item()
@@ -140,8 +140,8 @@ def main(file_name):
140
 
141
  hf_token = os.getenv("HUGGINGFACE_TOKEN")
142
  pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1",use_auth_token=hf_token)
143
- #device = torch.device('cuda:0') if torch.cuda.is_available() else torch.device('cpu')
144
- device = torch.device('cpu')
145
 
146
  video_file = file_name #deepfake #meganfox.mp4'
147
  #current_path = os.getcwd()
@@ -161,7 +161,7 @@ def main(file_name):
161
  # 모델
162
  model_name = hf_hub_download(repo_id="sssssungk/deepfake_voice", filename="deepvoice_model_girl.pth")
163
  model = DeepVoiceModel(input_dim, hidden_dim, num_classes, dropout_rate, l2_reg).to(device)
164
- model.load_state_dict(torch.load(model_name, map_location=torch.device('cpu')))
165
  model.eval() # 평가 모드로 설정
166
 
167
 
 
117
  prob = {}
118
  for i in list_dir: # real / fake 선택
119
  input_data = extract_mfcc_path(os.path.join(path, i))
120
+ input_data = torch.tensor(input_data).unsqueeze(0).to('cuda') # 배치 차원을 추가하여 (1, input_dim, sequence_length)로 맞춤
121
+ #input_data = torch.tensor(input_data).unsqueeze(0).to('cpu')
122
  result = model(input_data.float())
123
  probabilities = F.softmax(result, dim=1)
124
  prob[i]='%.2f'%probabilities[0][1].item()
 
140
 
141
  hf_token = os.getenv("HUGGINGFACE_TOKEN")
142
  pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1",use_auth_token=hf_token)
143
+ device = torch.device('cuda:0') if torch.cuda.is_available() else torch.device('cpu')
144
+ #device = torch.device('cpu')
145
 
146
  video_file = file_name #deepfake #meganfox.mp4'
147
  #current_path = os.getcwd()
 
161
  # 모델
162
  model_name = hf_hub_download(repo_id="sssssungk/deepfake_voice", filename="deepvoice_model_girl.pth")
163
  model = DeepVoiceModel(input_dim, hidden_dim, num_classes, dropout_rate, l2_reg).to(device)
164
+ model.load_state_dict(torch.load(model_name))#, map_location=torch.device('cpu')))
165
  model.eval() # 평가 모드로 설정
166
 
167