(
config,
inference_cfg,
data,
paf_inds,
greedy=False,
add_discarded=True,
identity_only=False,
calibration_file="",
oks_sigma=0.1,
margin=0,
symmetric_kpts=None,
split_inds=None,
)
| 180 | |
| 181 | |
| 182 | def _benchmark_paf_graphs( |
| 183 | config, |
| 184 | inference_cfg, |
| 185 | data, |
| 186 | paf_inds, |
| 187 | greedy=False, |
| 188 | add_discarded=True, |
| 189 | identity_only=False, |
| 190 | calibration_file="", |
| 191 | oks_sigma=0.1, |
| 192 | margin=0, |
| 193 | symmetric_kpts=None, |
| 194 | split_inds=None, |
| 195 | ): |
| 196 | metadata = data.pop("metadata") |
| 197 | multi_bpts_orig = auxfun_multianimal.extractindividualsandbodyparts(config)[2] |
| 198 | multi_bpts = [j for j in metadata["all_joints_names"] if j in multi_bpts_orig] |
| 199 | n_multi = len(multi_bpts) |
| 200 | data_ = {"metadata": metadata} |
| 201 | for k, v in data.items(): |
| 202 | data_[k] = v["prediction"] |
| 203 | ass = Assembler( |
| 204 | data_, |
| 205 | max_n_individuals=inference_cfg["topktoretain"], |
| 206 | n_multibodyparts=n_multi, |
| 207 | greedy=greedy, |
| 208 | pcutoff=inference_cfg.get("pcutoff", 0.1), |
| 209 | min_affinity=inference_cfg.get("pafthreshold", 0.1), |
| 210 | add_discarded=add_discarded, |
| 211 | identity_only=identity_only, |
| 212 | ) |
| 213 | if calibration_file: |
| 214 | ass.calibrate(calibration_file) |
| 215 | |
| 216 | params = ass.metadata |
| 217 | image_paths = params["imnames"] |
| 218 | bodyparts = params["joint_names"] |
| 219 | idx = data[image_paths[0]]["groundtruth"][2].unstack("coords").reindex(bodyparts, level="bodyparts").index |
| 220 | mask_multi = idx.get_level_values("individuals") != "single" |
| 221 | if not mask_multi.all(): |
| 222 | idx = idx.drop("single", level="individuals") |
| 223 | individuals = idx.get_level_values("individuals").unique() |
| 224 | n_individuals = len(individuals) |
| 225 | map_ = dict(zip(individuals, range(n_individuals), strict=False)) |
| 226 | |
| 227 | # Form ground truth beforehand |
| 228 | ground_truth = [] |
| 229 | for i, imname in enumerate(image_paths): |
| 230 | temp = data[imname]["groundtruth"][2].reindex(multi_bpts, level="bodyparts") |
| 231 | ground_truth.append(temp.to_numpy().reshape((-1, 2))) |
| 232 | ground_truth = np.stack(ground_truth) |
| 233 | temp = np.ones((*ground_truth.shape[:2], 3)) |
| 234 | temp[..., :2] = ground_truth |
| 235 | temp = temp.reshape((temp.shape[0], n_individuals, -1, 3)) |
| 236 | ass_true_dict = _parse_ground_truth_data(temp) |
| 237 | ids = np.vectorize(map_.get)(idx.get_level_values("individuals").to_numpy()) |
| 238 | ground_truth = np.insert(ground_truth, 2, ids, axis=2) |
| 239 |
no test coverage detected