Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

ValueError: PosixPath('.') has an empty name #1

Closed
robmarkcole opened this issue Apr 5, 2021 · 3 comments
Closed

ValueError: PosixPath('.') has an empty name #1

robmarkcole opened this issue Apr 5, 2021 · 3 comments

Comments

@robmarkcole
Copy link
Owner

robmarkcole commented Apr 5, 2021

On uploading the image I get ValueError: PosixPath('.') has an empty name

Appears to be related to ultralytics/yolov5#2246

Source: An Image created from requests.get download will not have im.filename property set, thus Path(im.filename) will fail.

Solution: Just write a dummy filename into the image's property.

@robmarkcole
Copy link
Owner Author

I believe this is because we are creating the PIL image from bytes, so filename parameter is missing. Attempting to set it using file.filename = 'tmp.jpg' was not successful

@robmarkcole
Copy link
Owner Author

Resolved with hacky workaround:

  img_bytes = file.read()
  img = Image.open(io.BytesIO(img_bytes))
  img.save('/tmp/tmp.jpg')

  # Reopen
  img = Image.open('/tmp/tmp.jpg')
  results = model(img, size=640)

Created ultralytics/yolov5#2702

@robmarkcole
Copy link
Owner Author

The underlying issue was resolved in ultralytics/yolov5#2708

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant