Can I get the input size of model programmatically?

I have many models with different input sizes. Is there a way that I can get the input size programmatically so that I don't need to modify the hardcoded size every time?


Thanks in advance.

Accepted Reply

Yes, you can:


MLFeatureDescription* inputFeatureDescription = model.modelDescription.inputDescriptionsByName[@"input"];
MLImageConstraint* imageConstraints = inputFeatureDescription.imageConstraint;
CGSize inputSize = CGSizeMake(imageConstraints.pixelsWide, imageConstraints.pixelsHigh);


You have to adjust the name of the input, tough.

Replies

Yes, you can:


MLFeatureDescription* inputFeatureDescription = model.modelDescription.inputDescriptionsByName[@"input"];
MLImageConstraint* imageConstraints = inputFeatureDescription.imageConstraint;
CGSize inputSize = CGSizeMake(imageConstraints.pixelsWide, imageConstraints.pixelsHigh);


You have to adjust the name of the input, tough.