HomeiOS DevelopmentHow you can reshape MLMultipArray in Swift

How you can reshape MLMultipArray in Swift


I am making an attempt to colorize picture utilizing coreML, and the mannequin all the time returns (1, 3, 256, 256) as end result. I am reshaping to transform it to (3, 256, 256) however unsure if it is right approach. Is there no approach to choose solely first component in array?

let enter = attempt colorizer_coreInput(image_smallWith: resized)
let predicted = attempt colorizer_core(configuration: MLModelConfiguration()).prediction(enter: enter)
let array = predicted.colorized_small_image


var colori: UIImage?
attempt withExtendedLifetime(array) {
   if let reshapedArray = attempt? array.reshaped(to: [3, 256, 256]) {
       colori = createUIImage(fromFloatArray: reshapedArray, min: 0, max: 255)
   }
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments