Resnet 50 error / SwiftUI

I am building Object detection App using Xcode/ SwiftUI. I am using Resnet50 for image classification and have used this code.

var model = Resnet50().model. I have got this error ('init()' is deprecated: Use init(configuration:) instead and handle errors appropriately.). How to fix this problem.

The initializer that you are using when you initialize your Resnet50 model, Resnet50(), which is also equivalent to Resnet50.init(), is deprecated, and so you are being shown a deprecation warning by Xcode.

The warning suggests the init(configuration:) initializer as the replacement. To use that initializer, you would need to provide an MLConfiguration, you might do something like the following:

    var config = MLModelConfiguration()
    // Set any properties on the configuration here if you don't want to use the default configuration.
    
    // Pass the configuration in to the initializer.
    do {
        let resnet = try Resnet50(configuration: config)
        // Use the model if init was successful.
    } catch {
        // Handle the error if any.
        fatalError(error.localizedDescription)
    }
Resnet 50 error / SwiftUI
 
 
Q