roboflow / roboflow-python

The official Roboflow Python package. Manage your datasets, models, and deployments. Roboflow has everything you need to build a computer vision application.
https://docs.roboflow.com/python
Apache License 2.0
272 stars 71 forks source link

Enable upload for all our supported image formats #283

Closed stellasphere closed 1 month ago

stellasphere commented 1 month ago

Description

We support many other formats other than the ones we currently allow. We also lost jpg (not jpeg) support in PR #51 (https://github.com/roboflow/roboflow-python/pull/51/files#diff-05ecffcd056f67631588da1975ca43403a88910478c8435876abcdd85b7a8025)

Type of change

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

Tested locally and in this colab: https://colab.research.google.com/drive/1oRqgsKEiihpVpxz5sAWXfTq5L4Eq_zdY?usp=sharing

iurisilvio commented 1 month ago

I think the issue is with invalid images, I see a lot of it in other projects.

We need a verbose mode explaining why it failed.

iurisilvio commented 1 month ago

I tested here:

>>> from PIL import Image
>>> image = Image.open("image.jpg")
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=4080x3072>
>>> image.format
"JPEG"

The issue is probably with invalid images. We can use filetype lib to get the real type and give a good warning when file extension doesn't match expected mime extension:

>>> import filetype
>>> kind = filetype.guess("original.jpg")
>>> kind.extension
'avif'
>>> kind.mime
'image/avif'
iurisilvio commented 1 month ago

Closing this one because I merged #284 with a more complete solution.