|
@@ -26,6 +26,7 @@ from util.cos_util import cos_upload
|
|
from database.database import insert,update,query,Task
|
|
from database.database import insert,update,query,Task
|
|
from datetime import datetime
|
|
from datetime import datetime
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
+import hashlib
|
|
|
|
|
|
threadPool = ThreadPoolExecutor(max_workers=4)
|
|
threadPool = ThreadPoolExecutor(max_workers=4)
|
|
def lcm(a, b): return abs(a * b) / fractions.gcd(a, b) if a and b else 0
|
|
def lcm(a, b): return abs(a * b) / fractions.gcd(a, b) if a and b else 0
|
|
@@ -50,6 +51,15 @@ def get_args_from_json(json_file_path, args_dict):
|
|
args_dict[key] = summary_dict[key]
|
|
args_dict[key] = summary_dict[key]
|
|
|
|
|
|
return args_dict
|
|
return args_dict
|
|
|
|
+
|
|
|
|
+def getmd5(file):
|
|
|
|
+ m = hashlib.md5()
|
|
|
|
+ with open(file,'rb') as f:
|
|
|
|
+ for line in f:
|
|
|
|
+ m.update(line)
|
|
|
|
+ md5code = m.hexdigest()
|
|
|
|
+ print(md5code)
|
|
|
|
+ return md5code
|
|
class Item(BaseModel):
|
|
class Item(BaseModel):
|
|
isTrain:bool = False
|
|
isTrain:bool = False
|
|
use_mask:bool = False
|
|
use_mask:bool = False
|
|
@@ -165,6 +175,9 @@ def task_query(queryItem:QueryItem):
|
|
@app.post('/jeecg-boot/task/single')
|
|
@app.post('/jeecg-boot/task/single')
|
|
def single(item:Item):
|
|
def single(item:Item):
|
|
#插入数据库
|
|
#插入数据库
|
|
|
|
+ old_task = query(None,item.videoMd5,item.imageMd5,None)
|
|
|
|
+ if len(old_task) > 0:
|
|
|
|
+ return {'code':-1,'data':old_task}
|
|
uid = str(uuid.uuid4())
|
|
uid = str(uuid.uuid4())
|
|
suid = ''.join(uid.split('-'))
|
|
suid = ''.join(uid.split('-'))
|
|
video_input = item.inputVideoUrl
|
|
video_input = item.inputVideoUrl
|
|
@@ -274,6 +287,10 @@ def videoSwap(opt):
|
|
task.status = 'process_error'
|
|
task.status = 'process_error'
|
|
update(task)
|
|
update(task)
|
|
del_file(opt.base_path)
|
|
del_file(opt.base_path)
|
|
|
|
+ task = query(opt.taskId,None,None,None)[0]
|
|
|
|
+ task.status = 'uploading'
|
|
|
|
+ task.output_video_md5 = getmd5(opt.output_path)
|
|
|
|
+ update(task)
|
|
url = cos_upload(opt.output_path,datetime.now().strftime('%Y%m%d')+'/'+opt.output_file_name)
|
|
url = cos_upload(opt.output_path,datetime.now().strftime('%Y%m%d')+'/'+opt.output_file_name)
|
|
del_file(opt.base_path)
|
|
del_file(opt.base_path)
|
|
return {'taskId':opt.taskId,'outputUrl':url}
|
|
return {'taskId':opt.taskId,'outputUrl':url}
|