Machinelearning: Cannot load a trained model: "A local file header is corrupt"

Created on 8 May 2019  路  6Comments  路  Source: dotnet/machinelearning

System information

  • OS version/distro: Windows 10
  • .NET Version (eg., dotnet --info): Microsoft.NETCore.App 3.0.0-preview4-27615-11

Issue

Cannot load a trained model.

  • What did you do?
    Trained a model with AutoML, saved it to "model.zip" (see attached) and then I tried to load it via:
    var mlContext = new MLContext(); var mlModel = mlContext.Model.Load("model.zip", out _);
  • What happened?
    An exception is thrown: "A local file header is corrupt"
  • What did you expect?
    The model to be loaded so I can make a prediction.

    Source code / logs

model.zip

Please paste or attach the code or logs or traces that would be helpful to diagnose the issue you are reporting.

question

All 6 comments

@justinormont is this a supported scenario, atm, to your knowledge?

The model.zip should be a completely standard ML.NET model file once it's trained.

@vinodshanbhag, @daholste: any thoughts?

In case it is of any help. I can reproduce the error with a model I trained with "SdcaLogisticRegression" too (not only AutoML). Training and saving the model works fine, but loading it results in the same error.

Hmm.. what overload do you use the save the model? If you use stream, make sure the stream is flushed and disposed properly (within using(){} statement).
Can you check to see if the zip file can be opened by the explorer or other zip file reader? Is it corrupt?

@glebuk Yes, the stream is flushed. It is encapsulated in a using block. The zip can be opened fine (see attached).

I found the issue when I tried to make a minimal sample. The stream was flushed and I was able to open the zip file (the first time), but then after restarting that didn't work anymore, because I was accidentally appending to the zip instead of creating a new file everytime. Closing this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

frankhaugen picture frankhaugen  路  3Comments

ddobric picture ddobric  路  4Comments

bs6523 picture bs6523  路  4Comments

daholste picture daholste  路  3Comments

pgovind picture pgovind  路  3Comments