MobileTen yes I believe so, my info.plist has
Privacy - Camera Usage Description | Camera is needed to take pictures of food!
Post
Replies
Boosts
Views
Activity
Just resubmitted a build and changed target deployment info to iPhone only. I hope that fixes it!
Additionally, in case it's a lower barrier to solve, I tried to put this script together for my own training run using something similar to what I imagine createml does behind the scenes. My problem is it does not seem to save the model or checkpoints to the ~/.mlmodel file path specified. I added comments where I think my code is messed up, appreciate if anyone can take a look!
import CreateML
import Foundation
import Combine
let trainingData = MLImageClassifier.DataSource.labeledDirectories(at: URL(fileURLWithPath: "/Users/giovannizinzi/Desktop/FoodData/Train", isDirectory: true))
let parameters = MLImageClassifier.ModelParameters(
validation: .split(strategy: .automatic),
augmentation: [],
algorithm: .transferLearning(
featureExtractor: .scenePrint(revision: 2),
classifier: .logisticRegressor
)
)
var cancellables = Set<AnyCancellable>()
let trainingSession = try MLImageClassifier.makeTrainingSession(
trainingData: trainingData,
parameters: parameters
)
print(trainingSession.iteration)
print(trainingSession.checkpoints)
print(trainingSession.phase.rawValue)
let checkpointInterval = 0.05
Task{
do {
let trainingJob = try MLImageClassifier.resume(trainingSession)
let progress = trainingJob.progress
progress.publisher(for: \.fractionCompleted)
.sink { fractionCompleted in
print("Training progress: \(fractionCompleted * 100)%")
}
.store(in: &cancellables)
trainingJob.phase
.sink { phase in
print("Current phase: \(phase)")
}
.store(in: &cancellables)
trainingJob.checkpoints
.sink { checkpoint in
print("Checkpoint: \(checkpoint)")
print("Checkpoint: \(checkpoint)")
print("Model URL: \(checkpoint.url)")
// do I need to save the model here for a given checkpoint?
}
.store(in: &cancellables)
trainingJob.result
.sink { completion in
switch completion {
case .finished:
print("Training finished successfully.")
case .failure(let error):
print("Training failed with error: \(error)")
}
} receiveValue: { classifier in
let model = classifier.model
// Save the model, not working? .store(in: &cancellables) culprit?
let modelURL = URL(fileURLWithPath: "/Users/giovannizinzi/Desktop/avofeb24.mlmodel")
let metadata = MLModelMetadata(author: "Gio", shortDescription: "Avo", version: "1.0")
do {
try classifier.write(to: modelURL)
print("Model saved successfully at the end of training.")
} catch {
print("Failed to save model: \(error)")
}
}
.store(in: &cancellables)
} catch {
print("Error occurred: \(error)")
}
}
print(trainingSession.checkpoints)
print(trainingSession.phase)
print(trainingSession.iteration)