KyuWoo Choi
04/17/2024, 6:01 AMimport time
import asyncio
from prefect import flow, task
from prefect.artifacts import create_table_artifact
from prefect.deployments import DeploymentImage
from bmt.court.run import execute as detect_court_inference
@task(log_prints=True)
def detect_court_task(file_path: str, format: str, player_class: str):
time.sleep(3)
request = {'file_path': 'aicoach/bmt/assets/videos/demo.mp4',
'format': 'MS',
'class': 'SL3'}
args = {
"use_yolo": True,
"show_image": False,
"save_image": False,
}
result = detect_court_inference(request, args)
return result
@flow(persist_result=True, result_serializer="json", cache_result_in_memory=True, log_prints=True)
async def detect_court(file_path: str = "", format: str = "", player_class: str = ""):
task = detect_court_task.submit(file_path, format, player_class)
result = task.result()
await create_table_artifact(table=[result], key="detect-court",
description="Detect court in video")
return result
if __name__ == "__main__":
# asyncio.run(detect_court()) # It works fine
detect_court.deploy(
name="detect-court",
work_pool_name="default",
push=False,
image=DeploymentImage(
name="detect-court",
))
Nate
04/17/2024, 1:34 PMKyuWoo Choi
04/17/2024, 8:51 PMKyuWoo Choi
04/17/2024, 11:24 PMKyuWoo Choi
04/17/2024, 11:26 PMNate
04/17/2024, 11:48 PMDeploymentImage
accepts a dockerfile
kwarg that points to your Dockerfile
KyuWoo Choi
04/18/2024, 12:14 AMdetect_court.deploy(
name="detect-court",
work_pool_name="default",
push=False,
image=DeploymentImage(
name="detect-court",
))
So. Better build custom container image in my case? Can you link the base container Image Dockerfile which prefect use and I can start from?KyuWoo Choi
04/18/2024, 12:16 AM