Somehow got it to export by composing the transformer explicitly, which gave a
ComposedTransformer<ImageFeaturePrint, FullyConnectedNetworkMultiLabelClassifierModel>, so I'm guessing the chaining used in the documentation was never attempted to export since return type is invalid
let annotatedFeatures = detectionFiles.map {
AnnotatedFeature(
feature: directoryURL.appending(component: $0.filename),
annotation: $0.labels
)
}
let reader = ImageReader()
let (training, validation) = annotatedFeatures.randomSplit(by: 0.8)
let featurePrint = ImageFeaturePrint(revision: 2)
let classifier = FullyConnectedNetworkMultiLabelClassifier<Float, String>(labels: labels)
let task = featurePrint.appending(classifier)
Task {
let trainingImages = try await reader.applied(to: training)
let validationImages = try await reader.applied(to: validation)
let model = try await task.fitted(
to: trainingImages,
validateOn: validationImages,
eventHandler: { event in
debugPrint(event)
}
)
try! model.export(to: modelFile)
}
Topic:
Machine Learning & AI
SubTopic:
Create ML
Tags: