Azure AI 水果分类模型

创建水果分类模型

模型已经创建好,代码在此:

https://github.com/MicrosoftDocs/mslearn-oxford.create-image-recognition-with-azure-iot-edge/tree/main/modules/ImageClassifierService/cv-amd64

Azure 自定义视觉服务是创建图像分类机器学习模型的简单方法,无需成为数据科学或机器学习专家。 可上传多个已标记图像的集合。 例如,可以上传一组香蕉图像,并将其标记为“香蕉”。

本模块将使用预生成的分类模型。 图像分类模块是从 Azure 自定义视觉创建和导出的。

查看 cv-amd64 文件夹下 README.txt文件:

首先,编译Docker镜像,并发布(运行)为本地地址

# Custom Vision Dockerfile
Exported from customvision.ai.

## Build

```bash
docker build -t <your image name> .
```

### Build ARM container on x64 machine

Export "ARM" Dockerfile from customvision.ai. Then build it using docker buildx command.
```bash
docker buildx build --platform linux/arm/v7 -t <your image name> --load .
```

## Run the container locally
```bash
docker run -p 127.0.0.1:80:80 -d <your image name>
```

## Image resizing
By default, we run manual image resizing to maintain parity with CVS webservice prediction results.
If parity is not required, you can enable faster image resizing by uncommenting the lines installing OpenCV in the Dockerfile.

随后,如果是在Linux环境没有用户桌面,可以使用 curl 命令测试

Then use your favorite tool to connect to the end points.

POST http://127.0.0.1/image with multipart/form-data using the imageData key
e.g
    curl -X POST http://127.0.0.1/image -F imageData=@some_file_name.jpg

POST http://127.0.0.1/image with application/octet-stream
e.g.
    curl -X POST http://127.0.0.1/image -H "Content-Type: application/octet-stream" --data-binary @some_file_name.jpg

POST http://127.0.0.1/url with a json body of { "url": "<test url here>" }
e.g.
    curl -X POST http://127.0.0.1/url -d '{ "url": "<test url here>" }'

For information on how to use these files to create and deploy through AzureML check out the readme.txt in the azureml directory.

我测试了几次

curl -X POST http://127.0.0.1/url -d '{ "url": "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fqqpublic.qpic.cn%2Fqq_public%2F0%2F0-2667564742-449B66415D4E8A971E1495102FF1462D%2F0%3Ffmt%3Djpg%26size%3D42%26h%3D508%26w%3D900%26ppv%3D1.jpg&refer=http%3A%2F%2Fqqpublic.qpic.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1641007378&t=7d2156e89eee36b6cd8065d6f1da46da" }'
{"created":"2021-12-03T06:24:46.317757","id":"","iteration":"","predictions":[{"boundingBox":null,"probability":8.666000212542713e-05,"tagId":"","tagName":"Banana"},{"boundingBox":null,"probability":1.5800000028320937e-06,"tagId":"","tagName":"Green Apple"},{"boundingBox":null,"probability":0.9999083280563354,"tagId":"","tagName":"Hand"},{"boundingBox":null,"probability":5.100000066704524e-07,"tagId":"","tagName":"Purple Grapes"},{"boundingBox":null,"probability":2.9800000902469037e-06,"tagId":"","tagName":"Red Apple"}],"project":""}


curl -X POST http://127.0.0.1/url -d '{ "url": "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fm.360buyimg.com%2Fpop%2Fjfs%2Ft22510%2F310%2F1732366219%2F240203%2F814a940d%2F5b695dadN58168f6d.png&refer=http%3A%2F%2Fm.360buyimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1641104786&t=3d77a973c880076f7a7fca63795063a4" }'
{"created":"2021-12-03T06:27:18.323786","id":"","iteration":"","predictions":[{"boundingBox":null,"probability":0.0006651600124314427,"tagId":"","tagName":"Green Apple"},{"boundingBox":null,"probability":9.989999853132758e-06,"tagId":"","tagName":"Hand"},{"boundingBox":null,"probability":0.09840962290763855,"tagId":"","tagName":"Orange"},{"boundingBox":null,"probability":1.1000000199601345e-07,"tagId":"","tagName":"Purple Grapes"},{"boundingBox":null,"probability":0.9009151458740234,"tagId":"","tagName":"Red Apple"}],"project":""}


curl -X POST http://127.0.0.1/url -d '{ "url": "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Ff.3dxy.com%2FManual%2Fpic%2F2016%2F0324%2F08%2F180919041044_846676_water.jpg&refer=http%3A%2F%2Ff.3dxy.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1641104951&t=b9679b2d0800c73448fde4ff3c152bd0" }'
{"created":"2021-12-03T06:29:26.897402","id":"","iteration":"","predictions":[{"boundingBox":null,"probability":1.0,"tagId":"","tagName":"Banana"},{"boundingBox":null,"probability":5.99999978589949e-08,"tagId":"","tagName":"Hand"}],"project":""}

可见水果主要有这几种:

"Green Apple", "Orange" "Purple Grapes" "Red Apple" "Banana"。

参见:

创建水果分类模型 - Learn | Microsoft Docs

项目全文: GitHub - MicrosoftDocs/mslearn-oxford.create-image-recognition-with-azure-iot-edge: Microsoft Learn Repo for MS Learn Module oxford.create-image-recognition-with-azure-iot-edge This module provides a tutorial To enable visually impaired people to use the self checkout, the system will include image to speech capability.

上一篇:文章翻译|Semblance: An empirical similarity kernel on probability spaces


下一篇:Beta分布 原理理解及python 绘图