Vincent Garcia
Vincent Garcia

Reputation: 817

How to access the model's description in CoreML?

I have a CoreML model and I've added information to the model using coremltools:

model.author = 'Vincent Garcia'
model.license = 'BSD'
model.short_description = 'The model is doing something.'

Is there a way to access this information from Swift?

On Apple's documentation, it's written:

Inspect your model’s metadata and MLFeatureDescription instances through modelDescription.

I tried this:

let model = try! MyModel(configuration: MLModelConfiguration())
let desc = model.modelDescription

but I got the following error:

Value of type 'MyModel' has no member 'modelDescription'

It seems that I'm not using the documentation properly. Thanks for your help!

Upvotes: 0

Views: 403

Answers (1)

Matthijs Hollemans
Matthijs Hollemans

Reputation: 7892

MyModel is not an MLModel object but a class that is specifically generated for your model. However, it does have an MLModel object inside, in the model property.

You can access the description like so:

let model = try! MyModel(configuration: MLModelConfiguration())
let desc = model.model.modelDescription

Upvotes: 2

Related Questions