diff --git a/structures/Tensorflow.js b/structures/Tensorflow.js index 65da1c55..8006a0fa 100644 --- a/structures/Tensorflow.js +++ b/structures/Tensorflow.js @@ -83,7 +83,7 @@ module.exports = class Tensorflow { const stylizedImage = (await this.transformerModel.predict([loadedImage, stylePrediction])).squeeze(); loadedImage.dispose(); stylePrediction.dispose(); - const encodedImg = stylizedImage.mul(255).toInt(); + const encodedImg = stylizedImage.mul(255).clipByValue(0, 255).toInt(); stylizedImage.dispose(); const buffer = await tf.node.encodeJpeg(encodedImg); encodedImg.dispose();