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

Q: How to used cropped images in Create ML as Object Detection training data without JSON annotation
I have hundreds of thousands of image files that are cropped images grouped into class folders appropriately that I would like to use in Create ML to training an object detection model. I do not have .json annotation files for any of those cropped images. Q1: Am I required to create the .json annotation file for each individual image and just set the bounding box coordinates to the four corners of the images since the full image is the object already cropped? Or is there a way to leverage what I have directly without creating all those .json files? Q2: Anyone have a handy script to help automated the creation of those files? :-) Thanks everyone.
1
0
831
Sep ’21
Create ML doesn't read csv
I'm bad at English... I'm using create ML. I'm using X code. The csv file cannot be read. The same thing happens with core ML API. The structure of csv is as follows. ** text,labelA,labelB,labelC,labelD hello,2,3,4,5 good,3,4,5,6 ** I tried some. I don't think the structure is wrong... I think it's a setting problem. Please help me.
0
1
542
Sep ’21
keypoints annotation for CreateML
Hello, I've tried to label keypoints of my data by labelme, VGG, Make Sense... etc. But their output of annotation json or csv file did not work for createML. Is there any other tool or conversion method ? By the way, I also did not find any demo format of keypoints json file. Does anyone know? Thanks!
1
1
796
Aug ’21
How to create ML program from Swift?
I would like to generate and run ML program inside an app. I got familiar with the coremltools and MIL format, however I can't seem to find any resources on how to generate mlmodel/mlpackage files using Swift on the device. Is there any Swift equivalent of coremltools? Or is there a way to translate MIL description of a ML program into instance of a MLModel? Or something similar.
2
0
1.7k
Aug ’21
How to force CoreML to use only single thread for inference on MacOS
Is there anyway we can set the number of threads used during coreML inference? My model is relatively small and the overhead of launching new threads is too expensive. When using TensorFlow C API, forcing to single thread results in significant decrease in CPU usage. (So far coreML with multiple threads has 3 times the cpu usage compares to TensorFlow with single thread). Also, wondering if anyone has compared the performance between TensorFlow in C and coreML?
2
0
1.1k
Aug ’21
CreateML StyleTransfer not working on M1 MacBook Pro
I have a MacBook Pro M1 (16 GB RAM), and testing CreateML's StyleTransfer model training. When I press «Train», it starts processing and fails with error «Could not create buffer with format BGRA -6662». During the «processing» it allocates about 4.5 GB of RAM. I guess it runs out of memory, however, I've closed all other programs and I can see that there's lot of free RAM when it fails. It happens even if I use just 3 small (500*500) images, 1 for each training, content and validation. So, how to fix it?
1
0
1.1k
Aug ’21
Is it possible to update the data in my model?
I am trying to build an app that uses CoreML. However, I would like the data that was used to build the model to grow and the model to predict taking that growth into account. So, at the end of the day the more the user uses the app the smarter the app gets at predicting what the user will select next. For example: If the user is presented with a variety of clothes to choose from and the user selects pants, the app will present a list of colors to choose from and let's say the user chooses blue, the next time the user chooses pants the blue color is ranked higher than it was the previous time. Is this possible to do? And how do I make selection updates? Thanks in advance for any ideas or suggestions.
1
0
699
Aug ’21
Object Detection Model Preview and Model on App having varying results on the image despite it being the same model
Hello, I have an object detection model that I integrated into an app. When I put an image on the preview for the Object Detection File, it classifies the image correctly. However, if I put the same image onto the app, it classifies it differently with different values. I am confused as to how this is happening. Here is my code: import UIKit import CoreML import Vision import ImageIO class SecondViewController: UIViewController, UINavigationControllerDelegate { @IBOutlet weak var photoImageView: UIImageView! lazy var detectionRequest: VNCoreMLRequest = { do { let model = try VNCoreMLModel(for: EarDetection2().model) let request = VNCoreMLRequest(model: model, completionHandler: { [weak self] request, error in self?.processDetections(for: request, error: error) }) request.imageCropAndScaleOption = .scaleFit return request } catch { fatalError("Failed to load Vision ML model: \(error)") } }() @IBAction func testPhoto(_ sender: UIButton) { let vc = UIImagePickerController() vc.sourceType = .photoLibrary vc.delegate = self present(vc, animated: true) } @IBOutlet weak var results: UILabel! func updateDetections(for image: UIImage) { let orientation = CGImagePropertyOrientation(rawValue: UInt32(image.imageOrientation.rawValue)) guard let ciImage = CIImage(image: image) else { fatalError("Unable to create \(CIImage.self) from \(image).") } DispatchQueue.global(qos: .userInitiated).async { let handler = VNImageRequestHandler(ciImage: ciImage, orientation: orientation!) do { try handler.perform([self.detectionRequest]) } catch { print("Failed to perform detection.\n\(error.localizedDescription)") } } } func processDetections(for request: VNRequest, error: Error?) { DispatchQueue.main.async { guard let results = request.results else { print("Unable to detect anything.\n\(error!.localizedDescription)") return } let detections = results as! [VNRecognizedObjectObservation] self.drawDetectionsOnPreview(detections: detections) } } func drawDetectionsOnPreview(detections: [VNRecognizedObjectObservation]) { guard let image = self.photoImageView?.image else { return } let imageSize = image.size let scale: CGFloat = 0 UIGraphicsBeginImageContextWithOptions(imageSize, false, scale) for detection in detections { image.draw(at: CGPoint.zero) print(detection.labels.map({"\($0.identifier) confidence: \($0.confidence)"}).joined(separator: "\n")) print("------------") results.text = (detection.labels.map({"\($0.identifier) confidence: \($0.confidence)"}).joined(separator: "\n")) // The coordinates are normalized to the dimensions of the processed image, with the origin at the image's lower-left corner. let boundingBox = detection.boundingBox let rectangle = CGRect(x: boundingBox.minX*image.size.width, y: (1-boundingBox.minY-boundingBox.height)*image.size.height, width: boundingBox.width*image.size.width, height: boundingBox.height*image.size.height) UIColor(red: 0, green: 1, blue: 0, alpha: 0.4).setFill() UIRectFillUsingBlendMode(rectangle, CGBlendMode.normal) } let newImage = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() self.photoImageView?.image = newImage } } extension SecondViewController: UIImagePickerControllerDelegate { func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { picker.dismiss(animated: true) guard let image = info[.originalImage] as? UIImage else { return } self.photoImageView?.image = image updateDetections(for: image) } } I attached pictures of the model preview and the app preview (it may be hard to tell but they are the same image). I have also attached pictures of my files and storyboard. Any help would be great! Thanks in advance!
0
0
919
Aug ’21
Sample Rate Bug in CreateML App
Create a sample project in Creat ML and choose Activity Classifier. When lowering the sample rate, the preview timeline gets shorter instead of getting longer. Furthermore, it seems the entire preview timeline breaks (can't scroll) if the sample rate is anything other than 50. Try it out: Train a model with sample rate 50, then try training it with sample rate 10.
0
0
790
Aug ’21
TabularData: DataFrame - parsing JSON array that is not at the root level
DataFrame(contentsOfJSONFile:url) (and it's MLDataTable equivalent) assumes that the rows to be imported are at the root level of the JSON structure. However, I'm downloading a fairly large dataset that has "header" information, such as date created and validity period, with the targeted array at a subsidiary level. The DataFrame initialiser has JSONReadingOptions, but these don't apply to this situation (i.e. there's nothing that helps). It seems that I'm faced with the options of 1) stripping the extraneous data from the JSON file, to leave just the array or 2) decoding the JSON file into a bespoke struct then converting its array into a DataFrame - which removes a lot of the benefits of using DataFrame in the first place. Any thoughts? Cheers, Michaela
1
0
1.2k
Jul ’21
EXC_BAD_ACCESS (code=1, address=0x0) when calling model.prediction()
Hi, I try the activity classifier and want to show the results with an app on a IPhone SE. I try the example analog https://apple.github.io/turicreate/docs/userguide/activity_classifier/export_coreml.html When calling the prediction function: ...    func performModelPrediction () -> String? { ... EXC_BAD_ACCESS (code=1, address=0x0) was thrown in line:         let modelPrediction = try! activityClassificationModel.prediction( ^^^^^^^^here was the Error shown   I can trak it down to the source of the mlmodel:     func prediction(input: MyActivityClassifier2Input, options: MLPredictionOptions) throws -> MyActivityClassifier2Output {         let outFeatures = try model.prediction(from: input, options:options)         return MyActivityClassifier2Output(features: outFeatures)     } I created the model with ml creator, working with Xcode 13 beta. What I am doing wrong ? Do you have any hints ? Is there a better example for activity classifier ? Don't hesitate to ask for further details. -Hans here my code: // //  ViewController.swift //  motionstor4yboard // //  Created by Hans Regler on 19.07.21. // import Foundation import UIKit import CoreML import CoreMotion class ViewController: UIViewController {     override func viewDidLoad() {         debugPrint("info: start viewDidLoad ... ")         super.viewDidLoad()         // Do any additional setup after loading the view, typically from a nib.                 // Connect data:         self.startDeviceMotion()     }      // Define some ML Model constants for the recurrent network   struct ModelConstants {     static let numOfFeatures = 6     // Must be the same value you used while training     static let predictionWindowSize = 100     static let sensorsUpdateInterval = 1.0 / 10.0     static let stateInLength = 400   }      // Initialize the model, layers, and sensor data arrays     let activityClassificationModel = MyActivityClassifier2()     var currentIndexInPredictionWindow = 0     let accelDataX = try! MLMultiArray(shape: [ModelConstants.predictionWindowSize] as [NSNumber], dataType: MLMultiArrayDataType.double)     let accelDataY = try! MLMultiArray(shape: [ModelConstants.predictionWindowSize] as [NSNumber], dataType: MLMultiArrayDataType.double)     let accelDataZ = try! MLMultiArray(shape: [ModelConstants.predictionWindowSize] as [NSNumber], dataType: MLMultiArrayDataType.double)     let gyroDataX = try! MLMultiArray(shape: [ModelConstants.predictionWindowSize] as [NSNumber], dataType: MLMultiArrayDataType.double)     let gyroDataY = try! MLMultiArray(shape: [ModelConstants.predictionWindowSize] as [NSNumber], dataType: MLMultiArrayDataType.double)     let gyroDataZ = try! MLMultiArray(shape: [ModelConstants.predictionWindowSize] as [NSNumber], dataType: MLMultiArrayDataType.double)     var stateOutput = try! MLMultiArray(shape:[ModelConstants.stateInLength as NSNumber], dataType: MLMultiArrayDataType.double)     // Initialize CoreMotion Manager   let motionManager = CMMotionManager()      func startDeviceMotion() { //         guard motionManager.isDeviceMotionAvailable else {     guard motionManager.isAccelerometerAvailable, motionManager.isGyroAvailable else {             debugPrint("Core Motion Data Unavailable!")             return         }          motionManager.accelerometerUpdateInterval = TimeInterval(ModelConstants.sensorsUpdateInterval)     motionManager.gyroUpdateInterval = TimeInterval(ModelConstants.sensorsUpdateInterval)     motionManager.startAccelerometerUpdates(to: .main) { accelerometerData, error in         guard let accelerometerData = accelerometerData else {             print("Error: accelerometerData = accelerometerData")             return }         // Add the current data sample to the data array         self.addAccelSampleToDataArray(accelSample: accelerometerData)     }             }      func addAccelSampleToDataArray (accelSample: CMAccelerometerData) {     // Add the current accelerometer reading to the data array     accelDataX[[currentIndexInPredictionWindow] as [NSNumber]] = accelSample.acceleration.x as NSNumber     accelDataY[[currentIndexInPredictionWindow] as [NSNumber]] = accelSample.acceleration.y as NSNumber     accelDataZ[[currentIndexInPredictionWindow] as [NSNumber]] = accelSample.acceleration.z as NSNumber     // Update the index in the prediction window data array     currentIndexInPredictionWindow += 1     // If the data array is full, call the prediction method to get a new model prediction.     // We assume here for simplicity that the Gyro data was added to the data arrays as well.     if (currentIndexInPredictionWindow == ModelConstants.predictionWindowSize) {         if let predictedActivity = performModelPrediction() {             // Use the predicted activity here             // ...             // Start a new prediction window             currentIndexInPredictionWindow = 0         }     } }          func performModelPrediction () -> String? {         // Perform model prediction         let modelPrediction = try! activityClassificationModel.prediction(             acceleration_x: accelDataX,             acceleration_y: accelDataY,             acceleration_z: accelDataZ,             rotation_x: gyroDataX,             rotation_y: gyroDataY,             rotation_z: gyroDataZ,             stateIn: stateOutput)         // Update the state vector         stateOutput = modelPrediction.stateOut         // Return the predicted activity - the activity with the highest probability         return modelPrediction.label     }
1
0
1.3k
Jul ’21
CreateML Training ends in Unexpected Error
Hi Experts, I am new to CreateML. I am trying action classification library. When I start training on training dataset videos. It looks like it goes fine. Once it finishes the training. It blinks to show graphs and then throws Unexpected Error . I have no clue what to do as a next step. I have checked the videos for training, changed the dataset size to very small. But Honestly, I have no idea to fix it. Any help will be highly appreciated. Regards... MTA
5
0
2.3k
Jul ’21
TabularData DataFrame writeCSV changes double to string for numbers >= 1000
The TabularData DataFrame writeCSV method formats Double (and possibly Integer) numbers that are >= 1000 with a comma thousands separator and surrounds the output in double quotes. Numbers less than 1000 are not double-quoted. If the resulting CSV file is then read by DataFrame contentsOfCSVFile an error is thrown, i.e. a type mismatch. This happens irrespective of whether the types option is set in the CSV read, or not. There is no option in DataFrame writeCSV to specify no thousands separator, nor any other obvious way of preventing the double-quoting. Currently, I "fix" the problem by reading the CSV in Numbers, setting the faulty column(s) to Numeric then exporting back to CSV. Any thoughts on preventing the issue in the first place?
2
0
1.1k
Jul ’21
CreateML Object Detection Image Augmentation
I'm currently gathering data to train an object detection model using the CreateML app. I'd like to get an understanding if any image augmentation is done automatically during the training process in the CreateML app. eg does the CreateML app Flip, Rotate, Blur or Crop by default when training or should I be providing these images? I know when training an image classifier model you have the option to check boxes for augmentation but I'm trying to understand if I need to provide training data with these augmented styles.
3
0
2.0k
Jul ’21
Create ML not recognizing all samples
Hi folks! My sound classifier is not picking up all the sound samples in the subfolder. They are all .flac .mp3 .wav and .m4a files. I've also double checked that file type is possibly not the reason some samples were not recognized. Since Create ML is a complete blackbox, could anyone tell me how should I pre-process my sound samples so that they could all be recognized by the data loader? Thanks!
0
0
966
Jun ’21
How to obtain the class labels in the prediction of the model?
I trained the object detection model into 3 classes using CreateML. Loaded the model into coremltools and performed the prediction, got 'coordinates' and 'confidence' but got no class labels. How can I get class labels? {'coordinates': array([[0.31552333, 0.30995899, 0.38225624, 0.59993058], [0.41404313, 0.5812282 , 0.07037259, 0.06291649], [0.23581643, 0.08297428, 0.18884215, 0.12770388], [0.42899013, 0.18289472, 0.06921174, 0.06600466]]), 'confidence': array([[9.92818241e-06, 9.99987483e-01, 8.74077966e-09], [1.00150883e-05, 1.29828220e-06, 9.98730123e-01], [9.98335183e-01, 1.02320407e-03, 2.00047023e-09], [6.40532759e-04, 1.93859320e-04, 8.27081084e-01]])} def get_feature_size(spec): 		input_description = spec.description.input[0] 		inputSizeImg = input_description.type.imageType.imageSizeRange.widthRange.lowerBound, \ 									 input_description.type.imageType.imageSizeRange.heightRange.lowerBound 		return inputSizeImg loaded_model = coremltools.models.MLModel(modelPath) inputSize_img = get_feature_size(loaded_model.get_spec()) with Image.open(imgPath).resize(input_size_img) as img: out_dict = model.predict({'image':img})
1
0
1.1k
Jun ’21
is the base model M1 iMac enough?
Hi, i'm planning on buying an m1 iMac with 256gb storage, 8gb ram and the 7 core gpu. Will this configuration be enough for Xcode development, Create ML and swift playgrounds? Thanks in advance :)
Replies
2
Boosts
0
Views
1.3k
Activity
Oct ’21
Q: How to used cropped images in Create ML as Object Detection training data without JSON annotation
I have hundreds of thousands of image files that are cropped images grouped into class folders appropriately that I would like to use in Create ML to training an object detection model. I do not have .json annotation files for any of those cropped images. Q1: Am I required to create the .json annotation file for each individual image and just set the bounding box coordinates to the four corners of the images since the full image is the object already cropped? Or is there a way to leverage what I have directly without creating all those .json files? Q2: Anyone have a handy script to help automated the creation of those files? :-) Thanks everyone.
Replies
1
Boosts
0
Views
831
Activity
Sep ’21
Create ML doesn't read csv
I'm bad at English... I'm using create ML. I'm using X code. The csv file cannot be read. The same thing happens with core ML API. The structure of csv is as follows. ** text,labelA,labelB,labelC,labelD hello,2,3,4,5 good,3,4,5,6 ** I tried some. I don't think the structure is wrong... I think it's a setting problem. Please help me.
Replies
0
Boosts
1
Views
542
Activity
Sep ’21
keypoints annotation for CreateML
Hello, I've tried to label keypoints of my data by labelme, VGG, Make Sense... etc. But their output of annotation json or csv file did not work for createML. Is there any other tool or conversion method ? By the way, I also did not find any demo format of keypoints json file. Does anyone know? Thanks!
Replies
1
Boosts
1
Views
796
Activity
Aug ’21
How to create ML program from Swift?
I would like to generate and run ML program inside an app. I got familiar with the coremltools and MIL format, however I can't seem to find any resources on how to generate mlmodel/mlpackage files using Swift on the device. Is there any Swift equivalent of coremltools? Or is there a way to translate MIL description of a ML program into instance of a MLModel? Or something similar.
Replies
2
Boosts
0
Views
1.7k
Activity
Aug ’21
How to force CoreML to use only single thread for inference on MacOS
Is there anyway we can set the number of threads used during coreML inference? My model is relatively small and the overhead of launching new threads is too expensive. When using TensorFlow C API, forcing to single thread results in significant decrease in CPU usage. (So far coreML with multiple threads has 3 times the cpu usage compares to TensorFlow with single thread). Also, wondering if anyone has compared the performance between TensorFlow in C and coreML?
Replies
2
Boosts
0
Views
1.1k
Activity
Aug ’21
CreateML StyleTransfer not working on M1 MacBook Pro
I have a MacBook Pro M1 (16 GB RAM), and testing CreateML's StyleTransfer model training. When I press «Train», it starts processing and fails with error «Could not create buffer with format BGRA -6662». During the «processing» it allocates about 4.5 GB of RAM. I guess it runs out of memory, however, I've closed all other programs and I can see that there's lot of free RAM when it fails. It happens even if I use just 3 small (500*500) images, 1 for each training, content and validation. So, how to fix it?
Replies
1
Boosts
0
Views
1.1k
Activity
Aug ’21
Is it possible to update the data in my model?
I am trying to build an app that uses CoreML. However, I would like the data that was used to build the model to grow and the model to predict taking that growth into account. So, at the end of the day the more the user uses the app the smarter the app gets at predicting what the user will select next. For example: If the user is presented with a variety of clothes to choose from and the user selects pants, the app will present a list of colors to choose from and let's say the user chooses blue, the next time the user chooses pants the blue color is ranked higher than it was the previous time. Is this possible to do? And how do I make selection updates? Thanks in advance for any ideas or suggestions.
Replies
1
Boosts
0
Views
699
Activity
Aug ’21
Object Detection Model Preview and Model on App having varying results on the image despite it being the same model
Hello, I have an object detection model that I integrated into an app. When I put an image on the preview for the Object Detection File, it classifies the image correctly. However, if I put the same image onto the app, it classifies it differently with different values. I am confused as to how this is happening. Here is my code: import UIKit import CoreML import Vision import ImageIO class SecondViewController: UIViewController, UINavigationControllerDelegate { @IBOutlet weak var photoImageView: UIImageView! lazy var detectionRequest: VNCoreMLRequest = { do { let model = try VNCoreMLModel(for: EarDetection2().model) let request = VNCoreMLRequest(model: model, completionHandler: { [weak self] request, error in self?.processDetections(for: request, error: error) }) request.imageCropAndScaleOption = .scaleFit return request } catch { fatalError("Failed to load Vision ML model: \(error)") } }() @IBAction func testPhoto(_ sender: UIButton) { let vc = UIImagePickerController() vc.sourceType = .photoLibrary vc.delegate = self present(vc, animated: true) } @IBOutlet weak var results: UILabel! func updateDetections(for image: UIImage) { let orientation = CGImagePropertyOrientation(rawValue: UInt32(image.imageOrientation.rawValue)) guard let ciImage = CIImage(image: image) else { fatalError("Unable to create \(CIImage.self) from \(image).") } DispatchQueue.global(qos: .userInitiated).async { let handler = VNImageRequestHandler(ciImage: ciImage, orientation: orientation!) do { try handler.perform([self.detectionRequest]) } catch { print("Failed to perform detection.\n\(error.localizedDescription)") } } } func processDetections(for request: VNRequest, error: Error?) { DispatchQueue.main.async { guard let results = request.results else { print("Unable to detect anything.\n\(error!.localizedDescription)") return } let detections = results as! [VNRecognizedObjectObservation] self.drawDetectionsOnPreview(detections: detections) } } func drawDetectionsOnPreview(detections: [VNRecognizedObjectObservation]) { guard let image = self.photoImageView?.image else { return } let imageSize = image.size let scale: CGFloat = 0 UIGraphicsBeginImageContextWithOptions(imageSize, false, scale) for detection in detections { image.draw(at: CGPoint.zero) print(detection.labels.map({"\($0.identifier) confidence: \($0.confidence)"}).joined(separator: "\n")) print("------------") results.text = (detection.labels.map({"\($0.identifier) confidence: \($0.confidence)"}).joined(separator: "\n")) // The coordinates are normalized to the dimensions of the processed image, with the origin at the image's lower-left corner. let boundingBox = detection.boundingBox let rectangle = CGRect(x: boundingBox.minX*image.size.width, y: (1-boundingBox.minY-boundingBox.height)*image.size.height, width: boundingBox.width*image.size.width, height: boundingBox.height*image.size.height) UIColor(red: 0, green: 1, blue: 0, alpha: 0.4).setFill() UIRectFillUsingBlendMode(rectangle, CGBlendMode.normal) } let newImage = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() self.photoImageView?.image = newImage } } extension SecondViewController: UIImagePickerControllerDelegate { func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { picker.dismiss(animated: true) guard let image = info[.originalImage] as? UIImage else { return } self.photoImageView?.image = image updateDetections(for: image) } } I attached pictures of the model preview and the app preview (it may be hard to tell but they are the same image). I have also attached pictures of my files and storyboard. Any help would be great! Thanks in advance!
Replies
0
Boosts
0
Views
919
Activity
Aug ’21
Getting 'init()' is deprecated: Use init(configuration:) instead and handle errors appropriately.
I am trying to make an Image Classifier but I keep getting a warning 'init()' is deprecated: Use init(configuration:) instead and handle errors appropriately. I was wondering if it matters because the app gets made and the classifier works. Just wondering what the warning means. Thanks in advance!
Replies
1
Boosts
0
Views
1.9k
Activity
Aug ’21
Sample Rate Bug in CreateML App
Create a sample project in Creat ML and choose Activity Classifier. When lowering the sample rate, the preview timeline gets shorter instead of getting longer. Furthermore, it seems the entire preview timeline breaks (can't scroll) if the sample rate is anything other than 50. Try it out: Train a model with sample rate 50, then try training it with sample rate 10.
Replies
0
Boosts
0
Views
790
Activity
Aug ’21
TabularData: DataFrame - parsing JSON array that is not at the root level
DataFrame(contentsOfJSONFile:url) (and it's MLDataTable equivalent) assumes that the rows to be imported are at the root level of the JSON structure. However, I'm downloading a fairly large dataset that has "header" information, such as date created and validity period, with the targeted array at a subsidiary level. The DataFrame initialiser has JSONReadingOptions, but these don't apply to this situation (i.e. there's nothing that helps). It seems that I'm faced with the options of 1) stripping the extraneous data from the JSON file, to leave just the array or 2) decoding the JSON file into a bespoke struct then converting its array into a DataFrame - which removes a lot of the benefits of using DataFrame in the first place. Any thoughts? Cheers, Michaela
Replies
1
Boosts
0
Views
1.2k
Activity
Jul ’21
EXC_BAD_ACCESS (code=1, address=0x0) when calling model.prediction()
Hi, I try the activity classifier and want to show the results with an app on a IPhone SE. I try the example analog https://apple.github.io/turicreate/docs/userguide/activity_classifier/export_coreml.html When calling the prediction function: ...    func performModelPrediction () -> String? { ... EXC_BAD_ACCESS (code=1, address=0x0) was thrown in line:         let modelPrediction = try! activityClassificationModel.prediction( ^^^^^^^^here was the Error shown   I can trak it down to the source of the mlmodel:     func prediction(input: MyActivityClassifier2Input, options: MLPredictionOptions) throws -> MyActivityClassifier2Output {         let outFeatures = try model.prediction(from: input, options:options)         return MyActivityClassifier2Output(features: outFeatures)     } I created the model with ml creator, working with Xcode 13 beta. What I am doing wrong ? Do you have any hints ? Is there a better example for activity classifier ? Don't hesitate to ask for further details. -Hans here my code: // //  ViewController.swift //  motionstor4yboard // //  Created by Hans Regler on 19.07.21. // import Foundation import UIKit import CoreML import CoreMotion class ViewController: UIViewController {     override func viewDidLoad() {         debugPrint("info: start viewDidLoad ... ")         super.viewDidLoad()         // Do any additional setup after loading the view, typically from a nib.                 // Connect data:         self.startDeviceMotion()     }      // Define some ML Model constants for the recurrent network   struct ModelConstants {     static let numOfFeatures = 6     // Must be the same value you used while training     static let predictionWindowSize = 100     static let sensorsUpdateInterval = 1.0 / 10.0     static let stateInLength = 400   }      // Initialize the model, layers, and sensor data arrays     let activityClassificationModel = MyActivityClassifier2()     var currentIndexInPredictionWindow = 0     let accelDataX = try! MLMultiArray(shape: [ModelConstants.predictionWindowSize] as [NSNumber], dataType: MLMultiArrayDataType.double)     let accelDataY = try! MLMultiArray(shape: [ModelConstants.predictionWindowSize] as [NSNumber], dataType: MLMultiArrayDataType.double)     let accelDataZ = try! MLMultiArray(shape: [ModelConstants.predictionWindowSize] as [NSNumber], dataType: MLMultiArrayDataType.double)     let gyroDataX = try! MLMultiArray(shape: [ModelConstants.predictionWindowSize] as [NSNumber], dataType: MLMultiArrayDataType.double)     let gyroDataY = try! MLMultiArray(shape: [ModelConstants.predictionWindowSize] as [NSNumber], dataType: MLMultiArrayDataType.double)     let gyroDataZ = try! MLMultiArray(shape: [ModelConstants.predictionWindowSize] as [NSNumber], dataType: MLMultiArrayDataType.double)     var stateOutput = try! MLMultiArray(shape:[ModelConstants.stateInLength as NSNumber], dataType: MLMultiArrayDataType.double)     // Initialize CoreMotion Manager   let motionManager = CMMotionManager()      func startDeviceMotion() { //         guard motionManager.isDeviceMotionAvailable else {     guard motionManager.isAccelerometerAvailable, motionManager.isGyroAvailable else {             debugPrint("Core Motion Data Unavailable!")             return         }          motionManager.accelerometerUpdateInterval = TimeInterval(ModelConstants.sensorsUpdateInterval)     motionManager.gyroUpdateInterval = TimeInterval(ModelConstants.sensorsUpdateInterval)     motionManager.startAccelerometerUpdates(to: .main) { accelerometerData, error in         guard let accelerometerData = accelerometerData else {             print("Error: accelerometerData = accelerometerData")             return }         // Add the current data sample to the data array         self.addAccelSampleToDataArray(accelSample: accelerometerData)     }             }      func addAccelSampleToDataArray (accelSample: CMAccelerometerData) {     // Add the current accelerometer reading to the data array     accelDataX[[currentIndexInPredictionWindow] as [NSNumber]] = accelSample.acceleration.x as NSNumber     accelDataY[[currentIndexInPredictionWindow] as [NSNumber]] = accelSample.acceleration.y as NSNumber     accelDataZ[[currentIndexInPredictionWindow] as [NSNumber]] = accelSample.acceleration.z as NSNumber     // Update the index in the prediction window data array     currentIndexInPredictionWindow += 1     // If the data array is full, call the prediction method to get a new model prediction.     // We assume here for simplicity that the Gyro data was added to the data arrays as well.     if (currentIndexInPredictionWindow == ModelConstants.predictionWindowSize) {         if let predictedActivity = performModelPrediction() {             // Use the predicted activity here             // ...             // Start a new prediction window             currentIndexInPredictionWindow = 0         }     } }          func performModelPrediction () -> String? {         // Perform model prediction         let modelPrediction = try! activityClassificationModel.prediction(             acceleration_x: accelDataX,             acceleration_y: accelDataY,             acceleration_z: accelDataZ,             rotation_x: gyroDataX,             rotation_y: gyroDataY,             rotation_z: gyroDataZ,             stateIn: stateOutput)         // Update the state vector         stateOutput = modelPrediction.stateOut         // Return the predicted activity - the activity with the highest probability         return modelPrediction.label     }
Replies
1
Boosts
0
Views
1.3k
Activity
Jul ’21
CreateML Training ends in Unexpected Error
Hi Experts, I am new to CreateML. I am trying action classification library. When I start training on training dataset videos. It looks like it goes fine. Once it finishes the training. It blinks to show graphs and then throws Unexpected Error . I have no clue what to do as a next step. I have checked the videos for training, changed the dataset size to very small. But Honestly, I have no idea to fix it. Any help will be highly appreciated. Regards... MTA
Replies
5
Boosts
0
Views
2.3k
Activity
Jul ’21
CreateML on iOS
Hi everyone! In my app I need to re-train my MLRecommendation model everyday based on user data. Can I use Create ML directly from iOS or how to use Core ML for this task?
Replies
2
Boosts
0
Views
2.2k
Activity
Jul ’21
TabularData DataFrame writeCSV changes double to string for numbers >= 1000
The TabularData DataFrame writeCSV method formats Double (and possibly Integer) numbers that are >= 1000 with a comma thousands separator and surrounds the output in double quotes. Numbers less than 1000 are not double-quoted. If the resulting CSV file is then read by DataFrame contentsOfCSVFile an error is thrown, i.e. a type mismatch. This happens irrespective of whether the types option is set in the CSV read, or not. There is no option in DataFrame writeCSV to specify no thousands separator, nor any other obvious way of preventing the double-quoting. Currently, I "fix" the problem by reading the CSV in Numbers, setting the faulty column(s) to Numeric then exporting back to CSV. Any thoughts on preventing the issue in the first place?
Replies
2
Boosts
0
Views
1.1k
Activity
Jul ’21
Meal App Personalization Sample Code
Hello! I was wondering if it would be possible for the sample code for the Meal App to be posted. There are some things I'd like to see regarding MLLinearRegressor and how models can be personalized with context and data.
Replies
1
Boosts
0
Views
1.3k
Activity
Jul ’21
CreateML Object Detection Image Augmentation
I'm currently gathering data to train an object detection model using the CreateML app. I'd like to get an understanding if any image augmentation is done automatically during the training process in the CreateML app. eg does the CreateML app Flip, Rotate, Blur or Crop by default when training or should I be providing these images? I know when training an image classifier model you have the option to check boxes for augmentation but I'm trying to understand if I need to provide training data with these augmented styles.
Replies
3
Boosts
0
Views
2.0k
Activity
Jul ’21
Create ML not recognizing all samples
Hi folks! My sound classifier is not picking up all the sound samples in the subfolder. They are all .flac .mp3 .wav and .m4a files. I've also double checked that file type is possibly not the reason some samples were not recognized. Since Create ML is a complete blackbox, could anyone tell me how should I pre-process my sound samples so that they could all be recognized by the data loader? Thanks!
Replies
0
Boosts
0
Views
966
Activity
Jun ’21
How to obtain the class labels in the prediction of the model?
I trained the object detection model into 3 classes using CreateML. Loaded the model into coremltools and performed the prediction, got 'coordinates' and 'confidence' but got no class labels. How can I get class labels? {'coordinates': array([[0.31552333, 0.30995899, 0.38225624, 0.59993058], [0.41404313, 0.5812282 , 0.07037259, 0.06291649], [0.23581643, 0.08297428, 0.18884215, 0.12770388], [0.42899013, 0.18289472, 0.06921174, 0.06600466]]), 'confidence': array([[9.92818241e-06, 9.99987483e-01, 8.74077966e-09], [1.00150883e-05, 1.29828220e-06, 9.98730123e-01], [9.98335183e-01, 1.02320407e-03, 2.00047023e-09], [6.40532759e-04, 1.93859320e-04, 8.27081084e-01]])} def get_feature_size(spec): 		input_description = spec.description.input[0] 		inputSizeImg = input_description.type.imageType.imageSizeRange.widthRange.lowerBound, \ 									 input_description.type.imageType.imageSizeRange.heightRange.lowerBound 		return inputSizeImg loaded_model = coremltools.models.MLModel(modelPath) inputSize_img = get_feature_size(loaded_model.get_spec()) with Image.open(imgPath).resize(input_size_img) as img: out_dict = model.predict({'image':img})
Replies
1
Boosts
0
Views
1.1k
Activity
Jun ’21