I use create ml to train the image classification model.
With the iteration of the function, I need to use the code to train to achieve the automation process.
However, when I use the code to train the model, the same data, the same parameters, but the executable file generated by the code, the training is very slow.
Create ml may only take tens of seconds, while the code often takes more than 20 minutes.
Here is code and pictures.
class CreateMLManager : NSObject {
open var dataPath: String?
open var outPath: String?
public func training() -> Int {
guard let dataPath = dataPath else {
return 1
}
guard let outPath = outPath else {
return 1
}
do {
let aumentation : MLImageClassifier.ImageAugmentationOptions = [.crop, .rotation, .blur, .exposure, .noise, .flip];
let parameters = MLImageClassifier.ModelParameters(validation: .split(strategy: .automatic),maxIterations: 11,augmentation: aumentation,algorithm: .transferLearning(featureExtractor: .scenePrint(revision: 1), classifier: .logisticRegressor))
let out_path = outPath + "/test.mlmodel"
let model = try MLImageClassifier(trainingData: .labeledDirectories(at: URL(fileURLWithPath: dataPath)), parameters:parameters)
try model.write(to: URL(fileURLWithPath: out_path))
return 0
} catch {
return 1
}
}
}
Current working dir: /Users/wbw/Library/Developer/Xcode/DerivedData/mlmodelTransition-cdfkslvlaufvnagpypknnofdmgkv/Build/Products/Debug 2023-01-10 18:02:09.670712+0800 mlmodelTransition[1435:1935624] 训练数据:/Users/wbw/Desktop/Rashomon/work/company_library/ArWeb/web/ml_platform/temp/xjy 2023-01-10 18:02:09.671074+0800 mlmodelTransition[1435:1935624] 存储路径:/Users/wbw/Desktop/Rashomon/work/company_library/ArWeb/web/ml_platform/resource/training_model/xjy 4 augmented images by 'crop' to be generated. 4 augmented images by 'rotation' to be generated. 4 augmented images by 'blur' to be generated. 1 augmented images by 'exposure' to be generated. 1 augmented images by 'noise' to be generated. 1 augmented images by 'flip' to be generated. Extracting augmented image features from training data. Analyzing and extracting image features. +----------------------+------------------+--------------+------------------+ Raw Images Processed | Augmented Images | Elapsed Time | Percent Complete | +----------------------+------------------+--------------+------------------+ 2023-01-10 18:02:11.132922+0800 mlmodelTransition[1435:1936088] Metal API Validation Enabled Failed to render 89401 pixels because a CIKernel's ROI function did not allow tiling. 2023-01-10 18:02:11.212669+0800 mlmodelTransition[1435:1936088] [api] -[CIContext(CIRenderDestination) _startTaskToRender:toDestination:forPrepareRender:forClear:error:] Failed to render part of the image because memory requirement of -1 too big Failed to render 89401 pixels because a CIKernel's ROI function did not allow tiling. 2023-01-10 18:02:11.233004+0800 mlmodelTransition[1435:1936088] [api] -[CIContext(CIRenderDestination) _startTaskToRender:toDestination:forPrepareRender:forClear:error:] Failed to render part of the image because memory requirement of -1 too big Failed to render 89401 pixels because a CIKernel's ROI function did not allow tiling. 2023-01-10 18:02:11.252051+0800 mlmodelTransition[1435:1936088] [api] -[CIContext(CIRenderDestination) _startTaskToRender:toDestination:forPrepareRender:forClear:error:] Failed to render part of the image because memory requirement of -1 too big Failed to render 89401 pixels because a CIKernel's ROI function did not allow tiling. 2023-01-10 18:02:11.276394+0800 mlmodelTransition[1435:1936088] [api] -[CIContext(CIRenderDestination) _startTaskToRender:toDestination:forPrepareRender:forClear:error:] Failed to render part of the image because memory requirement of -1 too big Failed to render 89401 pixels because a CIKernel's ROI function did not allow tiling. 2023-01-10 18:02:11.297000+0800 mlmodelTransition[1435:1936088] [api] -[CIContext(CIRenderDestination) _startTaskToRender:toDestination:forPrepareRender:forClear:error:] Failed to render part of the image because memory requirement of -1 too big Failed to render 89401 pixels because a CIKernel's ROI function did not allow tiling. 2023-01-10 18:02:11.318678+0800 mlmodelTransition[1435:1936088] [api] -[CIContext(CIRenderDestination) _startTaskToRender:toDestination:forPrepareRender:forClear:error:] Failed to render part of the image because memory requirement of -1 too big Failed to render 89401 pixels because a CIKernel's ROI function did not allow tiling. 2023-01-10 18:02:11.340412+0800 mlmodelTransition[1435:1936088] [api] -[CIContext(CIRenderDestination) _startTaskToRender:toDestination:forPrepareRender:forClear:error:] Failed to render part of the image because memory requirement of -1 too big Failed to render 89401 pixels because a CIKernel's ROI function did not allow tiling. 2023-01-10 18:02:11.360359+0800 mlmodelTransition[1435:1936088] [api] -[CIContext(CIRenderDestination) _startTaskToRender:toDestination:forPrepareRender:forClear:error:] Failed to render part of the image because memory requirement of -1 too big Failed to render 89401 pixels because a CIKernel's ROI function did not allow tiling. 2023-01-10 18:02:11.379907+0800 mlmodelTransition[1435:1936088] [api] -[CIContext(CIRenderDestination) _startTaskToRender:toDestination:forPrepareRender:forClear:error:] Failed to render part of the image because memory requirement of -1 too big Failed to render 63687 pixels because a CIKernel's ROI function did not allow tiling. 2023-01-10 18:02:11.397403+0800 mlmodelTransition[1435:1936088] [api] -[CIContext(CIRenderDestination) _startTaskToRender:toDestination:forPrepareRender:forClear:error:] Failed to render part of the image because memory requirement of -1 too big Failed to render 81029 pixels because a CIKernel's ROI function did not allow tiling. 2023-01-10 18:02:11.416585+0800 mlmodelTransition[1435:1936088] [api] -[CIContext(CIRenderDestination) _startTaskToRender:toDestination:forPrepareRender:forClear:error:] Failed to render part of the image because memory requirement of -1 too big Failed to render 89401 pixels because a CIKernel's ROI function did not allow tiling.
create ml param
create ml training process
When I run the code, I keep getting warnings.
This warning is about cikernel's. I guess it has something to do with image processing, but I checked Apple's documentation and found no solution. I found a question about this error on stackoverflow, but I have no idea to solve the slow problem.
cikernel's warning.
I really don't know the difference between code training and program training