-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
How to convert the uploaded image to Numpy array? #2376
Comments
both of the codes are working for me. @app.post("/")
async def read_root(file: UploadFile = File(...)):
image = load_image_into_numpy_array(await file.read())
print(image.data)
return {"Hello": "World"} curl -X POST "http://localhost:3000/" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "file=@image (31).png;type=image/png"
|
Thanks for the reply. Both the codes also worked out for me apparently I had made a mistake in other part of my code. |
Thanks for the help here @includeamin ! 👏 🙇 Thanks for reporting back and closing the issue @pavitrashah 👍 |
Probably, we need convert image's color from BGR to RGB
|
hi guys. I am working on a similar code like yours but instead of printing the numpy array I need to return the numpy array. While returning the numpy array I am getting internal server error |
this work for me to return numpy (but it serialized) |
Thanks for the code. It worked and solved my problem. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Example Code To Get an Image
Or
Environment
Question
How to convert the uploaded image to Numpy array? So it can be then used in libraries like openCV, tensorflow for Computer Vision or Deep Learning Applications.
Things I have already tried
And
But I keep getting errors. And none of the solutions in any other thread works.
Errors:
AttributeError: 'JpegImageFile' object has no attribute 'read'
orAttributeError: 'bytes' object has no attribute 'read'
orAttributeError: 'numpy.ndarray' object has no attribute 'read'
orUnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
The text was updated successfully, but these errors were encountered: