82 lines
2.5 KiB
Python
82 lines
2.5 KiB
Python
from clearml.automation import PipelineController
|
|
|
|
|
|
def inject_xywh_from_detection(pipeline, node, parameters):
|
|
from clearml import Task
|
|
|
|
prev = pipeline.get_pipeline_dag()["model_training_v1"]
|
|
if not prev.executed:
|
|
raise ValueError("model_training_v1 has not finished yet")
|
|
|
|
task = Task.get_task(task_id=prev.executed)
|
|
artifacts = task.artifacts or {}
|
|
if "final_result" not in artifacts:
|
|
raise ValueError(
|
|
f"final_result not found on {prev.executed}; "
|
|
f"available={list(artifacts.keys())}"
|
|
)
|
|
|
|
result = artifacts["final_result"].get()
|
|
detections = result.get("output", {}).get("detections", [])
|
|
if not detections:
|
|
raise ValueError("No detections in model_training_v1.final_result")
|
|
|
|
box = None
|
|
for det in detections:
|
|
if det.get("name") == "person":
|
|
box = det["box"]
|
|
break
|
|
if box is None:
|
|
box = detections[0]["box"]
|
|
|
|
xywh = f"{box['x']},{box['y']},{box['w']},{box['h']}"
|
|
parameters["General/xywh"] = xywh
|
|
if node.job and node.job.task:
|
|
node.job.task.set_parameter("General/xywh", xywh)
|
|
return True
|
|
|
|
|
|
if __name__ == "__main__":
|
|
pipe = PipelineController(
|
|
name="Git_Data_Processing_Pipeline",
|
|
project="Git_Pipeline_Demo",
|
|
version="1.0.0",
|
|
add_pipeline_tags=True,
|
|
)
|
|
pipe.set_default_execution_queue("default")
|
|
|
|
pipe.add_step(
|
|
name="model_training_v1",
|
|
base_task_project="Normal_Object_Detection",
|
|
base_task_name="model-yolo26-human",
|
|
parameter_override={
|
|
"General/image_url": "https://link.lxl.kr/reumdata/20260619_145116_image.jpg"
|
|
},
|
|
)
|
|
pipe.add_step(
|
|
name="vcode2",
|
|
parents=["model_training_v1"],
|
|
base_task_project="Sample",
|
|
base_task_name="vcode",
|
|
cache_executed_step=False,
|
|
)
|
|
pipe.add_step(
|
|
name="model_training_v2",
|
|
parents=["vcode2"],
|
|
base_task_project="Person_Attribute_Recognition",
|
|
base_task_name="model-yolo-person-classify",
|
|
parameter_override={
|
|
"General/image_url": "https://link.lxl.kr/reumdata/20260619_145116_image.jpg",
|
|
},
|
|
task_overrides={
|
|
"script.branch": "main",
|
|
"script.version_num": "",
|
|
},
|
|
pre_execute_callback=inject_xywh_from_detection,
|
|
cache_executed_step=False,
|
|
)
|
|
|
|
pipe.start(queue="default")
|
|
pipe.wait()
|
|
print("파이프라인 실행이 완료되었습니다!")
|