Update index.js
Browse files
index.js
CHANGED
@@ -494,7 +494,7 @@ async function upscaleImage(imageBuffer) {
|
|
494 |
return new Promise(async (resolve, reject) => {
|
495 |
try {
|
496 |
const upscaler = new Upscaler();
|
497 |
-
const imageTensor =
|
498 |
|
499 |
const upscaledTensor = await upscaler.upscale(imageTensor, {
|
500 |
scale: 4, // upscale by a factor of 4
|
@@ -504,7 +504,7 @@ async function upscaleImage(imageBuffer) {
|
|
504 |
colorEnhance: true, // enhance colors
|
505 |
});
|
506 |
|
507 |
-
const upscaledImageBuffer = await
|
508 |
|
509 |
// dispose the tensors!
|
510 |
imageTensor.dispose();
|
|
|
494 |
return new Promise(async (resolve, reject) => {
|
495 |
try {
|
496 |
const upscaler = new Upscaler();
|
497 |
+
const imageTensor = tfjs.tensor3d(imageBuffer, [imageBuffer.height, imageBuffer.width, 3]);
|
498 |
|
499 |
const upscaledTensor = await upscaler.upscale(imageTensor, {
|
500 |
scale: 4, // upscale by a factor of 4
|
|
|
504 |
colorEnhance: true, // enhance colors
|
505 |
});
|
506 |
|
507 |
+
const upscaledImageBuffer = await tfjs.tensor3dToBuffer(upscaledTensor);
|
508 |
|
509 |
// dispose the tensors!
|
510 |
imageTensor.dispose();
|