cornea

A PyPI package to extract insightful information about an image using Machine Intelligence


Keywords
python, image-classification, pip, pypi-package, cognitive-services, microsoft-azure, image-analysis, cognitive-ser, image-classfication, image-recognition
License
MIT
Install
pip install cornea==1.1.0

Documentation

Cornea

PyPI - License Codacy Badge PyPI

A PyPI package to extract insightful information about an image using Machine Intelligence

Requirements

  • Python >=3.7

Installation

The recommended method to install this package is by using pip or pip3

pip3 install cornea
or
python3 -m pip install cornea

Setup

The package requires that you specify your Microsoft Azure API credentials as environment variables. Type the following commands in your terminal. Alternatively, you can also add the following lines at the end of .bashrc or .bash_profile.

export AZURE_API_KEY={{{YOUR_API_KEY}}}
export AZURE_API_BASE_ENDPOINT={{{YOUR_API_REGION_BASE_URL}}}
export AZURE_API_VERSION={{{AZURE_API_VERSION}}}

Example:

export AZURE_API_KEY=QmQZdzdQXftzrOOvCUC7tjx8wzZed8Wk
export AZURE_API_BASE_ENDPOINT=https://eastus.api.cognitive.microsoft.com
export AZURE_API_VERSION=v2.0

Usage

from cornea import descImgFromURL

analysis = descImgFromURL("https://upload.wikimedia.org/wikipedia/commons/b/b9/CyprusShorthair.jpg")
print(analysis)

Output

{'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'}}