@@ -120,10 +120,11 @@ def inference_patch(self, model, period, composer, instrumentation,
120
120
nota_model_path = os .path .join (self .nota_model_path , model )
121
121
if self .model_cache is None :
122
122
checkpoint = torch .load (nota_model_path , map_location = torch .device (self .device ))
123
- self .model_cache = checkpoint
124
- else :
125
- checkpoint = self .model_cache
126
- nota_model .load_state_dict (checkpoint ['model' ])
123
+ NotaGenRun .model_cache = checkpoint
124
+ del checkpoint
125
+ torch .cuda .empty_cache ()
126
+
127
+ nota_model .load_state_dict (self .model_cache ['model' ])
127
128
nota_model = nota_model .to (self .device )
128
129
nota_model .eval ()
129
130
@@ -338,9 +339,8 @@ def inference_patch(self, model, period, composer, instrumentation,
338
339
if unload_model :
339
340
del patchilizer
340
341
del nota_model
341
- del checkpoint
342
+ NotaGenRun . model_cache = None
342
343
torch .cuda .empty_cache ()
343
- self .model_cache = None
344
344
345
345
return (
346
346
audio ,
@@ -352,9 +352,9 @@ def inference_patch(self, model, period, composer, instrumentation,
352
352
if unload_model :
353
353
del patchilizer
354
354
del nota_model
355
- del checkpoint
355
+ NotaGenRun . model_cache = None
356
356
torch .cuda .empty_cache ()
357
- self . model_cache = None
357
+
358
358
print (f".abc and .xml was saved to { INTERLEAVED_OUTPUT_FOLDER } and { ORIGINAL_OUTPUT_FOLDER } " )
359
359
raise Exception ("Conversion of .mp3 and .png failed, try again or check if MuseScore4 installation was successful." )
360
360
0 commit comments