Skip to content

Commit

Permalink
Fixed incorrect dimensions in JS only TensorFlow image loader
Browse files Browse the repository at this point in the history
  • Loading branch information
SimplyBoo committed Mar 21, 2021
1 parent e091239 commit 40fa5e6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/src/tasks/tensorflow/tensorflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ if (isAvxSupported()) {
function decodeImage(buffer: Buffer): TFJS.Tensor3D {
const decoded = PNG.sync.read(buffer);
const rgbaPixels = decoded.data;
const rgbPixels: number[] = Array(decoded.width * decoded.height * 3);
const rgbPixels = new Int32Array(decoded.width * decoded.height * 3);
for (let i = 0; i < decoded.width * decoded.height; i++) {
for (let channel = 0; channel < 3; channel++) {
rgbPixels[i * 3 + channel] = rgbaPixels[i * 4 + channel];
}
}
return tfjs.tensor3d(rgbPixels, [decoded.width, decoded.height, 3]);
return tfjs.tensor3d(rgbPixels, [decoded.height, decoded.width, 3], 'int32');
}
module.exports = {
...tfjs,
Expand Down

0 comments on commit 40fa5e6

Please sign in to comment.