Article ID: 000088255 Content Type: Troubleshooting Last Reviewed: 11/20/2023

Unable to Load an Image File Using "numpy.array" Function

Environment

Windows® 10, 64-bit*

BUILT IN - ARTICLE INTRO SECOND COMPONENT
Summary

OpenCV 2 command to load an image file.

Description
  • Created an array of specified shape and filled it with random values: random_input_data = np.random.randn(1, 3, 224, 224).astype(np.float16)
  • Replaced the random values with an image file: random_input_data = np.array(r"<image_dir>\image.png").astype(np.float16)
  • Encountered error: ValueError: could not convert string to float: '<image_dir>\image.png'
Resolution

Use cv2.imread("image.png")

Additional information

Inference Pipeline

Related Products

This article applies to 2 products