roboflow-python icon indicating copy to clipboard operation
roboflow-python copied to clipboard

fix: allow model.predict to handle numpy array inputs

Open Anirudh2112 opened this issue 11 months ago • 0 comments

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

Anirudh2112 avatar Jan 02 '25 20:01 Anirudh2112