Plot keypoint confidence as alpha value by n-poulsen · Pull Request #2319 · DeepLabCut/DeepLabCut

The code was updated so that confidence_to_alpha can now be a function. As the docstring describes:

confidence_to_alpha: Union[bool, Callable[[float], float], default=False
If False, all keypoints will be plot with alpha=1. Otherwise, this can be defined as a function f: [0, 1] -> [0, 1] such that the alpha value for a keypoint will be set as a function of its score: alpha = f(score). The default function used when True is f(x) = max(0, (x - pcutoff)/(1 - pcutoff)).

As an example of the resulting video obtained with the plotting function, here are the results on a toy project of running create_video_with_all_detections with two different values:

deeplabcut.create_video_with_all_detections(..., confidence_to_alpha=False)
penDLC_resnet50_dev-maJul18shuffle1_1000_full_no_conf.mov
pcutoff = 0.1
def confidence_to_alpha(c):
    return np.clip((c - pcutoff) / (1 - pcutoff), 0, 1)

deeplabcut.create_video_with_all_detections(..., confidence_to_alpha=confidence_to_alpha)
penDLC_resnet50_dev-maJul18shuffle1_1000_full.mov

In the second video, the low scores for the red keypoint in the top right corner is very clear, while it cannot be inferred from the first video with confidence_to_alpha=False.