mirror of
https://github.com/w-okada/voice-changer.git
synced 2025-01-23 13:35:12 +03:00
WIP: multi
This commit is contained in:
parent
707096b48c
commit
e1e1f94fa3
@ -34,7 +34,6 @@ class MMVC_Rest_Fileuploader:
|
||||
json_compatible_item_data = jsonable_encoder(res)
|
||||
return JSONResponse(content=json_compatible_item_data)
|
||||
|
||||
# def post_concat_uploaded_file(self, slot: int = Form(...), filename: str = Form(...), filenameChunkNum: int = Form(...)):
|
||||
def post_concat_uploaded_file(self, filename: str = Form(...), filenameChunkNum: int = Form(...)):
|
||||
slot = 0
|
||||
res = concat_file_chunks(slot, UPLOAD_DIR, filename, filenameChunkNum, UPLOAD_DIR)
|
||||
@ -54,7 +53,7 @@ class MMVC_Rest_Fileuploader:
|
||||
|
||||
def post_load_model(
|
||||
self,
|
||||
# slot: int = Form(...),
|
||||
slot: int = Form(...),
|
||||
pyTorchModelFilename: str = Form(...),
|
||||
onnxModelFilename: str = Form(...),
|
||||
configFilename: str = Form(...),
|
||||
@ -63,15 +62,44 @@ class MMVC_Rest_Fileuploader:
|
||||
indexFilename: str = Form(...),
|
||||
isHalf: bool = Form(...),
|
||||
):
|
||||
pyTorchModelFilePath = os.path.join(UPLOAD_DIR, pyTorchModelFilename) if pyTorchModelFilename != "-" else None
|
||||
onnxModelFilePath = os.path.join(UPLOAD_DIR, onnxModelFilename) if onnxModelFilename != "-" else None
|
||||
configFilePath = os.path.join(UPLOAD_DIR, configFilename)
|
||||
clusterTorchModelFilePath = os.path.join(UPLOAD_DIR, clusterTorchModelFilename) if clusterTorchModelFilename != "-" else None
|
||||
featureFilePath = os.path.join(UPLOAD_DIR, featureFilename) if featureFilename != "-" else None
|
||||
indexFilePath = os.path.join(UPLOAD_DIR, indexFilename) if indexFilename != "-" else None
|
||||
|
||||
info = self.voiceChangerManager.loadModel(configFilePath, pyTorchModelFilePath, onnxModelFilePath,
|
||||
clusterTorchModelFilePath, featureFilePath, indexFilePath,
|
||||
# # Upload File Path
|
||||
# pyTorchModelFilePath = os.path.join(UPLOAD_DIR, pyTorchModelFilename) if pyTorchModelFilename != "-" else None
|
||||
# onnxModelFilePath = os.path.join(UPLOAD_DIR, onnxModelFilename) if onnxModelFilename != "-" else None
|
||||
# configFilePath = os.path.join(UPLOAD_DIR, configFilename)
|
||||
# clusterTorchModelFilePath = os.path.join(UPLOAD_DIR, clusterTorchModelFilename) if clusterTorchModelFilename != "-" else None
|
||||
# featureFilePath = os.path.join(UPLOAD_DIR, featureFilename) if featureFilename != "-" else None
|
||||
# indexFilePath = os.path.join(UPLOAD_DIR, indexFilename) if indexFilename != "-" else None
|
||||
|
||||
# # Stored File Path by Slot
|
||||
# pyTorchModelStoredFilePath = os.path.join(UPLOAD_DIR, f"{slot}", pyTorchModelFilename) if pyTorchModelFilename != "-" else None
|
||||
# onnxModelStoredFilePath = os.path.join(UPLOAD_DIR, f"{slot}", onnxModelFilename) if onnxModelFilename != "-" else None
|
||||
# configStoredFilePath = os.path.join(UPLOAD_DIR, f"{slot}", configFilename)
|
||||
# clusterTorchModelStoredFilePath = os.path.join(UPLOAD_DIR, f"{slot}", clusterTorchModelFilename) if clusterTorchModelFilename != "-" else None
|
||||
# featureStoredFilePath = os.path.join(UPLOAD_DIR, f"{slot}", featureFilename) if featureFilename != "-" else None
|
||||
# indexStoredFilePath = os.path.join(UPLOAD_DIR, f"{slot}", indexFilename) if indexFilename != "-" else None
|
||||
|
||||
# # Store File
|
||||
# if pyTorchModelFilename != "-":
|
||||
# pyTorchModelFilePath = os.path.join(UPLOAD_DIR, pyTorchModelFilename)
|
||||
# pyTorchModelStoredFilePath = os.path.join(UPLOAD_DIR, f"{slot}", pyTorchModelFilename)
|
||||
# shutil.move(pyTorchModelFilePath, pyTorchModelStoredFilePath)
|
||||
|
||||
paths = []
|
||||
for x in [pyTorchModelFilename, onnxModelFilename, configFilename, clusterTorchModelFilename, featureFilename, indexFilename]:
|
||||
if x != "-":
|
||||
uploadPath = os.path.join(UPLOAD_DIR, x)
|
||||
storeDir = os.path.join(UPLOAD_DIR, f"{slot}")
|
||||
os.makedirs(storeDir, exist_ok=True)
|
||||
storePath = os.path.join(storeDir, x)
|
||||
shutil.move(uploadPath, storePath)
|
||||
paths.push(storePath)
|
||||
else:
|
||||
paths.push(None)
|
||||
pyTorchModelStoredFilePath, onnxModelStoredFilePath, configStoredFilePath, clusterTorchModelStoredFilePath, featureStoredFilePath, indexStoredFilePath = paths
|
||||
|
||||
info = self.voiceChangerManager.loadModel(slot, configStoredFilePath, pyTorchModelStoredFilePath, onnxModelStoredFilePath,
|
||||
clusterTorchModelStoredFilePath, featureStoredFilePath, indexStoredFilePath,
|
||||
isHalf)
|
||||
json_compatible_item_data = jsonable_encoder(info)
|
||||
return JSONResponse(content=json_compatible_item_data)
|
||||
|
@ -108,6 +108,7 @@ class VoiceChanger():
|
||||
|
||||
def loadModel(
|
||||
self,
|
||||
slot: number,
|
||||
config: str,
|
||||
pyTorch_model_file: Optional[str] = None,
|
||||
onnx_model_file: Optional[str] = None,
|
||||
@ -123,7 +124,7 @@ class VoiceChanger():
|
||||
elif self.modelType == "so-vits-svc-40" or self.modelType == "so-vits-svc-40_c" or self.modelType == "so-vits-svc-40v2":
|
||||
return self.voiceChanger.loadModel(config, pyTorch_model_file, onnx_model_file, clusterTorchModel)
|
||||
elif self.modelType == "RVC":
|
||||
return self.voiceChanger.loadModel(config, pyTorch_model_file, onnx_model_file, feature_file, index_file, is_half)
|
||||
return self.voiceChanger.loadModel(slot, config, pyTorch_model_file, onnx_model_file, feature_file, index_file, is_half)
|
||||
else:
|
||||
return self.voiceChanger.loadModel(config, pyTorch_model_file, onnx_model_file, clusterTorchModel)
|
||||
except Exception as e:
|
||||
|
@ -11,8 +11,8 @@ class VoiceChangerManager():
|
||||
cls._instance.voiceChanger = VoiceChanger(params)
|
||||
return cls._instance
|
||||
|
||||
def loadModel(self, config, model, onnx_model, clusterTorchModel, feature_file, index_file, is_half: bool = True):
|
||||
info = self.voiceChanger.loadModel(config, model, onnx_model, clusterTorchModel, feature_file, index_file, is_half)
|
||||
def loadModel(self, slot, config, model, onnx_model, clusterTorchModel, feature_file, index_file, is_half: bool = True):
|
||||
info = self.voiceChanger.loadModel(slot, config, model, onnx_model, clusterTorchModel, feature_file, index_file, is_half)
|
||||
if hasattr(info, "status") and info["status"] == "NG":
|
||||
return info
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user