Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions deepposekit/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,28 @@ def on_epoch_end(self, epoch, logs):

euclidean = euclidean.flatten()
confidence = confidence.flatten()
y_visible = ~np.isnan(y_error[...,0].flatten())

if self.confidence_threshold:
mask = confidence >= confidence_threshold
euclidean = euclidean[mask]
confidence = confidence[mask]

keypoint_percentile = np.percentile(
[euclidean, confidence], [0, 5, 25, 50, 75, 95, 100], axis=1
).T
euclidean_perc, confidence_perc = keypoint_percentile

euclidean_mean, confidence_mean = np.mean([euclidean, confidence], axis=1)
y_visible = y_visible[mask]

if ~y_visible.all():
euclidean = euclidean[y_visible]
confidence[~y_visible] = 1-confidence[~y_visible]

euclidean_perc = np.percentile(euclidean, [0, 5, 25, 50, 75, 95, 100])
euclidean_mean = euclidean.mean()
confidence_perc = np.percentile(confidence, [0, 5, 25, 50, 75, 95, 100])
confidence_mean = confidence.mean()
# keypoint_percentile = np.percentile(
# [euclidean, confidence], [0, 5, 25, 50, 75, 95, 100], axis=1
# ).T
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just delete this commented code. git keeps track of changes. There's no need to keep old code.

# euclidean_perc, confidence_perc = keypoint_percentile

# euclidean_mean, confidence_mean = np.mean([euclidean, confidence], axis=1)

logs["euclidean"] = euclidean_mean
logs["confidence"] = confidence_mean
Expand Down
1 change: 1 addition & 0 deletions deepposekit/utils/keypoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def imgaug_to_numpy(keypoints):


def keypoint_errors(y_true, y_pred):
y_true[y_true<-100] = np.NaN # Non-visible points have keypoint location -99999 before augmentation
y_error = y_true - y_pred

euclidean = np.sqrt(np.sum(y_error ** 2, axis=-1))
Expand Down