Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A warning "'init()' is deprecated"

I am making a image classification iOS app with Swift.

When I write

guard let model = try? VNCoreMLModel(for: SqueezeNet().model) else { return }

I got this warning:

'init()' is deprecated: Use init(configuration:) instead and handle errors appropriately.

How to get rid of it?

like image 550
Ally Avatar asked Aug 26 '26 09:08

Ally


1 Answers

For me the code of an Apple sample project worked out:

guard let mlModel = try? YOLOv3(configuration: .init()).model,
              let model = try? VNCoreMLModel(for: mlModel) else {
            print("Failed to load detector!")
            return


this was the code which gave me the warning:

guard let model = try? VNCoreMLModel(for: YOLOv3().model) else {
            print("Could not load model")
            return
like image 164
braendnew Avatar answered Aug 28 '26 06:08

braendnew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!