在这里插入代码片
1.可以参考百度al社区的这个帖子https://ai.baidu.com/forum/topic/show/942310
2。不过他说的太笼统了,我进行一下补充:
client_id、client_secret是EasyDL定制训练平台 - 应用列表创建apl的API Key,Secret Key
test.py中的labelImg数据目录只能是英文和数字,不能有汉字和其他符号,里面的数据是图片和xml放一起。
而且他的工程有点小问题,我是师兄帮忙调试的。把里面的easydl模块参考我的换一下就行了,稍微修改后easydl模块代码
#coding=utf-8
#baidu ai easydl toolkit by kooky126
import urllib.request
import configparser
import os
import json
import re
import time
import base64
import cv2
import glob
from xml.etree import ElementTree as ET
#初始化token
def inittoken():
cf = configparser.ConfigParser()
a = cf.read("easydl.conf")
client_id = cf.get("token","client_id")
client_secret = cf.get("token","client_secret")
host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id='+client_id+'&client_secret='+client_secret
request = urllib.request.Request(host)
request.add_header('Content-Type', 'application/json; charset=UTF-8')
response = urllib.request.urlopen(request)
content = response.read()
if (content):
date = json.loads(content.decode('utf-8'))
if date['access_token']:
with open("token.json","w") as f:
json.dump(date,f)
return date['access_token']
else:
return None
else:
return