Project requirements
As shown in the figure below, the content of the picture is that the tag is divided into tag, and the washing standard is divided into water washing. If these two items are not included, they are marked as other
Pick out tag and wash pictures from tens of thousands of pictures
Sort out the mixed pictures
Implementation plan: Use EasyDL to customize the image classification algorithm of the AI training platform , train the model and call the trained model api to classify local images
Image data
Create image classification data set
Upload pictures-"Online annotation
After I finished marking 200 pictures, I found a more convenient way,
It is recommended to read more documents and explore more
Because I have three tags here, I divide the pictures under the corresponding tags, name the folder with the tag name and compress it into zip format, and upload the compressed package directly to automatically mark it.
Model processing
EasyDL custom AI training platform
in accordance with the official documentation training model step step by step operation can be, is a graphical interface can be quite convenient, I chose to deploy public cloud API, other deployment did not try, step by step training model test model Can
I personally put about 100 sheets under each of the three labels (not too detailed, more than 100 and 90),
Finally, the training and test results are okay. The accuracy rate can reach 95%
. After training, the model can be released, and it can be called only after it is released. According to the
official statement 通常的审核周期为T+1,即当天申请第二天可以审核完成
, my model was reviewed within 10 minutes after it was released.
Model use
Finally, the model is used. I mentioned that I used the public cloud API for deployment,
so the public cloud API I set up should be called when I use it. There are also operating instructions in this official document.
Because I personally use python3, the demo of the official document is still python2, which is not applicable
If you are interested here, you can take a look at it yourself, and you can also choose other languages to
call the image classification API.
The following is my own rewrite in python3 environment
# 先获取api token
# encoding:utf-8
import requests
# access_token: 要获取的Access Token;
# expires_in: Access Token的有效期(秒为单位,一般为1个月);
# client_id 为官网获取的AK, client_secret 为官网获取的SK
host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=【官网获取的AK】&client_secret=【官网获取的SK】'
response = requests.get(host)
if response:
print(response.json())
# 单张图片test
# encoding:utf-8
# import urllib2
from urllib.request import urlopen
import base64
import json
import urllib
pic_path = r"D:\Jupyter Notebook\水洗标\INSE-17.jpg"
'''
easydl图像分类
'''
request_url = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/classification/dpsxv1"
with open(pic_path, 'rb') as f:
base64_data = base64.b64encode(f.read())
s = base64_data.decode('UTF8')
params = {
"image": s, "top_num": "3"}
params = json.dumps(params)
access_token = response.json()['access_token']
request_url = request_url + "?access_token=" + access_token
session = requests.Session()
headers = {
'Content-Type': 'application/json'}
r = session.post(request_url, data=params, headers=headers)
print(r.text)
The output results are as follows, corresponding to each tag score,
the image file can be marked and classified according to the score. Is it really easy to use and free, and there are many other models open for research! And many free
low-code implementations of artificial intelligence algorithms! Come on! juvenile! ! !