jhtonyKoo commited on
Commit
9e8da41
1 Parent(s): 94583f1

modify app

Browse files
Files changed (2) hide show
  1. app.py +8 -1
  2. inference.py +3 -49
app.py CHANGED
@@ -161,8 +161,10 @@ with gr.Blocks() as demo:
161
  title="ITO Loss Curve",
162
  x_title="Step",
163
  y_title="Loss",
164
- height=400,
165
  width=600,
 
 
166
  )
167
  ito_log = gr.Textbox(label="ITO Log", lines=10)
168
 
@@ -187,6 +189,11 @@ with gr.Blocks() as demo:
187
  final_log = log
188
  loss_df = loss_data
189
 
 
 
 
 
 
190
  return final_audio, final_params, final_log, loss_df
191
 
192
  ito_button.click(
 
161
  title="ITO Loss Curve",
162
  x_title="Step",
163
  y_title="Loss",
164
+ height=300,
165
  width=600,
166
+ x_series_axis=gr.LinePlot.XAxisType.INTEGER,
167
+ y_lim=[None, None],
168
  )
169
  ito_log = gr.Textbox(label="ITO Log", lines=10)
170
 
 
189
  final_log = log
190
  loss_df = loss_data
191
 
192
+ # Update y_lim based on the actual min and max values
193
+ y_min = loss_df['loss'].min()
194
+ y_max = loss_df['loss'].max()
195
+ ito_loss_plot.update(y_lim=[y_min, y_max])
196
+
197
  return final_audio, final_params, final_log, loss_df
198
 
199
  ito_button.click(
inference.py CHANGED
@@ -109,7 +109,7 @@ class MasteringStyleTransfer:
109
  if step == 0:
110
  initial_params = current_params
111
  top_5_diff = self.get_top_n_diff_string(initial_params, current_params, top_n=5)
112
- log_entry = f"Step {step + 1}, Loss: {total_loss.item():.4f}\n{top_5_diff}\n"
113
 
114
  if divergence_counter >= 10:
115
  print(f"Optimization stopped early due to divergence at step {step}")
@@ -166,52 +166,6 @@ class MasteringStyleTransfer:
166
 
167
  return output_audio, predicted_params, self.args.sample_rate
168
 
169
- def print_param_difference(self, initial_params, ito_params):
170
- all_diffs = []
171
-
172
- print("\nAll parameter differences:")
173
- for fx_name in initial_params.keys():
174
- print(f"\n{fx_name.upper()}:")
175
- if isinstance(initial_params[fx_name], dict):
176
- for param_name in initial_params[fx_name].keys():
177
- initial_value = initial_params[fx_name][param_name]
178
- ito_value = ito_params[fx_name][param_name]
179
-
180
- # Calculate normalized difference
181
- param_range = self.mastering_converter.fx_processors[fx_name].param_ranges[param_name]
182
- normalized_diff = abs((ito_value - initial_value) / (param_range[1] - param_range[0]))
183
-
184
- all_diffs.append((fx_name, param_name, initial_value, ito_value, normalized_diff))
185
-
186
- print(f" {param_name}:")
187
- print(f" Initial: {initial_value.item():.4f}")
188
- print(f" ITO: {ito_value.item():.4f}")
189
- print(f" Normalized Diff: {normalized_diff.item():.4f}")
190
- else:
191
- initial_value = initial_params[fx_name]
192
- ito_value = ito_params[fx_name]
193
-
194
- # For 'imager', assume range is 0 to 1
195
- normalized_diff = abs(ito_value - initial_value)
196
-
197
- all_diffs.append((fx_name, 'width', initial_value, ito_value, normalized_diff))
198
-
199
- print(f" width:")
200
- print(f" Initial: {initial_value.item():.4f}")
201
- print(f" ITO: {ito_value.item():.4f}")
202
- print(f" Normalized Diff: {normalized_diff.item():.4f}")
203
-
204
- # Sort differences by normalized difference and get top 10
205
- top_diffs = sorted(all_diffs, key=lambda x: x[4], reverse=True)[:10]
206
-
207
- print("\nTop 10 parameter differences (sorted by normalized difference):")
208
- for fx_name, param_name, initial_value, ito_value, normalized_diff in top_diffs:
209
- print(f"{fx_name.upper()} - {param_name}:")
210
- print(f" Initial: {initial_value.item():.4f}")
211
- print(f" ITO: {ito_value.item():.4f}")
212
- print(f" Normalized Diff: {normalized_diff.item():.4f}")
213
- print()
214
-
215
  def print_predicted_params(self, predicted_params):
216
  if predicted_params is None:
217
  print("No predicted parameters available.")
@@ -273,9 +227,9 @@ class MasteringStyleTransfer:
273
 
274
  top_diffs = sorted(all_diffs, key=lambda x: x[4], reverse=True)[:top_n]
275
 
276
- output = [f"Top {top_n} parameter differences (initial / ITO / normalized diff):"]
277
  for fx_name, param_name, initial_value, ito_value, normalized_diff in top_diffs:
278
- output.append(f"{fx_name.upper()} - {param_name}: {initial_value:.3f} / {ito_value:.3f} / {normalized_diff:.3f}")
279
 
280
  return "\n".join(output)
281
 
 
109
  if step == 0:
110
  initial_params = current_params
111
  top_5_diff = self.get_top_n_diff_string(initial_params, current_params, top_n=5)
112
+ log_entry = f"Step {step + 1}\n Loss: {total_loss.item():.4f}\n{top_5_diff}\n"
113
 
114
  if divergence_counter >= 10:
115
  print(f"Optimization stopped early due to divergence at step {step}")
 
166
 
167
  return output_audio, predicted_params, self.args.sample_rate
168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  def print_predicted_params(self, predicted_params):
170
  if predicted_params is None:
171
  print("No predicted parameters available.")
 
227
 
228
  top_diffs = sorted(all_diffs, key=lambda x: x[4], reverse=True)[:top_n]
229
 
230
+ output = [f" Top {top_n} parameter differences (initial / ITO / normalized diff):"]
231
  for fx_name, param_name, initial_value, ito_value, normalized_diff in top_diffs:
232
+ output.append(f" {fx_name.upper()} - {param_name}: {initial_value:.3f} / {ito_value:.3f} / {normalized_diff:.3f}")
233
 
234
  return "\n".join(output)
235