Spaces:
Sleeping
Sleeping
修改时间
Browse files- facefusion/api/core.py +8 -1
facefusion/api/core.py
CHANGED
|
@@ -25,6 +25,7 @@ async def process_frames(params: Params = Body(...)) -> dict:
|
|
| 25 |
# delete_files_in_directory(f"{work_dir}temp/source")
|
| 26 |
# delete_files_in_directory(f"{work_dir}temp/target")
|
| 27 |
# delete_files_in_directory(f"{work_dir}temp/output")
|
|
|
|
| 28 |
|
| 29 |
if not (params.source or params.target):
|
| 30 |
return {"message": "Source image or path is required"}
|
|
@@ -42,7 +43,8 @@ async def process_frames(params: Params = Body(...)) -> dict:
|
|
| 42 |
|
| 43 |
save_file(globals.source_path, params.source)
|
| 44 |
save_file(globals.target_path, params.target)
|
| 45 |
-
|
|
|
|
| 46 |
try:
|
| 47 |
core.api_conditional_process()
|
| 48 |
except Exception as e:
|
|
@@ -52,9 +54,14 @@ async def process_frames(params: Params = Body(...)) -> dict:
|
|
| 52 |
# delete_files_in_directory(globals.source_path)
|
| 53 |
# delete_files_in_directory(globals.target_path)
|
| 54 |
# delete_files_in_directory(globals.output_path)
|
|
|
|
|
|
|
| 55 |
os.remove(globals.source_path)
|
| 56 |
os.remove(globals.target_path)
|
| 57 |
os.remove(globals.output_path)
|
|
|
|
|
|
|
|
|
|
| 58 |
return {'output': output}
|
| 59 |
|
| 60 |
def update_global_variables(params: Params):
|
|
|
|
| 25 |
# delete_files_in_directory(f"{work_dir}temp/source")
|
| 26 |
# delete_files_in_directory(f"{work_dir}temp/target")
|
| 27 |
# delete_files_in_directory(f"{work_dir}temp/output")
|
| 28 |
+
start_time = time.time()
|
| 29 |
|
| 30 |
if not (params.source or params.target):
|
| 31 |
return {"message": "Source image or path is required"}
|
|
|
|
| 43 |
|
| 44 |
save_file(globals.source_path, params.source)
|
| 45 |
save_file(globals.target_path, params.target)
|
| 46 |
+
end_time = time.time()
|
| 47 |
+
print("程序处理时间:", end_time - start_time)
|
| 48 |
try:
|
| 49 |
core.api_conditional_process()
|
| 50 |
except Exception as e:
|
|
|
|
| 54 |
# delete_files_in_directory(globals.source_path)
|
| 55 |
# delete_files_in_directory(globals.target_path)
|
| 56 |
# delete_files_in_directory(globals.output_path)
|
| 57 |
+
end_time2 = time.time()
|
| 58 |
+
print("生成时间:", end_time2 - end_time)
|
| 59 |
os.remove(globals.source_path)
|
| 60 |
os.remove(globals.target_path)
|
| 61 |
os.remove(globals.output_path)
|
| 62 |
+
end_time3 = time.time()
|
| 63 |
+
print("删除文件时间:", end_time3 - end_time2)
|
| 64 |
+
print("最终运行时间:", end_time3 - start_time)
|
| 65 |
return {'output': output}
|
| 66 |
|
| 67 |
def update_global_variables(params: Params):
|