Safemotion Lib
Loading...
Searching...
No Matches
Functions
smrunner.model_runner_builder Namespace Reference

Functions

 build_model (cfg, device='cpu')
 

Function Documentation

◆ build_model()

smrunner.model_runner_builder.build_model ( cfg,
device = 'cpu' )
세이프모션 라이브러리의 모델들을 빌드하는 기능
action, detect, pose, track 모델들을 빌드할 수 있음
args:
    cfg (str or Config): 모델의 config 파일 경로 또는 mmengine.config.Config.fromfile()로 생성한 객체
    device (str): 모델이 구동될 디바이스
return : 세이프모션 라이브러리의 모델

Definition at line 27 of file model_runner_builder.py.

27def build_model(cfg, device='cpu'):
28 """
29 세이프모션 라이브러리의 모델들을 빌드하는 기능
30 action, detect, pose, track 모델들을 빌드할 수 있음
31 args:
32 cfg (str or Config): 모델의 config 파일 경로 또는 mmengine.config.Config.fromfile()로 생성한 객체
33 device (str): 모델이 구동될 디바이스
34 return : 세이프모션 라이브러리의 모델
35 """
36
37 #문자열로 입력 받을 경우 mmengine.config.Config.fromfile() cfg 생성
38 if isinstance(cfg, str):
39 cfg = Config.fromfile(cfg)
40
41 model = cfg.model #모델 파라미터
42 model_args = model.copy() #복사
43
44 #모델 빌드
45 if model.type in det_runner_builders: #객체 검출 모델 빌드
46 model = build_detect_runner(model_args)
47
48 elif model.type in pose_runner_builders: #포즈 추정 모델 빌드
49 model = build_pose_runner(model_args)
50
51 elif model.type in action_runner_builders: #행동 인식 모델 빌드
52 model = build_action_runner(model_args)
53 if cfg.test.model_path is not None:
54 load_model(model, cfg.test.model_path, device=device)
55
56 elif model.type in track_runner_builders: #추적 모델 빌드
57 model = build_track_runner(model_args)
58 else:
59 return None
60
61 return model
62
63 # assert model.type in __model_builder__, \
64 # f'not found model type : {model.type}'
65
66 # model_builder = __model_builder__[model.type]
67 # model_args = model.copy()
68 # return model_builder(model_args)
69
70