Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load the Model by Stream #3462

Closed
arafattehsin opened this issue Apr 22, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@arafattehsin
Copy link

commented Apr 22, 2019

System information

I have used my model as an embedded resource in one of my projects.

Issue

I tried to load the model using Stream and it gives me an error below;

System.ArgumentOutOfRangeException: 'filePath cannot be null or empty
Parameter name: filePath'

Source code / logs

My below code snippet;

var assembly = Assembly.GetExecutingAssembly();
using (var stream = assembly.GetManifestResourceStream("SentimentAnalyzer.MLModels.SentimentModel.zip"))
{
//Create MLContext to be shared across the model creation workflow objects
//Set a random seed for repeatable/deterministic results across multiple trainings.
var mlContext = new MLContext(seed: 1);
Sentiment sampleStatement = new Sentiment { Text = text };
ITransformer trainedModel = mlContext.Model.Load(stream, out var modelInputSchema);
...
...
}

@arafattehsin

This comment has been minimized.

Copy link
Author

commented Apr 22, 2019

Just an update on this!

If I try to use without using then it works fine. I had to explicitly close the stream.

@sfilipi

This comment has been minimized.

Copy link
Member

commented Apr 22, 2019

Glad you can move forward @arafattehsin.
Closing the issue since it seems resolved.

@sfilipi sfilipi closed this Apr 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.