Spaces:
Runtime error
Runtime error
Update app.py
Browse files10 unmodified lines11121314151652 unmodified lines69707172737475767743 unmodified lines121122123124125126127128100 unmodified lines22923023123223323410 unmodified linesimport reimport requestsimport time# Import necessary functions and classesfrom utils import load_t5, load_clap52 unmodified linesglobal global_model, current_model_nameif global_model is not None:del global_modeltorch.cuda.empty_cache()global_model = Nonecurrent_model_name = Nonedef load_model(model_name, device, model_url=None):global global_model, current_model_name43 unmodified linesload_time = end_time - start_timereturn f"Successfully loaded model: {model_name} in {load_time:.2f} seconds"except Exception as e:global_model = Nonecurrent_model_name = Noneprint(f"Error loading model {model_name}: {str(e)}")return f"Failed to load model: {model_name}. Error: {str(e)}"100 unmodified linesall_waveforms.append(waveform)# Concatenate all waveformsfinal_waveform = np.concatenate(all_waveforms)10 unmodified lines1112131415161752 unmodified lines7071727374757677787943 unmodified lines123124125126127128129100 unmodified lines23023123223323423523623723823924010 unmodified linesimport reimport requestsimport timeimport gc# Import necessary functions and classesfrom utils import load_t5, load_clap52 unmodified linesglobal global_model, current_model_nameif global_model is not None:del global_modelglobal_model = Nonecurrent_model_name = Nonetorch.cuda.empty_cache()gc.collect()def load_model(model_name, device, model_url=None):global global_model, current_model_name43 unmodified linesload_time = end_time - start_timereturn f"Successfully loaded model: {model_name} in {load_time:.2f} seconds"except Exception as e:unload_current_model()print(f"Error loading model {model_name}: {str(e)}")return f"Failed to load model: {model_name}. Error: {str(e)}"100 unmodified linesall_waveforms.append(waveform)# Clear some memory after each segmentdel images, latents, mel_spectrogram, x_itorch.cuda.empty_cache()gc.collect()# Concatenate all waveformsfinal_waveform = np.concatenate(all_waveforms)
app.py+9-3