If you need to have it in the form [width, height, 1]:
tf.browser.fromPixels(image)
.mean(2)
.toFloat()
.expandDims(-1)
If you need in the form [1, width, height, 1]:
tf.browser.fromPixels(image)
.mean(2)
.toFloat()
.expandDims(0)
.expandDims(-1)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…