|
Safemotion Lib
|
Functions | |
| make_reid_cfg (cfg_path, checkpoint_path, device='cuda:0') | |
| build_reid_model (args) | |
| inference_reid_model (model, image) | |
| get_reid_feats (model, crop_images) | |
| get_reid_matrix (q_feats, g_feats=None) | |
| get_reid_image_index (simmat, select_id=1, threshold=0.8) | |
| index_sort (keep_index, s_sim) | |
| reid_api.build_reid_model | ( | args | ) |
fast-reid 모델 빌드 기능
args:
cfg_path (str): 모델이 정의된 config 파일 경로
checkpoint_path (str): 모델의 파라미터가 저장된 경로
device (str): 모델이 구동될 디바이스
return: reid 모델
Definition at line 30 of file reid_api.py.
| reid_api.get_reid_feats | ( | model, | |
| crop_images ) |
여러장의 이미지에 대해 reid 특징을 추출하는 기능
args:
model: reid 모델
crop_images (list[str or np.array]): 사람 영역만 자른 이미지 저장 경로 또는 이미지
return (list[Tensor]):
각 이미지에 대한 reid 특징
Definition at line 62 of file reid_api.py.
| reid_api.get_reid_image_index | ( | simmat, | |
| select_id = 1, | |||
| threshold = 0.8 ) |
유사도 매트릭스를 기반으로 임계치 이상의 유사도를 가지는 feature를 찾는 기능
args:
simmat (np.array): 유사도 매트릭스
select_id (int): 유사도를 비교하려는 인덱스
threshold (float): 유사도 임계치
return:
s_sim (np.array):select_id와 다른 특징과의 유사도
keep_index (np.array): 임계치 이상의 유사도를 가지는 인덱스
Definition at line 121 of file reid_api.py.
| reid_api.get_reid_matrix | ( | q_feats, | |
| g_feats = None ) |
쿼리와 갤러리 간의 유사도 행렬을 계산하는 기능
args:
q_feats (list[tensor] or Tensor): 쿼리, reid 특징 벡터
g_feats (Tensor): 갤러리, reid 특징 벡터
return (np.array):
유사도 행렬
Definition at line 94 of file reid_api.py.
| reid_api.index_sort | ( | keep_index, | |
| s_sim ) |
유사도를 기준으로 정렬하는 기능
args:
keep_index (np.array): 인덱스
s_sim (np.array): 유사도
return (list[tuple]): (인덱스, 유사도) 튜플의 내림차순 정렬된 리스트
Definition at line 143 of file reid_api.py.
| reid_api.inference_reid_model | ( | model, | |
| image ) |
이미지 한장에 대해 reid 모델을 inference 하는 기능
args:
model: reid 모델
image (np.array): BGR 이미지
return:
reid features
Definition at line 45 of file reid_api.py.
| reid_api.make_reid_cfg | ( | cfg_path, | |
| checkpoint_path, | |||
| device = 'cuda:0' ) |
fast-reid 모델 빌드를 위한 cfg 생성 기능
args:
cfg_path (str): 모델이 정의된 config 파일 경로
checkpoint_path (str): 모델의 파라미터가 저장된 경로
device (str): 모델이 구동될 디바이스
return: cfg
Definition at line 13 of file reid_api.py.