Skip to content

Conversation

@Tao-Yida
Copy link

Example 1 in the documentation (https://augraphy.readthedocs.io/en/latest/doc/source/example_usage.html) contains incorrect code that causes an IndexError when users try to run it.
The current code shows:

data = pipeline(image)
augmented = data["output"]  # This causes IndexError!

ruturns:

IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

But pipeline(image) returns a numpy array directly (via __call__ method which calls augment(image, return_dict=0)), not a dictionary.

  • Solution
  1. Fixed the example to use the return value correctly:
augmented = pipeline(image)  # Returns numpy array directly
  1. Explicitly request dictionary:
data = pipeline.augment(image, return_dict=1)
augmented = data["output"]
  • Technical Details

In AugraphyPipeline.__call__:

def __call__(self, image):
    return self.augment(image, return_dict=0)  # return_dict=0 returns numpy array

When return_dict=0, the augment method returns data["output"] (numpy array), not the full dictionary.

Copilot AI review requested due to automatic review settings January 17, 2026 20:03
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes incorrect documentation in Example 1 that would cause an IndexError when users run the code. The documentation incorrectly showed that pipeline(image) returns a dictionary, when it actually returns a numpy array directly.

Changes:

  • Updated Example 1 to show two correct ways of using the pipeline: calling pipeline(image) to get a numpy array directly, and calling pipeline.augment(image, return_dict=1) to explicitly request a dictionary

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant