When trying to access to ObjectDetect.detector(options). Getting bad memory access error.
init?(modelFileInfo: FileInfo, threadCount: Int, scoreThreshold: Float, maxResults: Int) {
let modelFilename = modelFileInfo.name
// Construct the path to the model file.
guard let modelPath = Bundle.main.path(
forResource: modelFileInfo.name,
ofType: modelFileInfo.extension
)
else {
print("Failed to load the model file with name: \(modelFilename).")
return nil
}
// Specify the options for the `Detector`.
let options = ObjectDetectorOptions(modelPath: modelPath)
options.classificationOptions.scoreThreshold = scoreThreshold
options.classificationOptions.maxResults = maxResults
options.baseOptions.computeSettings.cpuSettings.numThreads = threadCount
do {
// Create the `Detector`.
detector = try ObjectDetector.detector(options: options)
} catch let error {
print("Failed to create the interpreter with error: \(error.localizedDescription)")
return nil
}
super.init()
}
i got this code from examples/lite/examples/object_detection/ios at master ยท tensorflow/examples (github.com)
when i run this project cloned from the above git its working perfectly.
to re-produce the error:
create new ios project (i am using ios 17.2) and import the library then try to process a image. it will produce the EXE_BAD_ACCESS when trying to
detector = try ObjectDetector.detector(options: options)