Create ML

RSS for tag

Create machine learning models for use in your app using Create ML.

Posts under Create ML tag

200 Posts

Post

Replies

Boosts

Views

Activity

CoreML Detecting Specific Objects Based On Inputs
I would like to detect specific objects based on a text input for a coreml project. I am currently using ios 14 along with Xcode and using Apple developer object detection template linked here. For example, can I have a textbox with live capture in the background, and when you put a Banana into the textbox, it only detects bananas, and when you put apples, it only detects apples? Would I have to edit the [VNRecognizedObjectObservation] array? (Basically I just want to control what objects I can detect)
1
0
1.3k
Nov ’22
Tensorflow-metal
Tensorflow metal not working on M1 Macbook Air(8GB RAM). #test.py import tensorflow as tf cifar = tf.keras.datasets.cifar100 (x_train, y_train), (x_test, y_test) = cifar.load_data() model = tf.keras.applications.ResNet50( include_top=True, weights=None, input_shape=(32, 32, 3), classes=100,) loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True) model.compile(optimizer="adam", loss=loss_fn, metrics=["accuracy"]) model.fit(x_train, y_train, epochs=5, batch_size=64) Here's the error log:- > python test.py Metal device set to: Apple M1 systemMemory: 8.00 GB maxCacheSize: 2.67 GB 2022-10-28 23:09:44.144540: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:305] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support. 2022-10-28 23:09:44.144913: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:271] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>) [1] 89863 bus error python test.py Another test on a custom code raises this error:- 1 leaked semaphore objects to clean up at shutdown
0
0
1.6k
Nov ’22
Export and use Create ML model in runtime
Hello! In my iPhone app, I have created a button so that I can retrain my CreateML Linear Regression: let model = try MLLinearRegressor.init(trainingData: trainingData.base, targetColumn: "Target") Now I want to use this model in the UI. I know that I can use the model above directly, like following: let pred = try model.predictions(from: testData) However, I prefer using .mlmodel files, because I want to receive one prediction at a time, instead of having to input a DataFrame. I have seen examples where people use the model.write-method to store the .mlmodel on the computer desktop for example, but I want to do it in runtime in the app. Is this possible? And in that case, how can I store the .mlfile and load it again? Can I do it in the app repository?
0
0
1.3k
Oct ’22
MLModelCollection: Begin Access for model collection always fails
HI, I have archived CoreML model and deployed it in CoreML Model deployment. If I try to access it in app, facing issue like "Failed to begin access for model collection with identifier". I have double checked the identifiers in my app and CoreML model deployment, both are same. Not sure what mistake I'm making, Thanks in advance. Please view my code used in Xcode as below: func asddasd() {       if #available(iOS 14.0, *) {         let progress = MLModelCollection.beginAccessing(identifier: "MainCoreMLCollection", completionHandler: modelCollectionAvailable)         debugPrint(progress)       } else {         // Fallback on earlier versions       }     }           @available(iOS 14.0, *)     func modelCollectionAvailable(result: Result<MLModelCollection, Error>) {       switch result {       case .success(let collection):         debugPrint("Model collection \(collection.identifier) is now available.")                   // Load a model from the collection.         loadModel("BCGSearchClassifier", from: collection)                 case .failure(let error):         debugPrint("Error accessing a model collection: \(error)")       }     }           @available(iOS 14.0, *)     func loadModel(_ modelName: String, from collection: MLModelCollection) {       debugPrint(collection.entries[modelName])       guard let entry = collection.entries[modelName] else {         debugPrint("Couldn't find model \(modelName) in \(collection.identifier).")         return       }       MLModel.load(contentsOf: entry.modelURL) { result in         switch result {         case .success(let modelFromCollection):           // Use the modelFromCollection instance.         debugPrint("success")           debugPrint(modelFromCollection)         case .failure(let error):           debugPrint("Error loading model \(modelName) in \(collection.identifier): \(error).")         }       }     } ERROR: MLModelCollection: namespace (TeamID.BCGCoreMLCollection) download failed. Error Domain=com.apple.trial Code=0 "Unknown error." UserInfo={NSLocalizedDescription=Unknown error.} Error Domain=com.apple.CoreML Code=10 \"Failed to begin access for model collection with identifier \'MainCoreMLCollection\': invalid identifier\" UserInfo={NSLocalizedDescription=Failed to begin access for model collection with identifier \'MainCoreMLCollection\': invalid identifier}"
1
0
1.4k
Oct ’22
Image classification works in preview, but not simulator
Following the guide found here, I've been able to preview image classification in Create ML and Xcode. However, when I swap out the MobileNet model for my own and try running it as an app, images are not classified accurately. When I check the same images using my model in its Xcode preview tab, the guesses are accurate. I've tried changing this line to the different available options, but it doesn't seem to help: imageClassificationRequest.imageCropAndScaleOption = .centerCrop Does anyone know why a model would work well in preview but not while running in the app? Thanks in advance.
1
1
1.7k
Sep ’22
There is skiprow option in MLDataTable framework and I am wondering what would be the equivalent in Swift TabularData framework ?
I was working in this csv file and header in located in 4th row so how to skip 3 rows in TabularData framework. Note that skiprow option in available in MLDataTable framework as well as in Python's Panda import Foundation import TabularData let options = CSVReadingOptions( hasHeaderRow: false, nilEncodings: ["","nil"], ignoresEmptyLines: true ) let dataPath = " https://www2.census.gov/programs-surveys/saipe/datasets/time-series/model-tables/irs.csv" var dataFrame = try! DataFrame(contentsOfCSVFile: URL(string: dataPath)!, rows: 0..<15, options: options) print (dataFrame.description)
1
0
1.4k
Sep ’22
Create ML - Unexpected Error
I'm attempting to build a Create ML Image Classification model with 60k images and 4k classes. Each time I run it it manages to extract all the image features and run over 8 iterations but then when I come back to it it has stopped with "Unexpected Error". I ran it on a MacBook Air 2020 (Intel chip) a few times and then purchased a Mac mini M1 to try it on (256GB, 8GB ram - 160 GB free space), but the same happens. Are there any logs with more details of the errors? "Unexpected Error" doesn't give me anything to go on. Thanks.
1
1
1.1k
Aug ’22
Ask an Expert: Does TabularData do much of Python's Pandas Framework
I'm looking for a way to easily (or more easy than rewriting a time series data framework) deal with stock market data. I apparently need to preprocess much of the data I could get from typical APIs (Finnhub.io, AlphaVantage.co) to remove the weekend days from the datasets. Problem: When using the awesome NEW Charts framework to plot prices by daily close price - I get weekends and holidays in my charts. No "real" stock charting tool does this. They some how remove the non-market days from their charts. How? Researching I found the Python Pandas library for TimeSeries data... Can Apple's TabularData do this TimeSeries data manipulation for me? Can to share an example? Thanks! David
1
0
1.3k
Aug ’22
CreateMLComponents: Error in Playground
I encountered an error while experimenting with the new CreateMLComponents in playground with the following code: import CreateMLComponents import CoreML var fullyConnected = FullyConnectedNetworkRegressor<Float>.init() fullyConnected.hiddenUnitCounts = [2] let feature: AnnotatedFeature<MLShapedArray<Float>, Float> = .init(feature: .init(scalars: [2, 3], shape: [2]), annotation: 5) let fitted = try? await fullyConnected.fitted(to: [feature, feature]) print(fitted) The generated error message is included (partially) at the end of this post. I later found out that this same code works fine in an actual app. Any insights? The error message: Playground execution failed: error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation. * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)   * frame #0: 0x00007ffb2093728d SwiftNN`SwiftNN.Tensor.scalar<œÑ_0_0 where œÑ_0_0: SwiftNN.TensorScalar>(as: œÑ_0_0.Type) -> œÑ_0_0 + 157     frame #1: 0x00007ffb20937cbb SwiftNN`SwiftNN.Tensor.playgroundDescription.getter : Any + 91     frame #2: 0x000000010da43ac4 PlaygroundLogger`___lldb_unnamed_symbol491 + 820     frame #3: 0x000000010da45dbd PlaygroundLogger`___lldb_unnamed_symbol505 + 189 (some more lines ...) PlaygroundLogger`___lldb_unnamed_symbol428 + 124     frame #65: 0x000000010da41dad PlaygroundLogger`playground_log_hidden + 269     frame #66: 0x000000010ca59aba $__lldb_expr14`async_MainTY1_ at CreateMLComp.xcplaygroundpage:12:5     frame #67: 0x000000010ca59fb0 $__lldb_expr14`thunk for @escaping @convention(thin) @async () -> () at <compiler-generated>:0     frame #68: 0x000000010ca5a0c0 $__lldb_expr14`partial apply for thunk for @escaping @convention(thin) @async () -> () at <compiler-generated>:0
2
0
1.6k
Aug ’22
ML
I've restarted my ColorProposer app and renamed it Chroma and the app suggests a color for a string. My main function is here: import Foundation import NaturalLanguage import CoreML func predict(for string: String) -> SingleColor? {     var model: MLModel     var predictor: NLModel     do {         model = try ChromaClassifier(configuration: .init()).model     } catch {         print("NIL MDL")         return ni     }     do {         predictor = try NLModel(mlModel: model)     } catch {         print("NIL PREDICT")         return nil     }     let colorKeys = predictor.predictedLabelHypotheses(for: string, maximumCount: 1) // set the maximumCount to 1...7     print(colorKeys)     var color: SingleColor = .init(red: 0, green: 0, blue: 0)     for i in colorKeys {         coor.morphing((ColorKeys.init(rawValue: i.key) ?? .white).toColor().percentage(of: i.value))         print(color)     }     return color } extension SingleColor {     mutating func morphing(_ color: SingleColor) {         self.blue += color.blue         self.green += color.green         self.red += color.red     }     func percentage(of percentage: Double) -> SingleColor {         return .init(red: slf.red * percentage, green: self.green * percentage, blue: self.blue * percentage)     } } struct SingleColor: Codable, Hashable, Identifiable {     var id: UUID {         get {             return .init()         }     }     var red: Double     var green: Double     var blue: Double     var color: Color {         get {             return Color(red: red / 255, green: green / 255, blue: blue / 255)         }     } } enum ColorKeys: String, CaseIterable {     case red = "RED"     case orange = "ORG"     case yellow = "YLW"     case green = "GRN"     case mint = "MNT"     case blue = "BLU"     case violet = "VLT"     case white = "WHT" } extension ColorKeys {     func toColor() -> SingleColor {         print(self)         switch self {         case .red:             return .init(red: 255, green: 0, blue: 0)         case .orange:             return .init(red: 255, green: 125, blue: 0)         case .yellow:             return .init(red: 255, green: 255, blue: 0)         case .green:             return .init(red: 0, green: 255, blue: 0)         case .mint:             return .init(red: 0, green: 255, blue: 255)         case .blue:             return .init(red: 0, green: 0, blue: 255)         case .violet:             return .init(red: 255, green: 0, blue: 255)         case .white:             return .init(red: 255, green: 255, blue: 255)         }     } } here's my view, quite simple: import SwiftUI import Combine struct ContentView: View {     @AppStorage("Text") var text: String = ""     let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()     @State var color: Color? = .white     var body: some View {       TextField("Text...", text: $text).padding().background(color).onReceive(timer) { _ in             color = predict(for: text)?.color             print(color)         }     } } But the problem of not updating the view still persists. In prints, I discovered a really strange issue: The line of print(colorKeys) is always the same.
3
0
1.3k
Aug ’22
Create ML training error "Unexpected error" failure
I'm facing an "Unexpected error" in CreatML while training **Action Classification **. I've added more than 100 videos and followed the same steps as per the apple doc but still, an error occurred and there is not much description for an error as well. I've tried different things but nothing worked. so, If anyone had faced this kind of issue before and resolved that then let me know.
1
0
956
Jul ’22
Best strategy for a "Sing that Tune" game?
I am trying to build a "Sing that Tune" game. For example: The app will tell the user to sing, "Row row your boat." The user will sing "Row row your boat" into the microphone. If the user's melody is close enough to the actual melody, the game is won. My question: Since I'm dealing with live audio that might be "correct" but not "exact," is the best strategy to use ShazamKit and an SHCustomCatalog, or is it better to use Create ML and sound classification? I know Create ML model can learn the difference between a baby and a firetruck, but can it learn the difference between a good guess and a wrong guess of a sung melody? Thank you, Eli
1
0
1k
Jul ’22
object detector model version errors
Hi, I'm trying to build an object detector model using create ml. I have updated my X code version from 13.4 to 13.41. The model created in createml, version 12.20, works and the model created in version 12.40 does not work. No build errors have occurred in both cases. After upgrading the X code version, the model can be built, but it is not recognized and does not respond when the camera is pointed at the object. I would like to know if there is a way to deal with this problem.
1
0
612
Jun ’22
CoreML Detecting Specific Objects Based On Inputs
I would like to detect specific objects based on a text input for a coreml project. I am currently using ios 14 along with Xcode and using Apple developer object detection template linked here. For example, can I have a textbox with live capture in the background, and when you put a Banana into the textbox, it only detects bananas, and when you put apples, it only detects apples? Would I have to edit the [VNRecognizedObjectObservation] array? (Basically I just want to control what objects I can detect)
Replies
1
Boosts
0
Views
1.3k
Activity
Nov ’22
2019 Sample Code
I would like to know whether 2019 WWDC sample codes can be accessed somehow. I was referring to the following Video Building Activity Classification Models in Create ML A working sample code is really useful to verify this capability. Any suggestions will be helpful.
Replies
3
Boosts
0
Views
1.4k
Activity
Nov ’22
Tensorflow-metal
Tensorflow metal not working on M1 Macbook Air(8GB RAM). #test.py import tensorflow as tf cifar = tf.keras.datasets.cifar100 (x_train, y_train), (x_test, y_test) = cifar.load_data() model = tf.keras.applications.ResNet50( include_top=True, weights=None, input_shape=(32, 32, 3), classes=100,) loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True) model.compile(optimizer="adam", loss=loss_fn, metrics=["accuracy"]) model.fit(x_train, y_train, epochs=5, batch_size=64) Here's the error log:- > python test.py Metal device set to: Apple M1 systemMemory: 8.00 GB maxCacheSize: 2.67 GB 2022-10-28 23:09:44.144540: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:305] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support. 2022-10-28 23:09:44.144913: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:271] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>) [1] 89863 bus error python test.py Another test on a custom code raises this error:- 1 leaked semaphore objects to clean up at shutdown
Replies
0
Boosts
0
Views
1.6k
Activity
Nov ’22
Export and use Create ML model in runtime
Hello! In my iPhone app, I have created a button so that I can retrain my CreateML Linear Regression: let model = try MLLinearRegressor.init(trainingData: trainingData.base, targetColumn: "Target") Now I want to use this model in the UI. I know that I can use the model above directly, like following: let pred = try model.predictions(from: testData) However, I prefer using .mlmodel files, because I want to receive one prediction at a time, instead of having to input a DataFrame. I have seen examples where people use the model.write-method to store the .mlmodel on the computer desktop for example, but I want to do it in runtime in the app. Is this possible? And in that case, how can I store the .mlfile and load it again? Can I do it in the app repository?
Replies
0
Boosts
0
Views
1.3k
Activity
Oct ’22
How to access to model class of MLmodel file in xcode 14
Is there any way to view the model class of the mlmodel file on xcode 14?. I watched the video tutorial but didn't see the button to access its model class.
Replies
2
Boosts
0
Views
1.6k
Activity
Oct ’22
MLModelCollection: Begin Access for model collection always fails
HI, I have archived CoreML model and deployed it in CoreML Model deployment. If I try to access it in app, facing issue like "Failed to begin access for model collection with identifier". I have double checked the identifiers in my app and CoreML model deployment, both are same. Not sure what mistake I'm making, Thanks in advance. Please view my code used in Xcode as below: func asddasd() {       if #available(iOS 14.0, *) {         let progress = MLModelCollection.beginAccessing(identifier: "MainCoreMLCollection", completionHandler: modelCollectionAvailable)         debugPrint(progress)       } else {         // Fallback on earlier versions       }     }           @available(iOS 14.0, *)     func modelCollectionAvailable(result: Result<MLModelCollection, Error>) {       switch result {       case .success(let collection):         debugPrint("Model collection \(collection.identifier) is now available.")                   // Load a model from the collection.         loadModel("BCGSearchClassifier", from: collection)                 case .failure(let error):         debugPrint("Error accessing a model collection: \(error)")       }     }           @available(iOS 14.0, *)     func loadModel(_ modelName: String, from collection: MLModelCollection) {       debugPrint(collection.entries[modelName])       guard let entry = collection.entries[modelName] else {         debugPrint("Couldn't find model \(modelName) in \(collection.identifier).")         return       }       MLModel.load(contentsOf: entry.modelURL) { result in         switch result {         case .success(let modelFromCollection):           // Use the modelFromCollection instance.         debugPrint("success")           debugPrint(modelFromCollection)         case .failure(let error):           debugPrint("Error loading model \(modelName) in \(collection.identifier): \(error).")         }       }     } ERROR: MLModelCollection: namespace (TeamID.BCGCoreMLCollection) download failed. Error Domain=com.apple.trial Code=0 "Unknown error." UserInfo={NSLocalizedDescription=Unknown error.} Error Domain=com.apple.CoreML Code=10 \"Failed to begin access for model collection with identifier \'MainCoreMLCollection\': invalid identifier\" UserInfo={NSLocalizedDescription=Failed to begin access for model collection with identifier \'MainCoreMLCollection\': invalid identifier}"
Replies
1
Boosts
0
Views
1.4k
Activity
Oct ’22
create ML: Data Analysis stopped
Being brand new to create ML I tried to run my own ML project. When creating my own image classifier (same with tabular classification) I fail from the start. When selecting valid training data create ML says "Data Analysis stopped". I'm using Create ML Version 3.0 (78.7). Any suggestions?
Replies
3
Boosts
0
Views
2.1k
Activity
Oct ’22
Image classification works in preview, but not simulator
Following the guide found here, I've been able to preview image classification in Create ML and Xcode. However, when I swap out the MobileNet model for my own and try running it as an app, images are not classified accurately. When I check the same images using my model in its Xcode preview tab, the guesses are accurate. I've tried changing this line to the different available options, but it doesn't seem to help: imageClassificationRequest.imageCropAndScaleOption = .centerCrop Does anyone know why a model would work well in preview but not while running in the app? Thanks in advance.
Replies
1
Boosts
1
Views
1.7k
Activity
Sep ’22
There is skiprow option in MLDataTable framework and I am wondering what would be the equivalent in Swift TabularData framework ?
I was working in this csv file and header in located in 4th row so how to skip 3 rows in TabularData framework. Note that skiprow option in available in MLDataTable framework as well as in Python's Panda import Foundation import TabularData let options = CSVReadingOptions( hasHeaderRow: false, nilEncodings: ["","nil"], ignoresEmptyLines: true ) let dataPath = " https://www2.census.gov/programs-surveys/saipe/datasets/time-series/model-tables/irs.csv" var dataFrame = try! DataFrame(contentsOfCSVFile: URL(string: dataPath)!, rows: 0..<15, options: options) print (dataFrame.description)
Replies
1
Boosts
0
Views
1.4k
Activity
Sep ’22
createML Importing Xcode swiftui app
I used createML to generate a text-categorized mlmodel file. I want to import it into my app and let users use it. How can I pour in and write code? Please note: 1. My app was written with SwiftUI. 2. This createML mlmodel file is used for text classification.
Replies
1
Boosts
0
Views
1k
Activity
Sep ’22
Create ML - Unexpected Error
I'm attempting to build a Create ML Image Classification model with 60k images and 4k classes. Each time I run it it manages to extract all the image features and run over 8 iterations but then when I come back to it it has stopped with "Unexpected Error". I ran it on a MacBook Air 2020 (Intel chip) a few times and then purchased a Mac mini M1 to try it on (256GB, 8GB ram - 160 GB free space), but the same happens. Are there any logs with more details of the errors? "Unexpected Error" doesn't give me anything to go on. Thanks.
Replies
1
Boosts
1
Views
1.1k
Activity
Aug ’22
Ask an Expert: Does TabularData do much of Python's Pandas Framework
I'm looking for a way to easily (or more easy than rewriting a time series data framework) deal with stock market data. I apparently need to preprocess much of the data I could get from typical APIs (Finnhub.io, AlphaVantage.co) to remove the weekend days from the datasets. Problem: When using the awesome NEW Charts framework to plot prices by daily close price - I get weekends and holidays in my charts. No "real" stock charting tool does this. They some how remove the non-market days from their charts. How? Researching I found the Python Pandas library for TimeSeries data... Can Apple's TabularData do this TimeSeries data manipulation for me? Can to share an example? Thanks! David
Replies
1
Boosts
0
Views
1.3k
Activity
Aug ’22
CreateMLComponents: Error in Playground
I encountered an error while experimenting with the new CreateMLComponents in playground with the following code: import CreateMLComponents import CoreML var fullyConnected = FullyConnectedNetworkRegressor<Float>.init() fullyConnected.hiddenUnitCounts = [2] let feature: AnnotatedFeature<MLShapedArray<Float>, Float> = .init(feature: .init(scalars: [2, 3], shape: [2]), annotation: 5) let fitted = try? await fullyConnected.fitted(to: [feature, feature]) print(fitted) The generated error message is included (partially) at the end of this post. I later found out that this same code works fine in an actual app. Any insights? The error message: Playground execution failed: error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation. * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)   * frame #0: 0x00007ffb2093728d SwiftNN`SwiftNN.Tensor.scalar<œÑ_0_0 where œÑ_0_0: SwiftNN.TensorScalar>(as: œÑ_0_0.Type) -> œÑ_0_0 + 157     frame #1: 0x00007ffb20937cbb SwiftNN`SwiftNN.Tensor.playgroundDescription.getter : Any + 91     frame #2: 0x000000010da43ac4 PlaygroundLogger`___lldb_unnamed_symbol491 + 820     frame #3: 0x000000010da45dbd PlaygroundLogger`___lldb_unnamed_symbol505 + 189 (some more lines ...) PlaygroundLogger`___lldb_unnamed_symbol428 + 124     frame #65: 0x000000010da41dad PlaygroundLogger`playground_log_hidden + 269     frame #66: 0x000000010ca59aba $__lldb_expr14`async_MainTY1_ at CreateMLComp.xcplaygroundpage:12:5     frame #67: 0x000000010ca59fb0 $__lldb_expr14`thunk for @escaping @convention(thin) @async () -> () at <compiler-generated>:0     frame #68: 0x000000010ca5a0c0 $__lldb_expr14`partial apply for thunk for @escaping @convention(thin) @async () -> () at <compiler-generated>:0
Replies
2
Boosts
0
Views
1.6k
Activity
Aug ’22
ML
I've restarted my ColorProposer app and renamed it Chroma and the app suggests a color for a string. My main function is here: import Foundation import NaturalLanguage import CoreML func predict(for string: String) -> SingleColor? {     var model: MLModel     var predictor: NLModel     do {         model = try ChromaClassifier(configuration: .init()).model     } catch {         print("NIL MDL")         return ni     }     do {         predictor = try NLModel(mlModel: model)     } catch {         print("NIL PREDICT")         return nil     }     let colorKeys = predictor.predictedLabelHypotheses(for: string, maximumCount: 1) // set the maximumCount to 1...7     print(colorKeys)     var color: SingleColor = .init(red: 0, green: 0, blue: 0)     for i in colorKeys {         coor.morphing((ColorKeys.init(rawValue: i.key) ?? .white).toColor().percentage(of: i.value))         print(color)     }     return color } extension SingleColor {     mutating func morphing(_ color: SingleColor) {         self.blue += color.blue         self.green += color.green         self.red += color.red     }     func percentage(of percentage: Double) -> SingleColor {         return .init(red: slf.red * percentage, green: self.green * percentage, blue: self.blue * percentage)     } } struct SingleColor: Codable, Hashable, Identifiable {     var id: UUID {         get {             return .init()         }     }     var red: Double     var green: Double     var blue: Double     var color: Color {         get {             return Color(red: red / 255, green: green / 255, blue: blue / 255)         }     } } enum ColorKeys: String, CaseIterable {     case red = "RED"     case orange = "ORG"     case yellow = "YLW"     case green = "GRN"     case mint = "MNT"     case blue = "BLU"     case violet = "VLT"     case white = "WHT" } extension ColorKeys {     func toColor() -> SingleColor {         print(self)         switch self {         case .red:             return .init(red: 255, green: 0, blue: 0)         case .orange:             return .init(red: 255, green: 125, blue: 0)         case .yellow:             return .init(red: 255, green: 255, blue: 0)         case .green:             return .init(red: 0, green: 255, blue: 0)         case .mint:             return .init(red: 0, green: 255, blue: 255)         case .blue:             return .init(red: 0, green: 0, blue: 255)         case .violet:             return .init(red: 255, green: 0, blue: 255)         case .white:             return .init(red: 255, green: 255, blue: 255)         }     } } here's my view, quite simple: import SwiftUI import Combine struct ContentView: View {     @AppStorage("Text") var text: String = ""     let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()     @State var color: Color? = .white     var body: some View {       TextField("Text...", text: $text).padding().background(color).onReceive(timer) { _ in             color = predict(for: text)?.color             print(color)         }     } } But the problem of not updating the view still persists. In prints, I discovered a really strange issue: The line of print(colorKeys) is always the same.
Replies
3
Boosts
0
Views
1.3k
Activity
Aug ’22
Transform Object Detection dataset from COCO to CreateML format
COCO has set a standard in Object Detection task dataset format. Is there a tool for translating this dataset format to CreateML format so that data can be used in CreateML for training and evaluation? I've found Roboflow but I would rather use a python script rather than this platform as it seems too complex for my needs.
Replies
3
Boosts
1
Views
2k
Activity
Aug ’22
Create ML training error "Unexpected error" failure
I'm facing an "Unexpected error" in CreatML while training **Action Classification **. I've added more than 100 videos and followed the same steps as per the apple doc but still, an error occurred and there is not much description for an error as well. I've tried different things but nothing worked. so, If anyone had faced this kind of issue before and resolved that then let me know.
Replies
1
Boosts
0
Views
956
Activity
Jul ’22
Best strategy for a "Sing that Tune" game?
I am trying to build a "Sing that Tune" game. For example: The app will tell the user to sing, "Row row your boat." The user will sing "Row row your boat" into the microphone. If the user's melody is close enough to the actual melody, the game is won. My question: Since I'm dealing with live audio that might be "correct" but not "exact," is the best strategy to use ShazamKit and an SHCustomCatalog, or is it better to use Create ML and sound classification? I know Create ML model can learn the difference between a baby and a firetruck, but can it learn the difference between a good guess and a wrong guess of a sung melody? Thank you, Eli
Replies
1
Boosts
0
Views
1k
Activity
Jul ’22
How do I port a yolov4 or yolov5 to CoreML
I am using turicreate to train a custom object detection model, however it only supports yolov2. Has anyone tried to port v4 or v5 to CoreML . Is their a utility to do this? I have a couple of v4 PyTorch examples I was going to train then try to do this.
Replies
1
Boosts
0
Views
2.4k
Activity
Jul ’22
object detector model version errors
Hi, I'm trying to build an object detector model using create ml. I have updated my X code version from 13.4 to 13.41. The model created in createml, version 12.20, works and the model created in version 12.40 does not work. No build errors have occurred in both cases. After upgrading the X code version, the model can be built, but it is not recognized and does not respond when the camera is pointed at the object. I would like to know if there is a way to deal with this problem.
Replies
1
Boosts
0
Views
612
Activity
Jun ’22