How you can make .correct request for CoreML Segmentation


Im engaged on a bakground removing app , the place Im doing the duty utilizing this perform , however this isn’t so correct . I discovered that Im not requesting correct output right here . I have to implement two line in my perform .

Two line :

var segmentationRequest = VNGeneratePersonSegmentationRequest()
segmentationRequest.qualityLevel = . correct

My Operate :

func removeBackground(picture:UIImage) -> UIImage?{
    let resizedImage = picture.resized(to: CGSize(width: 513, top: 513))
    if let pixelBuffer = resizedImage.pixelBuffer(width: 
    Int(resizedImage.measurement.width), top: Int(resizedImage.measurement.top)){
        if let outputImage = (attempt? modelCore.prediction(picture: 
           pixelBuffer))?.semanticPredictions.picture(min: 0, max: 1, axes: (0,0,1)), 
    let outputCIImage = CIImage(picture:outputImage){
            if let maskImage = removeWhitePixels(picture:outputCIImage), 
    let resizedCIImage = CIImage(picture: resizedImage), let compositedImage = 
           composite(picture: resizedCIImage, masks: maskImage){
                return UIImage(ciImage: compositedImage).resized(to: CGSize(width: 
                       picture.measurement.width, top: picture.measurement.top))
            }
        }
    }
    return nil
}