Skip to content

ImageLoadingTransformer hides exceptions in Mapper.MakeGetter #3154

Open

Description

System information

  • OS version/distro: Windows 10 1809
  • .NET Version (eg., dotnet --info): 2.2.202

Issue

I recently tried to use ML.NET in a Xamarin-based UWP app. I targeted the earliest version of UWP that support .NET Standard 2.0 and everything installed correctly. My intention was to make use a separately-trained TensorFlow model to predict some data from an image.

While my code worked without issues in a .NET Core 2.2 console app, in the UWP it was failing. I was constantly getting an exception when attempting to load the target image - Image [whatever] was not found. No additional details, no inner exception.

Only after a fair amount of headscratching and trying various things I managed to find the culprit (which was obvious in hindsight): UWP does not support bitmaps. After I tried to replicate a little bit of the ImageLoader code, I got an unsupported platform exception.

This is all fair but then looking into the code some more, I found this:

throw Host.Except($"Image {src.ToString()} was not found.");

The code is catching all exceptions and throwing a custom exception in their place, without providing the base exception. I think this could be improved as part of making the API surface friendlier to use - spending an hour on this, I started to think I was doing something insanely wrong. The inner exception would have told me the root cause in 10 seconds flat.

So there are basically two issues:

  1. Hiding the base exceptions
  2. Image analytics won't work in UWP at all because of bitmaps

I think a fix for 1. could be relatively simple. 2. will be much more difficult and might not be desirable but I wanted to throw it out there. Maybe using a platform-agnostic implementation of image handling could be useful.

Opinions? Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    P2Priority of the issue for triage purpose: Needs to be fixed at some point.UWPBugs related UWPbugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions