Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a9e4f5d
added working samples for common and detection
iscai-msft Nov 12, 2018
aa2aa63
edited common and detection parameters and completed find_similar sample
iscai-msft Nov 13, 2018
02bc0fc
edited find_similar sample and added group sample
iscai-msft Nov 13, 2018
600718e
added identify sample
iscai-msft Nov 13, 2018
8b5ae88
added samples for verify
iscai-msft Nov 14, 2018
d4e40c5
finished samples and edited retrieval method of environment variables
iscai-msft Nov 14, 2018
7dd4a98
cleaned up samples, getting rid of unused imports and variables
iscai-msft Nov 14, 2018
37c029c
consolidated the face samples into a single python file face_samples.py
iscai-msft Nov 16, 2018
c6f6987
edited Custom Search Samples, as CustomSearchAPI has been switched to…
iscai-msft Nov 17, 2018
ba597d4
got rid of changes I accidentally made to text analytics and visual s…
iscai-msft Nov 17, 2018
b7f3c9f
working on custom image search
iscai-msft Nov 19, 2018
260577d
Merge branch 'master' of github.com:Azure-Samples/cognitive-services-…
iscai-msft Nov 20, 2018
eda83d2
added custom image search samples and updated the README
iscai-msft Nov 20, 2018
f3d5939
added .idea folder to gitignore
iscai-msft Nov 20, 2018
8e8b52c
about to test whether style changes break the sample
iscai-msft Nov 27, 2018
b867e0b
updated custom image search to adress requested changes
iscai-msft Nov 27, 2018
656ad6f
slight spacing formatting
iscai-msft Nov 30, 2018
86da07d
Merge branch 'master' into cognitive_services_python_image_search_sam…
lmazuel Dec 11, 2018
d0317ef
Update requirements.txt
lmazuel Dec 11, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This project framework provides examples for the following services:

* Using the **Bing Autosuggest SDK** [azure-cognitiveservices-search-customsearch](http://pypi.python.org/pypi/azure-cognitiveservices-search-autosuggest) for the [Autosuggest API](https://azure.microsoft.com/services/cognitive-services/autosuggest/)
* Using the **Bing Custom Search SDK** [azure-cognitiveservices-search-customsearch](http://pypi.python.org/pypi/azure-cognitiveservices-search-customsearch) for the [Custom Search API](https://azure.microsoft.com/services/cognitive-services/bing-custom-search/)
* Using the **Bing Custom Image Search SDK** [azure-cognitiveservices-search-customimagesearch](http://pypi.python.org/pypi/azure-cognitiveservices-search-customimagesearch) for the [Custom Image Search API](https://azure.microsoft.com/services/cognitive-services/bing-custom-search/)
* Using the **Bing Entity Search SDK** [azure-cognitiveservices-search-entitysearch](http://pypi.python.org/pypi/azure-cognitiveservices-search-entitysearch) for the [Entity Search API](https://azure.microsoft.com/services/cognitive-services/bing-entity-search-api/)
* Using the **Bing Image Search SDK** [azure-cognitiveservices-search-imagesearch](http://pypi.python.org/pypi/azure-cognitiveservices-search-imagesearch) for the [Image Search API](https://azure.microsoft.com/services/cognitive-services/bing-image-search-api/)
* Using the **Bing News Search SDK** [azure-cognitiveservices-search-newssearch](http://pypi.python.org/pypi/azure-cognitiveservices-search-newssearch) for the [News Search API](https://azure.microsoft.com/services/cognitive-services/bing-news-search-api/)
Expand Down Expand Up @@ -85,6 +86,7 @@ We provide several meta-packages to help you install several packages at a time.
4. 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).
3. Set up the environment variable `AUTOSUGGEST_SUBSCRIPTION_KEY` with your key if you want to execute Autosuggest tests.
3. Set up the environment variable `CUSTOMSEARCH_SUBSCRIPTION_KEY` with your key if you want to execute CustomSearch tests.
3. Set up the environment variable `CUSTOMIMAGESEARCH_SUBSCRIPTION_KEY` with your key if you want to execute CustomImageSearch tests.
3. Set up the environment variable `ENTITYSEARCH_SUBSCRIPTION_KEY` with your key if you want to execute EntitySearch tests.
4. Set up the environment variable `IMAGESEARCH_SUBSCRIPTION_KEY` with your key if you want to execute ImageSearch tests.
4. Set up the environment variable `NEWSSEARCH_SUBSCRIPTION_KEY` with your key if you want to execute NewsSearch tests.
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ azure-cognitiveservices-language-luis
azure-cognitiveservices-language-spellcheck
azure-cognitiveservices-language-textanalytics
azure-cognitiveservices-search-autosuggest
azure-cognitiveservices-search-customimagesearch
azure-cognitiveservices-search-customsearch>=0.2.0 # sample won't work with previous versions
azure-cognitiveservices-search-entitysearch
azure-cognitiveservices-search-imagesearch
Expand Down
40 changes: 40 additions & 0 deletions samples/search/custom_image_search_samples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from azure.cognitiveservices.search.customimagesearch import CustomImageSearchAPI
from msrest.authentication import CognitiveServicesCredentials

SUBSCRIPTION_KEY_ENV_NAME = "CUSTOMIMAGESEARCH_SUBSCRIPTION_KEY"


def custom_image_search_result_lookup(subscription_key):
"""CustomImageSearchResultLookup.

This will look up a single query (Xbox) and print out number of results, insights token, thumbnail url, content url for the first image result
"""

client = CustomImageSearchAPI(credentials=CognitiveServicesCredentials(subscription_key))
try:
image_results = client.custom_instance.image_search(query="Xbox", custom_config=1)
print("Searched for Query \" Xbox \"")

# WebPages
if image_results.value:
# find the first web page
first_image_result = image_results.value[0]

if first_image_result:
print("Image result count: {}".format(len(image_results.value)))
print("First image insights token: {}".format(first_image_result.image_insights_token))
print("First image thumbnail url: {}".format(first_image_result.thumbnail_url))
print("First image content url: {}".format(first_image_result.content_url))
else:
print("Couldn't find image results!")
else:
print("Couldn't find image results!")
except Exception as e:
print("encountered exception. " + str(e))


if __name__ == "__main__":
import sys, os.path
sys.path.append(os.path.abspath(os.path.join(__file__, "..", "..")))
from tools import execute_samples
execute_samples(globals(), SUBSCRIPTION_KEY_ENV_NAME)