diff --git a/assets/images/spaghetti.jpg b/assets/images/spaghetti.jpg index 03e77174..7827d9e5 100644 Binary files a/assets/images/spaghetti.jpg and b/assets/images/spaghetti.jpg differ diff --git a/structures/Tensorflow.js b/structures/Tensorflow.js index 7234737e..0e42c0bb 100644 --- a/structures/Tensorflow.js +++ b/structures/Tensorflow.js @@ -74,10 +74,10 @@ module.exports = class Tensorflow { async stylizeImage(image, styleImg) { const imageTensor = await tf.node.decodeImage(image, 3); const [originalHeight, originalWidth] = imageTensor.shape.slice(0, 2); - const desiredWidth = 400; + const desiredHeight = 400; const aspectRatio = originalWidth / originalHeight; - const newHeight = Math.round(desiredWidth / aspectRatio); - const resizedImage = tf.image.resizeBilinear(imageTensor, [newHeight, desiredWidth]); + const newWidth = Math.round(desiredHeight / aspectRatio); + const resizedImage = tf.image.resizeBilinear(imageTensor, [desiredHeight, newWidth]); imageTensor.dispose(); const loadedImage = resizedImage.toFloat().div(tf.scalar(255)).expandDims(); resizedImage.dispose();