1- from azure .cognitiveservices .search .imagesearch import ImageSearchAPI
1+ from azure .cognitiveservices .search .imagesearch import ImageSearchClient
22from azure .cognitiveservices .search .imagesearch .models import ImageType , ImageAspect , ImageInsightModule
33from msrest .authentication import CognitiveServicesCredentials
44
@@ -9,7 +9,10 @@ def image_search(subscription_key):
99
1010 This will search images for (canadian rockies) then verify number of results and print out first image result, pivot suggestion, and query expansion.
1111 """
12- client = ImageSearchAPI (CognitiveServicesCredentials (subscription_key ))
12+ client = ImageSearchClient (
13+ endpoint = "https://api.cognitive.microsoft.com/bing/v7.0" ,
14+ credentials = CognitiveServicesCredentials (subscription_key )
15+ )
1316
1417 try :
1518 image_results = client .images .search (query = "canadian rockies" )
@@ -62,7 +65,10 @@ def image_search_with_filters(subscription_key):
6265
6366 This will search images for (studio ghibli), filtered for animated gifs and wide aspect, then verify number of results and print out insightsToken, thumbnail url and web url of first result.
6467 """
65- client = ImageSearchAPI (CognitiveServicesCredentials (subscription_key ))
68+ client = ImageSearchClient (
69+ endpoint = "https://api.cognitive.microsoft.com/bing/v7.0" ,
70+ credentials = CognitiveServicesCredentials (subscription_key )
71+ )
6672
6773 try :
6874 image_results = client .images .search (
@@ -90,7 +96,10 @@ def image_trending(subscription_key):
9096
9197 This will search for trending images then verify categories and tiles.
9298 """
93- client = ImageSearchAPI (CognitiveServicesCredentials (subscription_key ))
99+ client = ImageSearchClient (
100+ endpoint = "https://api.cognitive.microsoft.com/bing/v7.0" ,
101+ credentials = CognitiveServicesCredentials (subscription_key )
102+ )
94103
95104 try :
96105 trending_result = client .images .trending ()
@@ -120,7 +129,10 @@ def image_detail(subscription_key):
120129
121130 This will search images for (degas) and then search for image details of the first image.
122131 """
123- client = ImageSearchAPI (CognitiveServicesCredentials (subscription_key ))
132+ client = ImageSearchClient (
133+ endpoint = "https://api.cognitive.microsoft.com/bing/v7.0" ,
134+ credentials = CognitiveServicesCredentials (subscription_key )
135+ )
124136
125137 try :
126138 image_results = client .images .search (query = "degas" )
0 commit comments