Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This guide shows you how to use the Computer Vision API in Python and how to visualize your results using popular libraries. You will use Jupyter to run the tutorial. To learn how to get started with interactive Jupyter notebooks, refer to the Jupyter Documentation.
- Python 2.7+ or 3.5+
- pip tool
- Jupyter Notebook installed
- Go to the Cognitive Vision Python GitHub repo.
- Click on the green button to clone or download the repo.
- Open a command prompt and navigate to the folder Cognitive-Vision-Python\Jupyter Notebook.
- Ensure you have all the required libraries by running the command
pip install requests opencv-python numpy matplotlib
from the command prompt. - Start Jupyter by running the command
jupyter notebook
from the command prompt. - In the Jupyter window, click on Computer Vision API Example.ipynb to open the tutorial notebook.
To use this notebook, you will need a subscription key for the Computer Vision API. Visit Azure portal to sign up Either the primary or the secondary key will work. Be sure to enclose the key in quotes to make it a string.
You will also need to make sure the _region
field matches the region that corresponds to your subscription.
# Variables
_region = 'chinanorth' #Here you enter the region of your subscription
_url = 'https://{}.api.cognitive.azure.cn/vision/v2.0/analyze'.format(_region)
_key = None #Here you have to paste your primary key
_maxNumRetries = 10
When you run the tutorial, you will be able to add images to analyze, both from a URL and from local storage. The script will display the images and analysis information in the notebook.