mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Fix
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 47 KiB |
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user