FIX 修复空返回值问题
This commit is contained in:
parent
ce16fda8b2
commit
db4515292e
|
|
@ -1,4 +1,5 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from typing import Any, Coroutine
|
||||||
|
|
||||||
import modal
|
import modal
|
||||||
from modal import current_function_call_id
|
from modal import current_function_call_id
|
||||||
|
|
@ -78,27 +79,27 @@ async def video_match_video(target_image: str, reference_video: str) -> ModalTas
|
||||||
summary="查询参考视频中匹配目标结果",
|
summary="查询参考视频中匹配目标结果",
|
||||||
description="查询参考视频中匹配目标结果,返回起止帧/匹配帧信息和置信度",
|
description="查询参考视频中匹配目标结果,返回起止帧/匹配帧信息和置信度",
|
||||||
dependencies=[Depends(verify_token)])
|
dependencies=[Depends(verify_token)])
|
||||||
async def video_match_video(task_id: str, response: Response) -> ImageMatchVideoStatusResponse | VideoMatchVideoStatusResponse | BaseFFMPEGTaskStatusResponse:
|
async def video_match_video(task_id: str, response: Response) -> None | VideoMatchVideoStatusResponse | ImageMatchVideoStatusResponse | BaseFFMPEGTaskStatusResponse:
|
||||||
task_status, code, reason, result, transaction = await ModalUtils.get_modal_task_status(task_id)
|
task_status, code, reason, result, transaction = await ModalUtils.get_modal_task_status(task_id)
|
||||||
if transaction:
|
if transaction:
|
||||||
response.headers["x-trace-id"] = transaction.x_trace_id
|
response.headers["x-trace-id"] = transaction.x_trace_id
|
||||||
response.headers["x-baggage"] = transaction.x_baggage
|
response.headers["x-baggage"] = transaction.x_baggage
|
||||||
|
if result:
|
||||||
if len(result) == 2:
|
if len(result) == 2:
|
||||||
return ImageMatchVideoStatusResponse(taskId=task_id, status=task_status, code=code,error=reason, frame={
|
return ImageMatchVideoStatusResponse(taskId=task_id, status=task_status, code=code,error=reason, frame={
|
||||||
"frame_point": result[0].frame_num,
|
"frame_point": result[0].frame_num,
|
||||||
"frame_time": parse_time(result[0].timestamp),
|
"frame_time": parse_time(result[0].timestamp),
|
||||||
"similarity": result[1]
|
"similarity": result[1]
|
||||||
})
|
})
|
||||||
elif len(result) == 4:
|
elif len(result) == 4:
|
||||||
return VideoMatchVideoStatusResponse(taskId=task_id, status=task_status, code=code,error=reason, start_frame={
|
return VideoMatchVideoStatusResponse(taskId=task_id, status=task_status, code=code,error=reason, start_frame={
|
||||||
"frame_point": result[0].frame_num,
|
"frame_point": result[0].frame_num,
|
||||||
"frame_time": parse_time(result[0].timestamp),
|
"frame_time": parse_time(result[0].timestamp),
|
||||||
"similarity": result[2]
|
"similarity": result[2]
|
||||||
},end_frame={
|
},end_frame={
|
||||||
"frame_point": result[1].frame_num,
|
"frame_point": result[1].frame_num,
|
||||||
"frame_time": parse_time(result[1].timestamp),
|
"frame_time": parse_time(result[1].timestamp),
|
||||||
"similarity": result[3]
|
"similarity": result[3]
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
return BaseFFMPEGTaskStatusResponse(taskId=task_id, status=task_status, code=code,error=reason)
|
return BaseFFMPEGTaskStatusResponse(taskId=task_id, status=task_status, code=code,error=reason)
|
||||||
|
|
@ -349,15 +349,11 @@ with downloader_image.imports():
|
||||||
self.frames: List[VideoFrame] = []
|
self.frames: List[VideoFrame] = []
|
||||||
self.num_workers = num_workers # 线程池工作线程数
|
self.num_workers = num_workers # 线程池工作线程数
|
||||||
|
|
||||||
# 配置日志
|
|
||||||
logger.remove()
|
|
||||||
logger.add(sys.stderr, level="INFO")
|
|
||||||
|
|
||||||
# 获取视频元数据
|
# 获取视频元数据
|
||||||
self._get_video_metadata()
|
self._get_video_metadata()
|
||||||
|
|
||||||
def _get_styled_bar_format(self, text: str) -> str:
|
def _get_styled_bar_format(self, text: str) -> str:
|
||||||
return f"{Style.DIM}{Fore.GREEN}{str(datetime.now())[:-3]} {Fore.MAGENTA}| {Fore.BLACK}{Style.BRIGHT}PBAR {Style.DIM}{Fore.MAGENTA}| {Fore.CYAN}{text}{Fore.RESET}{Style.BRIGHT}"
|
return f"{Style.DIM}{Fore.GREEN}{str(datetime.now())[:-3]} {Fore.MAGENTA}| {Fore.RESET}{Style.BRIGHT}PBAR {Style.DIM}{Fore.MAGENTA}| {Fore.CYAN}{text}{Fore.RESET}{Style.BRIGHT}"
|
||||||
|
|
||||||
def _get_video_metadata(self) -> None:
|
def _get_video_metadata(self) -> None:
|
||||||
"""获取视频元数据"""
|
"""获取视频元数据"""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue