Closed natikgadzhi closed 7 months ago
Thanks @natikgadzhi! I would be fine with either of those proposed solutions. If you are interested in fixing it yourself,
there are existing suffixes
against which you can check the file extension. If you go with option 1, you can include the check in the could_log
method. If you go with option 2, you would have to add some logic to log_image
to modify the name
arg.
In an example like this:
when
live.log_image
is trying to save an image, we provide:name
="image"
val
=imagine/a/valid/path
dvc_live.Image
object with the providedname
. Notice that the name is not a valid filename, it does not have an extension.Image
will try todump
itself, but it'soutput_path
does not have an extension either, because it's basicallyoutput_dir/subdir/name
.ValueError: unknown file extension:
Solutions
Document and provide a better error
We can document this behavior, make it obvious that
name
will become the filename of the saved image, and that it must be a valid filename with an extension. And we can fail earlier with a nicer error message.Try to infer the extension from the image
Alternatively, we can infer the format of the image from the image itself. If the
name
does not have an extension, we can applyf"{name}/{val.format}"
.I think inferring the type from the image file is a better idea, but I'm not an expert in ML context specifically, and how folks are used to working with their data.
Happy to help with a fix if you point me in the right direction! /cc @dberenbaum @shcheklein