* Take an array of images (represented as typedarrays) and return * a tensor representing them. * * @param {Float32Array[]} imagesData * * @returns {Tensor3d} tensor of input images
(imagesData)
| 103 | * @returns {Tensor3d} tensor of input images |
| 104 | */ |
| 105 | function batchImages(imagesData) { |
| 106 | const numImages = imagesData.length; |
| 107 | const flat = []; |
| 108 | for (let i = 0; i < numImages; i++) { |
| 109 | const image = imagesData[i]; |
| 110 | for (let j = 0; j < image.length; j++) { |
| 111 | flat.push(image[j]); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | const batchedTensor = |
| 116 | tf.tensor3d(flat, [numImages, IMAGE_WIDTH, IMAGE_HEIGHT], 'float32'); |
| 117 | |
| 118 | return batchedTensor; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Convert an image represented as a typed array to a JIMP object. |