mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-16 00:12:32 +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) {
|
async stylizeImage(image, styleImg) {
|
||||||
const imageTensor = await tf.node.decodeImage(image, 3);
|
const imageTensor = await tf.node.decodeImage(image, 3);
|
||||||
const [originalHeight, originalWidth] = imageTensor.shape.slice(0, 2);
|
const [originalHeight, originalWidth] = imageTensor.shape.slice(0, 2);
|
||||||
const desiredWidth = 400;
|
const desiredHeight = 400;
|
||||||
const aspectRatio = originalWidth / originalHeight;
|
const aspectRatio = originalWidth / originalHeight;
|
||||||
const newHeight = Math.round(desiredWidth / aspectRatio);
|
const newWidth = Math.round(desiredHeight / aspectRatio);
|
||||||
const resizedImage = tf.image.resizeBilinear(imageTensor, [newHeight, desiredWidth]);
|
const resizedImage = tf.image.resizeBilinear(imageTensor, [desiredHeight, newWidth]);
|
||||||
imageTensor.dispose();
|
imageTensor.dispose();
|
||||||
const loadedImage = resizedImage.toFloat().div(tf.scalar(255)).expandDims();
|
const loadedImage = resizedImage.toFloat().div(tf.scalar(255)).expandDims();
|
||||||
resizedImage.dispose();
|
resizedImage.dispose();
|
||||||
|
|||||||
Reference in New Issue
Block a user