jhtonyKoo commited on
Commit
b9bf35a
·
1 Parent(s): df67096

modify app

Browse files
Files changed (1) hide show
  1. app.py +11 -16
app.py CHANGED
@@ -112,16 +112,19 @@ def perform_ito(input_audio, reference_audio, ito_reference_audio, num_steps, op
112
 
113
  initial_reference_feature = mastering_transfer.get_reference_embedding(reference_tensor)
114
 
 
 
 
 
115
  ito_log = ""
116
  loss_values = []
117
- all_results = []
118
- for log_entry, current_output, current_params, step, loss in mastering_transfer.inference_time_optimization(
119
- input_tensor, ito_reference_tensor, ito_config, initial_reference_feature
120
- ):
121
- ito_log += log_entry
122
- ito_param_output = mastering_transfer.get_param_output_string(current_params)
123
- loss_values.append({"step": int(step), "loss": loss})
124
 
 
 
 
125
  # Convert current_output to numpy array if it's a tensor
126
  if isinstance(current_output, torch.Tensor):
127
  current_output = current_output.cpu().numpy()
@@ -139,15 +142,7 @@ def perform_ito(input_audio, reference_audio, ito_reference_audio, num_steps, op
139
  # Denormalize the audio to int16
140
  current_output = denormalize_audio(current_output, dtype=np.int16)
141
 
142
- all_results.append({
143
- 'step': step,
144
- 'audio': current_output,
145
- 'params': ito_param_output,
146
- 'log': log_entry,
147
- 'loss': loss
148
- })
149
-
150
- yield (args.sample_rate, current_output), ito_param_output, step, ito_log, pd.DataFrame(loss_values), all_results
151
 
152
  def update_ito_output(all_results, selected_step):
153
  print(all_results)
 
112
 
113
  initial_reference_feature = mastering_transfer.get_reference_embedding(reference_tensor)
114
 
115
+ all_results, min_loss_step = mastering_transfer.inference_time_optimization(
116
+ input_tensor, ito_reference_tensor, ito_config, initial_reference_feature
117
+ )
118
+
119
  ito_log = ""
120
  loss_values = []
121
+ for result in all_results:
122
+ ito_log += result['log']
123
+ loss_values.append({"step": result['step'], "loss": result['loss']})
 
 
 
 
124
 
125
+ current_output = result['audio']
126
+ ito_param_output = mastering_transfer.get_param_output_string(result['params'])
127
+
128
  # Convert current_output to numpy array if it's a tensor
129
  if isinstance(current_output, torch.Tensor):
130
  current_output = current_output.cpu().numpy()
 
142
  # Denormalize the audio to int16
143
  current_output = denormalize_audio(current_output, dtype=np.int16)
144
 
145
+ yield (args.sample_rate, current_output), ito_param_output, result['step'], ito_log, pd.DataFrame(loss_values), all_results
 
 
 
 
 
 
 
 
146
 
147
  def update_ito_output(all_results, selected_step):
148
  print(all_results)