TorchSharp
TorchSharp copied to clipboard
torchvision.io.read_image{,_async}(string filename, ...) prevents subsequent opening of the file for reading
Describe the bug
- SSIA.
To Reproduce
- try to open an image file while processing
torchvision.io.read_image{,_async}(string filename, ...).
Expected behavior
- following
streammust be opened w/FileAccess.ReadandFileShare.Read.- https://github.com/dotnet/TorchSharp/blob/6ceda5336102bfb1e20b65ece1686fa9a8bd9a20/src/TorchVision/IO/Image.cs#L139
- https://github.com/dotnet/TorchSharp/blob/6ceda5336102bfb1e20b65ece1686fa9a8bd9a20/src/TorchVision/IO/Image.cs#L170
- see also https://learn.microsoft.com/en-us/dotnet/api/system.io.file.open?view=net-8.0#system-io-file-open(system-string-system-io-filemode).
Opens a FileStream on the specified path with read/write access with no sharing.
Please complete the following information:
- OS: at least on Windows
- Package: TorchVision
- Version: 0.105.1 or earlier
Additional context
- a possible workaround i can think of: use
torchvision.io.read_image{,_async}(Stream stream, ...)w/ correctly openedstream.