F5-TTS Unload model correct tab
This commit is contained in:
1 parent
88c97ea700
commit
1a5945235d
1 file changed
+26
-26
@@ -578,34 +578,34 @@ class tts_class:
|
|||||||
print(f"[{self.branding}ENG] \033[91mError loading model: {str(e)}\033[0m")
|
print(f"[{self.branding}ENG] \033[91mError loading model: {str(e)}\033[0m")
|
||||||
raise HTTPException(status_code=500, detail=f"Error loading model: {str(e)}")
|
raise HTTPException(status_code=500, detail=f"Error loading model: {str(e)}")
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
###############################
|
###############################
|
||||||
# CHANGE ME # Model unloading #
|
# CHANGE ME # Model unloading #
|
||||||
###############################
|
###############################
|
||||||
###############################
|
###############################
|
||||||
# This function will handle the UN-loading of your model, from VRAM/CUDA, System RAM or whatever.
|
# This function will handle the UN-loading of your model, from VRAM/CUDA, System RAM or whatever.
|
||||||
async def unload_model(self):
|
async def unload_model(self):
|
||||||
# ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
# ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
||||||
# ↑↑↑ Keep everything above this line ↑↑↑
|
# ↑↑↑ Keep everything above this line ↑↑↑
|
||||||
# ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
# ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
||||||
|
|
||||||
|
"""Unload the F5-TTS model from memory"""
|
||||||
|
if hasattr(self, 'model'):
|
||||||
|
del self.model
|
||||||
|
self.model = None
|
||||||
|
|
||||||
|
if hasattr(self, 'vocoder'):
|
||||||
|
del self.vocoder
|
||||||
|
self.vocoder = None
|
||||||
|
|
||||||
"""Unload the F5-TTS model from memory"""
|
if torch.cuda.is_available():
|
||||||
if hasattr(self, 'model'):
|
torch.cuda.empty_cache()
|
||||||
del self.model
|
|
||||||
self.model = None
|
|
||||||
|
|
||||||
if hasattr(self, 'vocoder'):
|
|
||||||
del self.vocoder
|
|
||||||
self.vocoder = None
|
|
||||||
|
|
||||||
if torch.cuda.is_available():
|
|
||||||
torch.cuda.empty_cache()
|
|
||||||
|
|
||||||
# ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
|
# ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
|
||||||
# ↓↓↓ Keep everything below this line ↓↓↓
|
# ↓↓↓ Keep everything below this line ↓↓↓
|
||||||
# ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
|
# ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
|
||||||
self.is_tts_model_loaded = False
|
self.is_tts_model_loaded = False
|
||||||
return None
|
return None
|
||||||
|
|
||||||
###################################################################################################################################
|
###################################################################################################################################
|
||||||
###################################################################################################################################
|
###################################################################################################################################
|
||||||
|
|||||||
Reference in new issue
Block a user