Hello,
Thank you for your help. But I don't know what "CICAgICAwPmveRIJQWdsYWlzX2lv" corresponds to. I am dealing with more than 100 different labels and the object of study is very peculiar. I am identifying different species of butterflies.
The Google Cloud platform gives a dict.txt file.
This is the content of my CoreML file. Do you see anything that I could change?
//
// AutoML.swift
//
// This file was automatically generated and should not be edited.
//
import CoreML
/// Model Prediction Input Type
@available(macOS 10.13, iOS 11.0, tvOS 11.0, watchOS 4.0, *)
class AutoMLInput : MLFeatureProvider {
/// image__0 as color (kCVPixelFormatType_32BGRA) image buffer, 224 pixels wide by 224 pixels high
var image__0: CVPixelBuffer
var featureNames: Set<String> {
get {
return ["image__0"]
}
}
func featureValue(for featureName: String) -> MLFeatureValue? {
if (featureName == "image__0") {
return MLFeatureValue(pixelBuffer: image__0)
}
return nil
}
init(image__0: CVPixelBuffer) {
self.image0 = image0
}
}
/// Model Prediction Output Type
@available(macOS 10.13, iOS 11.0, tvOS 11.0, watchOS 4.0, *)
class AutoMLOutput : MLFeatureProvider {
/// Source provided by CoreML
private let provider : MLFeatureProvider
/// scores__0 as dictionary of strings to doubles
lazy var scores__0: [String : Double] = {
[unowned self] in return self.provider.featureValue(for: "scores__0")!.dictionaryValue as! [String : Double]
}()
/// classLabel as string value
lazy var classLabel: String = {
[unowned self] in return self.provider.featureValue(for: "classLabel")!.stringValue
}()
var featureNames: Set<String> {
return self.provider.featureNames
}
func featureValue(for featureName: String) -> MLFeatureValue? {
return self.provider.featureValue(for: featureName)
}
init(scores__0: [String : Double], classLabel: String) {
self.provider = try! MLDictionaryFeatureProvider(dictionary: ["scores0" : MLFeatureValue(dictionary: scores0 as [AnyHashable : NSNumber]), "classLabel" : MLFeatureValue(string: classLabel)])
}
init(features: MLFeatureProvider) {
self.provider = features
}
}
/// Class for model loading and prediction
@available(macOS 10.13, iOS 11.0, tvOS 11.0, watchOS 4.0, *)
class AutoML {
var model: MLModel
/// URL of model assuming it was installed in the same bundle as this class
class var urlOfModelInThisBundle : URL {
let bundle = Bundle(for: AutoML.self)
return bundle.url(forResource: "AutoML", withExtension:"mlmodelc")!
}
/**
Construct a model with explicit path to mlmodelc file
- parameters:
- url: the file url of the model
- throws: an NSError object that describes the problem
*/
init(contentsOf url: URL) throws {
self.model = try MLModel(contentsOf: url)
}
/// Construct a model that automatically loads the model from the app's bundle
convenience init() {
try! self.init(contentsOf: type(of:self).urlOfModelInThisBundle)
}
/**
Construct a model with configuration
- parameters:
- configuration: the desired model configuration
- throws: an NSError object that describes the problem
*/
@available(macOS 10.14, iOS 12.0, tvOS 12.0, watchOS 5.0, *)
convenience init(configuration: MLModelConfiguration) throws {
try self.init(contentsOf: type(of:self).urlOfModelInThisBundle, configuration: configuration)
}
/**
Construct a model with explicit path to mlmodelc file and configuration
- parameters:
- url: the file url of the model
- configuration: the desired model configuration
- throws: an NSError object that describes the problem
*/
@available(macOS 10.14, iOS 12.0, tvOS 12.0, watchOS 5.0, *)
init(contentsOf url: URL, configuration: MLModelConfiguration) throws {
self.model = try MLModel(contentsOf: url, configuration: configuration)
}
/**
Make a prediction using the structured interface
- parameters:
- input: the input to the prediction as AutoMLInput
- throws: an NSError object that describes the problem
- returns: the result of the prediction as AutoMLOutput
*/
func prediction(input: AutoMLInput) throws -> AutoMLOutput {
return try self.prediction(input: input, options: MLPredictionOptions())
}
/**
Make a prediction using the structured interface
- parameters:
- input: the input to the prediction as AutoMLInput
- options: prediction options
- throws: an NSError object that describes the problem
- returns: the result of the prediction as AutoMLOutput
*/
func prediction(input: AutoMLInput, options: MLPredictionOptions) throws -> AutoMLOutput {
let outFeatures = try model.prediction(from: input, options:options)
return AutoMLOutput(features: outFeatures)
}
/**
Make a prediction using the convenience interface
- parameters:
- image__0 as color (kCVPixelFormatType_32BGRA) image buffer, 224 pixels wide by 224 pixels high
- throws: an NSError object that describes the problem
- returns: the result of the prediction as AutoMLOutput
*/
func prediction(image__0: CVPixelBuffer) throws -> AutoMLOutput {
let input_ = AutoMLInput(image0: image0)
return try self.prediction(input: input_)
}
/**
Make a batch prediction using the structured interface
- parameters:
- inputs: the inputs to the prediction as [AutoMLInput]
- options: prediction options
- throws: an NSError object that describes the problem
- returns: the result of the prediction as [AutoMLOutput]
*/
@available(macOS 10.14, iOS 12.0, tvOS 12.0, watchOS 5.0, *)
func predictions(inputs: [AutoMLInput], options: MLPredictionOptions = MLPredictionOptions()) throws -> [AutoMLOutput] {
let batchIn = MLArrayBatchProvider(array: inputs)
let batchOut = try model.predictions(from: batchIn, options: options)
var results : [AutoMLOutput] = []
results.reserveCapacity(inputs.count)
for i in 0..<batchOut.count {
let outProvider = batchOut.features(at: i)
let result = AutoMLOutput(features: outProvider)
results.append(result)
}
return results
}
}
Thank you!