Git Product home page Git Product logo

cognitive-services-python-sdk-samples's Introduction

page_type languages products description urlFragment
sample
python
azure
These samples will show you how to get up and running using the Python SDKs for various Cognitive Services services.
cognitive-services-python-sdk-samples

Cognitive Services Python SDK Samples

These samples will show you how to get up and running using the Python SDKs for various Cognitive Services services. They'll cover a few rudimentary use cases and hopefully express best practices for interacting with the data from these APIs.

Features

This project framework provides examples for the following services:

Knowledge

Language

Search

Vision

We provide several meta-packages to help you install several packages at a time. Please note that meta-packages are only recommended for development purpose. It's recommended in production to always pin specific version of individual packages.

Getting Started

Prerequisites

  1. A cognitive services API key with which to authenticate the SDK's calls. Create a new Azure account, and try Cognitive Services for free.

Subscription keys are usually per service. For example, the subscription key for Spell Check will not be the same than Custom Search. Read the previous sign up link or the Azure portal for details on subscription keys.

Installation

  1. If you don't already have it, install Python.

    This sample (and the SDK) is compatible with Python 2.7, 3.3, 3.4, 3.5 and 3.6.

  2. General recommendation for Python development is to use a Virtual Environment. For more information, see https://docs.python.org/3/tutorial/venv.html

    Install and initialize the virtual environment with the "venv" module on Python 3 (you must install virtualenv for Python 2.7):

    python -m venv mytestenv # Might be "python3" or "py -3.6" depending on your Python installation
    cd mytestenv
    source bin/activate      # Linux shell (Bash, ZSH, etc.) only
    ./scripts/activate       # PowerShell only
    ./scripts/activate.bat   # Windows CMD only
    

Quickstart

  1. Clone the repository.

    git clone https://github.com/Azure-Samples/cognitive-services-python-sdk-samples.git
    
  2. Install the dependencies using pip.

    cd cognitive-services-python-sdk-samples
    pip install -r requirements.txt
    
  3. Set up the environment variable LUIS_SUBSCRIPTION_KEY with your key if you want to execute LUIS tests.

  4. Set up the environment variable SPELLCHECK_SUBSCRIPTION_KEY with your key if you want to execute SpellCheck tests.

  5. Set up the environment variable TEXTANALYTICS_SUBSCRIPTION_KEY with your key if you want to execute TextAnalytics tests. You might override too TEXTANALYTICS_LOCATION (westcentralus by default).

  6. Set up the environment variable AUTOSUGGEST_SUBSCRIPTION_KEY with your key if you want to execute Autosuggest tests.

  7. Set up the environment variable CUSTOMSEARCH_SUBSCRIPTION_KEY with your key if you want to execute CustomSearch tests.

  8. Set up the environment variable CUSTOMIMAGESEARCH_SUBSCRIPTION_KEY with your key if you want to execute CustomImageSearch tests.

  9. Set up the environment variable ENTITYSEARCH_SUBSCRIPTION_KEY with your key if you want to execute EntitySearch tests.

  10. Set up the environment variable IMAGESEARCH_SUBSCRIPTION_KEY with your key if you want to execute ImageSearch tests.

  11. Set up the environment variable NEWSSEARCH_SUBSCRIPTION_KEY with your key if you want to execute NewsSearch tests.

  12. Set up the environment variable VIDEOSEARCH_SUBSCRIPTION_KEY with your key if you want to execute VideoSearch tests.

  13. Set up the environment variable VISUALSEARCH_SUBSCRIPTION_KEY with your key if you want to execute VideoSearch tests.

  14. Set up the environment variable WEBSEARCH_SUBSCRIPTION_KEY with your key if you want to execute WebSearch tests.

  15. Set up the environment variable COMPUTERVISION_SUBSCRIPTION_KEY with your key if you want to execute Computer Vision tests. You might override too COMPUTERVISION_LOCATION (westcentralus by default).

  16. Set up the environment variable CONTENTMODERATOR_SUBSCRIPTION_KEY with your key if you want to execute Content Moderator tests. You might override too CONTENTMODERATOR_LOCATION (westcentralus by default).

  17. Set up the environment variable CUSTOMVISION_TRAINING_KEY with your key and CUSTOMVISION_PREDICTION_ID with a valid prediction resource id if you want to execute CustomVision Training tests.

  18. Set up the environment variable CUSTOMVISION_PREDICTION_KEY with your key and CUSTOMVISION_PREDICTION_ID with a valid prediction resource id if you want to execute CustomVision Prediction tests.

Demo

A demo app is included to show how to use the project.

To run the complete demo, execute python example.py

To run each individual demo, point directly to the file. For example (i.e. not complete list):

  1. python samples/language/spellcheck_samples.py
  2. python samples/search/entity_search_samples.py
  3. python samples/search/video_search_samples.py
  4. python samples/vision/inkrecognizer_sample.py

To see the code of each example, simply look at the examples in the Samples folder. They are written to be isolated in scope so that you can see only what you're interested in.

Resources

cognitive-services-python-sdk-samples's People

Contributors

aahill avatar areddish avatar assafi avatar baranerf avatar chrishmsft avatar ctufts avatar dougiman avatar ericsk avatar iscai-msft avatar jwood803 avatar kpajdzik avatar lmazuel avatar microsoftopensource avatar mikedodaro avatar mohabghanem avatar moreover0 avatar msftgits avatar shigeyf avatar sptramer avatar v-jaswel avatar v-rajagt-zz avatar wiazur avatar xinyzhou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.