Skip to content

Proposal: modernize the keypoint detection example with AlbumentationsX #2414

Description

@ternaus

Proposal

Would the Keras team be open to a focused update to the existing Keypoint Detection with Transfer Learning example that replaces imgaug with AlbumentationsX inside the existing keras.utils.PyDataset?

Keras image augmentation layers should remain the first recommendation when they cover a project's required transforms and targets: they integrate directly with Keras and can run in tf.data or Grain pipelines. The example would present AlbumentationsX only as an optional external path for users who need the current example's image/keypoint synchronization together with a broader transform catalog.

AlbumentationsX documents roughly a hundred transforms across spatial, pixel, dropout, noise, compression, weather, and annotated-target workflows. This is not a one-to-one comparison with Keras layers, and the proposed example would make no performance or superiority claim. It would show how a Keras user can extend the input pipeline while keeping model.fit() unchanged.

Why update this example?

The current example already uses an external augmentation dependency, imgaug, to transform images and keypoints together. Its latest PyPI release is 0.4.0 from February 2020, and it currently fails with NumPy 2 because it references the removed np.sctypes API (upstream issue).

AlbumentationsX accepts NumPy keypoint arrays directly through KeypointParams, so the existing PyDataset can return complete image/keypoint batches without the Keypoint and KeypointsOnImage adapter objects.

Proposed scope

  • Change only examples/vision/keypoint_detection.py in the first review round.
  • Replace the imgaug imports and pipeline with A.Compose, A.Resize, A.HorizontalFlip, A.Affine, and A.KeypointParams while preserving the current augmentation semantics.
  • Preserve the dataset, model, optimizer, epoch count, and training behavior.
  • Update the stale Sequence wording to PyDataset.
  • Recommend built-in Keras augmentation layers when they cover the required transforms and targets.
  • Describe AlbumentationsX as an optional extension for additional transforms and keypoint-aware pipelines.
  • Add generated Markdown and notebook files only after the source change is approved, following the keras.io contributor workflow.

This proposal does not attempt to change the model or address convergence behavior; it is limited to the example's augmentation dependency and accompanying explanation.

Feasibility check

I tested the proposed boundary with Keras 3.15.1, TensorFlow 2.21.0, AlbumentationsX 2.4.3, and NumPy 2.5.2. A synthetic keras.utils.PyDataset returned augmented image/keypoint batches and completed model.fit() with validation.

The full StanfordExtra notebook still requires the annotation archive distributed through the dataset's access form. I would run the complete example before submitting the PR.

Dependency constraints

AlbumentationsX's current public release is AGPL-3.0-only and requires PyTorch to be installed, including when Keras uses TensorFlow as its backend. I am raising this proposal before preparing a PR so the maintainers can decide whether those dependency constraints are acceptable for a keras.io example.

Would this focused update be welcome? If so, I will prepare the source-only PR.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions