separate fileuploader
This commit is contained in:
parent
069737ff0a
commit
9cce69cd4d
@ -129,56 +129,25 @@ if __name__ == thisFilename or args.colab == True:
|
|||||||
############
|
############
|
||||||
# File Uploder
|
# File Uploder
|
||||||
# ##########
|
# ##########
|
||||||
UPLOAD_DIR = "upload_dir"
|
# @app_fastapi.post("/load_model_for_train")
|
||||||
os.makedirs(UPLOAD_DIR, exist_ok=True)
|
# async def post_load_model_for_train(
|
||||||
MODEL_DIR = "MMVC_Trainer/logs"
|
# modelGFilename: str = Form(...),
|
||||||
os.makedirs(MODEL_DIR, exist_ok=True)
|
# modelGFilenameChunkNum: int = Form(...),
|
||||||
|
# modelDFilename: str = Form(...),
|
||||||
# @app_fastapi.post("/upload_file")
|
# modelDFilenameChunkNum: int = Form(...),
|
||||||
# async def post_upload_file(
|
|
||||||
# file: UploadFile = File(...),
|
|
||||||
# filename: str = Form(...)
|
|
||||||
# ):
|
# ):
|
||||||
# return upload_file(UPLOAD_DIR, file, filename)
|
|
||||||
|
|
||||||
# @app_fastapi.post("/load_model")
|
|
||||||
|
|
||||||
|
# @app_fastapi.post("/extract_voices")
|
||||||
# async def post_load_model(
|
# async def post_load_model(
|
||||||
# modelFilename: str = Form(...),
|
# zipFilename: str = Form(...),
|
||||||
# modelFilenameChunkNum: int = Form(...),
|
# zipFileChunkNum: int = Form(...),
|
||||||
# configFilename: str = Form(...)
|
|
||||||
# ):
|
# ):
|
||||||
|
# zipFilePath = concat_file_chunks(
|
||||||
# modelFilePath = concat_file_chunks(
|
# UPLOAD_DIR, zipFilename, zipFileChunkNum, UPLOAD_DIR)
|
||||||
# UPLOAD_DIR, modelFilename, modelFilenameChunkNum, UPLOAD_DIR)
|
# shutil.unpack_archive(zipFilePath, "MMVC_Trainer/dataset/textful/")
|
||||||
# print(f'File saved to: {modelFilePath}')
|
# return {"Zip file unpacked": f"{zipFilePath}"}
|
||||||
# configFilePath = os.path.join(UPLOAD_DIR, configFilename)
|
|
||||||
|
|
||||||
# voiceChangerManager.loadModel(configFilePath, modelFilePath)
|
|
||||||
# return {"load": f"{modelFilePath}, {configFilePath}"}
|
|
||||||
|
|
||||||
@app_fastapi.post("/load_model_for_train")
|
|
||||||
async def post_load_model_for_train(
|
|
||||||
modelGFilename: str = Form(...),
|
|
||||||
modelGFilenameChunkNum: int = Form(...),
|
|
||||||
modelDFilename: str = Form(...),
|
|
||||||
modelDFilenameChunkNum: int = Form(...),
|
|
||||||
):
|
|
||||||
|
|
||||||
modelGFilePath = concat_file_chunks(
|
|
||||||
UPLOAD_DIR, modelGFilename, modelGFilenameChunkNum, MODEL_DIR)
|
|
||||||
modelDFilePath = concat_file_chunks(
|
|
||||||
UPLOAD_DIR, modelDFilename, modelDFilenameChunkNum, MODEL_DIR)
|
|
||||||
return {"File saved": f"{modelGFilePath}, {modelDFilePath}"}
|
|
||||||
|
|
||||||
@app_fastapi.post("/extract_voices")
|
|
||||||
async def post_load_model(
|
|
||||||
zipFilename: str = Form(...),
|
|
||||||
zipFileChunkNum: int = Form(...),
|
|
||||||
):
|
|
||||||
zipFilePath = concat_file_chunks(
|
|
||||||
UPLOAD_DIR, zipFilename, zipFileChunkNum, UPLOAD_DIR)
|
|
||||||
shutil.unpack_archive(zipFilePath, "MMVC_Trainer/dataset/textful/")
|
|
||||||
return {"Zip file unpacked": f"{zipFilePath}"}
|
|
||||||
|
|
||||||
############
|
############
|
||||||
# Voice Changer
|
# Voice Changer
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import os
|
import os,shutil
|
||||||
|
|
||||||
from fastapi import APIRouter
|
from fastapi import APIRouter
|
||||||
from fastapi.encoders import jsonable_encoder
|
from fastapi.encoders import jsonable_encoder
|
||||||
@ -19,6 +19,8 @@ class MMVC_Rest_Fileuploader:
|
|||||||
self.router = APIRouter()
|
self.router = APIRouter()
|
||||||
self.router.add_api_route("/upload_file", self.post_upload_file, methods=["POST"])
|
self.router.add_api_route("/upload_file", self.post_upload_file, methods=["POST"])
|
||||||
self.router.add_api_route("/load_model", self.post_load_model, methods=["POST"])
|
self.router.add_api_route("/load_model", self.post_load_model, methods=["POST"])
|
||||||
|
self.router.add_api_route("/load_model_for_train", self.post_load_model_for_train, methods=["POST"])
|
||||||
|
self.router.add_api_route("/extract_voices", self.post_load_model, methods=["POST"])
|
||||||
|
|
||||||
def post_upload_file(self, file: UploadFile = File(...), filename: str = Form(...)):
|
def post_upload_file(self, file: UploadFile = File(...), filename: str = Form(...)):
|
||||||
return upload_file(UPLOAD_DIR, file, filename)
|
return upload_file(UPLOAD_DIR, file, filename)
|
||||||
@ -37,4 +39,25 @@ class MMVC_Rest_Fileuploader:
|
|||||||
return {"load": f"{modelFilePath}, {configFilePath}"}
|
return {"load": f"{modelFilePath}, {configFilePath}"}
|
||||||
|
|
||||||
|
|
||||||
|
def post_load_model_for_train(
|
||||||
|
self,
|
||||||
|
modelGFilename: str = Form(...),
|
||||||
|
modelGFilenameChunkNum: int = Form(...),
|
||||||
|
modelDFilename: str = Form(...),
|
||||||
|
modelDFilenameChunkNum: int = Form(...),
|
||||||
|
):
|
||||||
|
modelGFilePath = concat_file_chunks(
|
||||||
|
UPLOAD_DIR, modelGFilename, modelGFilenameChunkNum, MODEL_DIR)
|
||||||
|
modelDFilePath = concat_file_chunks(
|
||||||
|
UPLOAD_DIR, modelDFilename, modelDFilenameChunkNum, MODEL_DIR)
|
||||||
|
return {"File saved": f"{modelGFilePath}, {modelDFilePath}"}
|
||||||
|
|
||||||
|
def post_load_model(
|
||||||
|
self,
|
||||||
|
zipFilename: str = Form(...),
|
||||||
|
zipFileChunkNum: int = Form(...),
|
||||||
|
):
|
||||||
|
zipFilePath = concat_file_chunks(
|
||||||
|
UPLOAD_DIR, zipFilename, zipFileChunkNum, UPLOAD_DIR)
|
||||||
|
shutil.unpack_archive(zipFilePath, "MMVC_Trainer/dataset/textful/")
|
||||||
|
return {"Zip file unpacked": f"{zipFilePath}"}
|
Loading…
x
Reference in New Issue
Block a user