Update _read_bytes function in images.py support for URL
Add support for fetching images from URLs in _read_bytes_image
Previously, the function only supported reading image files from local paths. This commit extends its functionality to also fetch images from URLs if the path starts with 'http://' or 'https://'. The function now uses the 'requests' library to download the image content when a URL is provided.
If the URL fetch is successful, the image content is returned as bytes. If the status code is not 200, a ValueError is raised with a message indicating the failure.
The existing file reading functionality remains unchanged for non-URL paths, ensuring backward compatibility.
Changes:
- Modified _read_bytes_image to check if the path is a URL
- Added conditional logic to handle URL paths using requests.get
- Included error handling for failed URL fetch attempts
For now, we don't push you to follow any predefined schema of issue, but ensure you've already read our contribution guide: https://open-metric-learning.readthedocs.io/en/latest/from_readme/contributing.html.
Hey, @stoensin ! Thank you for the interest in OML.
I think we need some tests for this. As an input you can use this url: https://i.ibb.co/wsmD5r4/photo-2022-06-06-17-40-52.jpg. You can put it here: https://github.com/OML-Team/open-metric-learning/tree/main/tests/test_oml/test_datasets
Hey, @stoensin ! Let's move on with this PR. Please, see the comment above: https://github.com/OML-Team/open-metric-learning/pull/548#discussion_r1596831798
@stoensin please, re-open this PR, when you ready to continue