标签: microsoft-custom-vision

使用带有Tensorflow JS的自定义视觉导出模型并输入图像

我是tensorflow.js和tensorflow的新手

上下文:我们已经使用自定义视觉训练了一个模型,以便从图像中识别头发的长度:短,中,长。该模型已导出,我们希望将其与tensorflow js一起在本地使用。从自定义视觉导出的文件是* .pb文件和labels.txt文件。

我使用了tensorflowjs_converter python脚本,这是我用来在json模型中转换冻结模型* .pb的命令:

tensorflowjs_converter --input_format=tf_frozen_model --output_node_names='model_outputs' --output_json OUTPUT_JSON C:\python\tf_models\hairlength\model.pb C:\python\tf_models\exports\
Run Code Online (Sandbox Code Playgroud)

然后,将这个model.json和碎片粘贴到我的有角客户端的资产文件夹中。然后,我尝试加载模型,并给他一张图像以进行预测,但我所得到的只是索引值超出范围,因为我只需要0:长,1:中,2:短发即可。这是控制台的截图 预测清单

这是我在客户端(打字稿)中用于预测的类:

import * as tf from '@tensorflow/tfjs';

// import {HAIRLENGTH_LABELS} from './hairlength';
import { FrozenModel } from '@tensorflow/tfjs';

const MODEL = 'assets/models/hairlength/model.json';
const INPUT_NODE_NAME = 'model_outputs';
const OUTPUT_NODE_NAME = 'model_outputs';
const PREPROCESS_DIVISOR = tf.scalar(255 / 2);

export class MobileNetHairLength {

  private model: FrozenModel;
  private labels = ['long', 'mid', 'short'];

  constructor() {}

  async load(){
    this.model = await tf.loadGraphModel(MODEL);
  }

  dispose() {
    if (this.model) {
      this.model.dispose();
    } …
Run Code Online (Sandbox Code Playgroud)

tensorflow angular tensorflow.js tensorflowjs-converter microsoft-custom-vision

11
推荐指数
1
解决办法
688
查看次数

Custom_Vision_Prediction_3.0 REST API 给出 ​​401 错误

我正在尝试调用自定义视觉预测分类 RestAPI 端点(https://southcentralus.dev.cognitive.microsoft.com/docs/services/Custom_Vision_Prediction_3.0/operations/5c82db60bf6a2b11a8247c15

我正在使用美国中南部端点

我从资源管理 Azure 门户中的密钥部分获取了所需的训练和预测密钥

以下是我调用自定义视觉预测分类 RestAPI 端点时得到的响应

{

"error": {
"code": "401",
"message": "The ClassifyImage Operation under Custom_Vision_Prediction_3.0 API is not supported with the current subscription key and pricing tier Custom_Vision.Training.S0."
}
}
Run Code Online (Sandbox Code Playgroud)

我可以看到它说我当前的定价层不支持 3.0 API,但计划 S0(标准)每 1k 图像花费 0.35 美元,而我的订阅计划是即用即付

那么为什么我会收到此错误?

任何帮助表示赞赏

在此输入图像描述

azure azure-cognitive-services microsoft-custom-vision

3
推荐指数
1
解决办法
1363
查看次数

如何将形式 [xmin ymin xmax ymax] 转换为图像中标准化的 [xy 宽度高度]?

我正在使用 Microsoft 的CustomVision.ai构建自定义视觉应用程序。

我正在使用本教程

在对象检测项目中标记图像时,需要使用标准化坐标指定每个标记对象的区域。

我有一个 XML 文件,其中包含有关图像的注释,例如名为sample_1.jpg

<annotation>
        <filename>sample_1.jpg</filename>
    <size>
        <width>410</width>
        <height>400</height>
        <depth>3</depth>
    </size>
    <object>
        <bndbox>
            <xmin>159</xmin>
            <ymin>15</ymin>
            <xmax>396</xmax>
            <ymax>302</ymax>
        </bndbox>
    </object>
</annotation>
Run Code Online (Sandbox Code Playgroud)

我必须根据提供的教程将边界框坐标从 xmin,xmax,ymin,ymax 转换为标准化的 x,y,w,h 坐标。

谁能给我一个转换函数?

python object-detection microsoft-custom-vision

2
推荐指数
2
解决办法
4452
查看次数

CustomVision API 返回“操作返回无效状态代码:'NotFound'”

我正在使用 Nuget 包 Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction

我在 Custom Vision 门户中创建了一个 Custom Vision 应用程序并获得了 API 密钥和一个项目 ID。

每当我尝试向 API 发出请求时,总是会抛出以下异常:

HttpOperationException: 操作返回了无效的状态代码“NotFound”

这是我的代码:

        HttpClient httpClient = new HttpClient();
        CustomVisionPredictionClient customVisionPredictionClient = new CustomVisionPredictionClient(httpClient, false)
        {
            ApiKey = PredictionKey,
            Endpoint = PredictionEndpoint,
        };
        var result = customVisionPredictionClient.PredictImageAsync(CUSTOM_VISION_PROJECT_GUID, imageData);        
Run Code Online (Sandbox Code Playgroud)

我尝试了几个不同的端点:

https://southcentralus.api.cognitive.microsoft.com/customvision/v2.0/Prediction https://southcentralus.api.cognitive.microsoft.com/customvision/Prediction/v1.0 https://southcentralus.api。 cognitive.microsoft.com/customvision/v1.1/Prediction

尽管在门户网站上列出的是列表中的第一个。我还成功地在 Azure 上导出了我的应用程序,这为我提供了列表中的第二个端点,但没有再成功。

我还按照我发现的类似问题中的建议设置了默认迭代(CustomVision: Operation returns an invalid status code: 'NotFound')。

我已经尝试过这个示例https://github.com/Microsoft/Cognitive-CustomVision-Windows/tree/master/Samples/CustomVision.Sample它使用不推荐使用的 Windows 客户端,至少确保我的项目信息是正确的,我能够访问 API。

任何见解将不胜感激

c# azure azure-cognitive-services microsoft-custom-vision

1
推荐指数
1
解决办法
3971
查看次数