From 59b37d515c2ceedd446115049594ee7856163e28 Mon Sep 17 00:00:00 2001 From: va barbosa Date: Mon, 10 Jun 2019 21:36:39 -0400 Subject: [PATCH] add encodeBase64, decodeBase64 see - https://github.com/tensorflow/tfjs-core/pull/1779 - https://github.com/tensorflow/tfjs-converter/pull/376 --- src/nodejs_kernel_backend.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/nodejs_kernel_backend.ts b/src/nodejs_kernel_backend.ts index b485a7ce..f45cf3f1 100644 --- a/src/nodejs_kernel_backend.ts +++ b/src/nodejs_kernel_backend.ts @@ -19,7 +19,7 @@ import {BackendTimingInfo, DataMover, DataType, fill, KernelBackend, ones, Rank, rsqrt, Scalar, scalar, ShapeMap, Tensor, Tensor1D, tensor1d, Tensor2D, tensor2d, Tensor3D, tensor3d, Tensor4D, tidy, util} from '@tensorflow/tfjs-core'; import {Conv2DInfo, Conv3DInfo} from '@tensorflow/tfjs-core/dist/ops/conv_util'; import {Activation} from '@tensorflow/tfjs-core/dist/ops/fused_util'; -import {Tensor5D} from '@tensorflow/tfjs-core/dist/tensor'; +import {StringTensor, Tensor5D} from '@tensorflow/tfjs-core/dist/tensor'; import {upcastType} from '@tensorflow/tfjs-core/dist/types'; import {isNullOrUndefined} from 'util'; @@ -1552,6 +1552,21 @@ export class NodeJSKernelBackend extends KernelBackend { return this.executeSingleOutput('LinSpace', opAttrs, inputs) as Tensor1D; } + encodeBase64(str: StringTensor|Tensor, pad = false): + T { + const opAttrs = + [{name: 'pad', type: this.binding.TF_ATTR_BOOL, value: pad}]; + return this.executeSingleOutput('EncodeBase64', opAttrs, [str as Tensor]) as + T; + } + + decodeBase64(str: StringTensor|Tensor): T { + // return this.executeSingleInput('DecodeBase64', str as Tensor) as Tensor; + const opAttrs: TFEOpAttr[] = []; + return this.executeSingleOutput('DecodeBase64', opAttrs, [str as Tensor]) as + T; + } + fromPixels( pixels: ImageData|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement, numChannels: number): Tensor3D {