利用机器智能提取图像信息的pypi包
cornea的Python项目详细描述
角膜
一个pypi包,用于使用机器智能提取有关图像的有洞察力的信息
要求
- python=3.7
安装
建议使用pip
或pip3
pip3 install cornea or python3 -m pip install cornea
设置
该包要求您将Microsoft Azure API凭据指定为环境变量。在终端中键入以下命令。或者,也可以在.bashrc
或.bash_profile
结尾处添加以下行。
exportAZURE_API_KEY={{{YOUR_API_KEY}}}exportAZURE_API_BASE_ENDPOINT={{{YOUR_API_REGION_BASE_URL}}}exportAZURE_API_VERSION={{{AZURE_API_VERSION}}}
示例:
exportAZURE_API_KEY=QmQZdzdQXftzrOOvCUC7tjx8wzZed8Wk exportAZURE_API_BASE_ENDPOINT=https://eastus.api.cognitive.microsoft.com exportAZURE_API_VERSION=v2.0
用法
fromcorneaimportdescImgFromURLanalysis=descImgFromURL("https://upload.wikimedia.org/wikipedia/commons/b/b9/CyprusShorthair.jpg")print(analysis)
输出
{'categories': [{'name': 'animal_cat', 'score': 0.99609375}], 'color': {'dominantColorForeground': 'Grey', 'dominantColorBackground': 'Grey', 'dominantColors': ['Grey'], 'accentColor': '5C4E3C', 'isBwImg': False, 'isBWImg': False}, 'description': {'tags': ['cat', 'indoor', 'laying', 'bed', 'sitting', 'white', 'brown', 'lying', 'small', 'large', 'sleeping'], 'captions': [{'text': 'a cat lying on a bed', 'confidence': 0.9512938154506553}]}, 'requestId': 'ef807a48-ecbf-4c30-883b-64a7d25683f2', 'metadata': {'width': 1024, 'height': 768, 'format': 'Jpeg'}}