如何在tensorflow js中获取tf.toPixels()的return值的Promise Value
How to get the PromiseValue of the return value of tf.toPixels() in tensorflowjs
如图,是使用console.log(tf.toPixels())得到的输出。如何在 PromiseValue 中获取 Uint8ClampedArray 数组?
要么使用 .then(callback)
,其中回调是一个函数并获取已解析的 Uint8ClampedArray
作为参数。
或者如果你在异步环境中,你可以简单地使用 await
:
async function run(){
const pixels = await tf.toPixels();
}
如图,是使用console.log(tf.toPixels())得到的输出。如何在 PromiseValue 中获取 Uint8ClampedArray 数组?
要么使用 .then(callback)
,其中回调是一个函数并获取已解析的 Uint8ClampedArray
作为参数。
或者如果你在异步环境中,你可以简单地使用 await
:
async function run(){
const pixels = await tf.toPixels();
}