I'm able to convert a UIImage to a ARGB CVPixelBuffer, but now i'm trying to convert the UIImage to a grayscale one buffer.
I thought i had it since the code goes through but the coreML model complains saying: 
"Error Domain=com.apple.CoreML Code=1 "Image is not expected type 8-Gray, instead is Unsupported (40)"
Here is the grayscale CGContext I have so far:
public func pixelBufferGray(width: Int, height: Int) -> CVPixelBuffer? {
        var pixelBuffer : CVPixelBuffer?
        let attributes = [kCVPixelBufferCGImageCompatibilityKey: kCFBooleanTrue, kCVPixelBufferCGBitmapContextCompatibilityKey: kCFBooleanTrue]
        let status = CVPixelBufferCreate(kCFAllocatorDefault, Int(width), Int(height), kCVPixelFormatType_8IndexedGray_WhiteIsZero, attributes as CFDictionary, &pixelBuffer)
        guard status == kCVReturnSuccess, let imageBuffer = pixelBuffer else {
            return nil
        }
        CVPixelBufferLockBaseAddress(imageBuffer, CVPixelBufferLockFlags(rawValue: 0))
        let imageData =  CVPixelBufferGetBaseAddress(imageBuffer)
        guard let context = CGContext(data: imageData, width: Int(width), height:Int(height),
                                      bitsPerComponent: 8, bytesPerRow: CVPixelBufferGetBytesPerRow(imageBuffer),
                                      space: CGColorSpaceCreateDeviceGray(),
                                      bitmapInfo: CGImageAlphaInfo.none.rawValue) else {
                                        return nil
        }
        context.translateBy(x: 0, y: CGFloat(height))
        context.scaleBy(x: 1, y: -1)
        UIGraphicsPushContext(context)
        self.draw(in: CGRect(x:0, y:0, width: width, height: height) )
        UIGraphicsPopContext()
        CVPixelBufferUnlockBaseAddress(imageBuffer, CVPixelBufferLockFlags(rawValue: 0))
        return imageBuffer
    }
Any help would be greatly appreciated