nisten commited on
Commit
cf68626
·
verified ·
1 Parent(s): f21fe07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -4,7 +4,7 @@ import soundfile as sf
4
  from snac import SNAC
5
  from transformers import AutoTokenizer, AutoModelForCausalLM
6
 
7
- device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
8
 
9
  def find_last_instance_of_separator(lst, element=50258):
10
  reversed_list = lst[::-1]
@@ -55,7 +55,7 @@ def reconstruct_tensors(flattened_output):
55
  tensor2.append(flattened_output[i+5])
56
  tensor3.append(flattened_output[i+6])
57
  tensor3.append(flattened_output[i+7])
58
- codes = [list_to_torch_tensor(tensor1).to(device), list_to_torch_tensor(tensor2).to(device), list_to_torch_tensor(tensor3).to(device)]
59
 
60
  if n_tensors == 15:
61
  for i in range(0, len(flattened_output), 16):
@@ -74,7 +74,7 @@ def reconstruct_tensors(flattened_output):
74
  tensor3.append(flattened_output[i+13])
75
  tensor4.append(flattened_output[i+14])
76
  tensor4.append(flattened_output[i+15])
77
- codes = [list_to_torch_tensor(tensor1).to(device), list_to_torch_tensor(tensor2).to(device), list_to_torch_tensor(tensor3).to(device), list_to_torch_tensor(tensor4).to(device)]
78
 
79
  return codes
80
 
@@ -117,4 +117,4 @@ iface = gr.Interface(
117
  )
118
 
119
  if __name__ == "__main__":
120
- iface.launch()
 
4
  from snac import SNAC
5
  from transformers import AutoTokenizer, AutoModelForCausalLM
6
 
7
+ device = torch.device("cpu") # Changed to CPU mode
8
 
9
  def find_last_instance_of_separator(lst, element=50258):
10
  reversed_list = lst[::-1]
 
55
  tensor2.append(flattened_output[i+5])
56
  tensor3.append(flattened_output[i+6])
57
  tensor3.append(flattened_output[i+7])
58
+ codes = [list_to_torch_tensor(tensor1), list_to_torch_tensor(tensor2), list_to_torch_tensor(tensor3)]
59
 
60
  if n_tensors == 15:
61
  for i in range(0, len(flattened_output), 16):
 
74
  tensor3.append(flattened_output[i+13])
75
  tensor4.append(flattened_output[i+14])
76
  tensor4.append(flattened_output[i+15])
77
+ codes = [list_to_torch_tensor(tensor1), list_to_torch_tensor(tensor2), list_to_torch_tensor(tensor3), list_to_torch_tensor(tensor4)]
78
 
79
  return codes
80
 
 
117
  )
118
 
119
  if __name__ == "__main__":
120
+ iface.launch(share=True)