• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript tfjs-core.image类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript tfjs-core.test_util类代码示例发布时间:2022-05-28
下一篇:
TypeScript tfjs-core.unstack函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap