| 123456789101112131415161718192021222324252627282930313233343536 |
- #-*-coding:utf-8 -*-
- from aip import AipContentCensor
- APP_ID = "33751511"
- API_KEY = "gd8nik5KMNIbh76KGqYbFOCc"
- SECRET_KEY = "1m6HfzQVURFcu9ghmFHPje587slp5XG6"
- def get_file_content(filePath):
- with open(filePath, 'rb') as fp:
- return fp.read()
- def baidu_ai_detect_image(imgpath):
- """
- """
- client = AipContentCensor(APP_ID, API_KEY, SECRET_KEY)
- if "http://" or "https://" in imgpath:
- result = client.imageCensorUserDefined(imgpath)
- else:
- result = client.imageCensorUserDefined(get_file_content(imgpath))
- return result
- def baidu_ai_detect_txt(content):
- """
- """
- client = AipContentCensor(APP_ID, API_KEY, SECRET_KEY)
- result = client.textCensorUserDefined(content)
- return result
- if __name__ == "__main__":
- imgpath = "/tmp/test.png"
- baidu_ai_detect_image(imgpath)
|