Skip to content

fix: allow model.predict to handle numpy array inputs #350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2025

Conversation

Anirudh2112
Copy link
Contributor

Description

This PR adds support for numpy array inputs to the model.predict function, fixing issue #346. Previously, model.predict would fail when trying to process numpy array inputs in segmentation models, despite working with file paths. This change enables consistent behavior across all input types.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How has this change been tested, please provide a testcase or example of how you tested the change?

Added comprehensive unit tests in test_instance_segmentation.py:

  1. Test with basic numpy array image
  2. Verify prediction group output
  3. Validate request formatting
  4. Check API response handling

Example test case:

image_array = np.zeros((100, 100, 3), dtype=np.uint8)
image_array[30:70, 30:70] = 255
result = model.predict(image_array)

Docs

  • Updated function docstring to include numpy array type

Copy link
Contributor

@hansent hansent left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you for contributing. sorry it took so long to review and merge

@hansent hansent merged commit c129fea into roboflow:main Jun 4, 2025
13 checks passed
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.

2 participants