当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript tfjs-core.image类代码示例

本文整理汇总了TypeScript中@tensorflow/tfjs-core.image的典型用法代码示例。如果您正苦于以下问题:TypeScript image类的具体用法?TypeScript image怎么用?TypeScript image使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了image类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: switch

export let executeOp: OpExecutor = (node: Node, tensorMap: NamedTensorsMap,
                                    context: ExecutionContext):
                                       tfc.Tensor[] => {
  switch (node.op) {
    case 'resizeBilinear': {
      const images =
          getParamValue('images', node, tensorMap, context) as tfc.Tensor;
      const size = getParamValue('size', node, tensorMap, context) as number[];
      const alignCorners =
          getParamValue('alignCorners', node, tensorMap, context) as boolean;
      return [tfc.image.resizeBilinear(
          images as tfc.Tensor3D | tfc.Tensor4D, [size[0], size[1]],
          alignCorners)];
    }
    case 'resizeNearestNeighbor': {
      const images =
          getParamValue('images', node, tensorMap, context) as tfc.Tensor;
      const size = getParamValue('size', node, tensorMap, context) as number[];
      const alignCorners =
          getParamValue('alignCorners', node, tensorMap, context) as boolean;
      return [tfc.image.resizeNearestNeighbor(
          images as tfc.Tensor3D | tfc.Tensor4D, [size[0], size[1]],
          alignCorners)];
    }
    default:
      throw TypeError(`Node type ${node.op} is not implemented`);
  }
};
开发者ID:oveddan,项目名称:tfjs-converter,代码行数:28,代码来源:image_executor.ts

示例2: async

export let executeOp: OpExecutor = async(
    node: Node, tensorMap: NamedTensorsMap,
    context: ExecutionContext): Promise<tfc.Tensor[]> => {
  switch (node.op) {
    case 'nonMaxSuppression': {
      const boxes =
          getParamValue('boxes', node, tensorMap, context) as tfc.Tensor;
      const scores =
          getParamValue('scores', node, tensorMap, context) as tfc.Tensor;
      const maxOutputSize =
          getParamValue('maxOutputSize', node, tensorMap, context) as number;
      const iouThreshold =
          getParamValue('iouThreshold', node, tensorMap, context) as number;
      const scoreThreshold =
          getParamValue('scoreThreshold', node, tensorMap, context) as number;
      return [await tfc.image.nonMaxSuppressionAsync(
          boxes as tfc.Tensor2D, scores as tfc.Tensor1D, maxOutputSize,
          iouThreshold, scoreThreshold)];
    }
    case 'whereAsync': {
      return [await tfc.whereAsync(
          getParamValue('condition', node, tensorMap, context) as tfc.Tensor)];
    }
    default:
      throw TypeError(`Node type ${node.op} is not implemented`);
  }
};
开发者ID:oveddan,项目名称:tfjs-converter,代码行数:27,代码来源:dynamic_executor.ts

示例3: getImageTensor

    const outTensor = tf.tidy(() => {
      const params = this._params

      let imgTensor = getImageTensor(netInput)
      const [height, width] = imgTensor.shape.slice(1)
      imageDimensions = { width, height }


      // work with 128 x 128 sized face images
      if (imgTensor.shape[1] !== 128 || imgTensor.shape[2] !== 128) {
        imgTensor = tf.image.resizeBilinear(imgTensor, [128, 128])
      }

      let out = conv(imgTensor, params.conv0_params)
      out = maxPool(out)
      out = conv(out, params.conv1_params)
      out = conv(out, params.conv2_params)
      out = maxPool(out)
      out = conv(out, params.conv3_params)
      out = conv(out, params.conv4_params)
      out = maxPool(out)
      out = conv(out, params.conv5_params)
      out = conv(out, params.conv6_params)
      out = maxPool(out, [1, 1])
      out = conv(out, params.conv7_params)
      const fc0 = tf.relu(fullyConnectedLayer(out.as2D(out.shape[0], -1), params.fc0_params))
      const fc1 = fullyConnectedLayer(fc0, params.fc1_params)

      return fc1
    })
开发者ID:BakirDiyar,项目名称:face-api.js,代码行数:30,代码来源:FaceLandmarkNet.ts

示例4: padToSquare

    return tf.tidy(() => {

      let x = padToSquare(getImageTensor(netInput), true)
      // work with 150 x 150 sized face images
      if (x.shape[1] !== 150 || x.shape[2] !== 150) {
        x = tf.image.resizeBilinear(x, [150, 150])
      }
      x = normalize(x)

      let out = convDown(x, this._params.conv32_down)
      out = tf.maxPool(out, 3, 2, 'valid')

      out = residual(out, this._params.conv32_1)
      out = residual(out, this._params.conv32_2)
      out = residual(out, this._params.conv32_3)

      out = residualDown(out, this._params.conv64_down)
      out = residual(out, this._params.conv64_1)
      out = residual(out, this._params.conv64_2)
      out = residual(out, this._params.conv64_3)

      out = residualDown(out, this._params.conv128_down)
      out = residual(out, this._params.conv128_1)
      out = residual(out, this._params.conv128_2)

      out = residualDown(out, this._params.conv256_down)
      out = residual(out, this._params.conv256_1)
      out = residual(out, this._params.conv256_2)
      out = residualDown(out, this._params.conv256_down_out)

      const globalAvg = out.mean([1, 2]) as tf.Tensor2D
      const fullyConnected = tf.matMul(globalAvg, this._params.fc)

      return fullyConnected
    })
开发者ID:BakirDiyar,项目名称:face-api.js,代码行数:35,代码来源:FaceRecognitionNet.ts

示例5:

  return tf.tidy(() => {

    const resized = tf.image.resizeBilinear(x, resizedImageSize, false)
    return tf.sub(tf.mul(resized, weight), bias)

  })
开发者ID:BakirDiyar,项目名称:face-api.js,代码行数:6,代码来源:resizeLayer.ts


注:本文中的@tensorflow/tfjs-core.image类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。