I am posting this so it might help people having problems with “Deep Learning for Coders with fastai and PyTorch,” Chapter 2. Specifically, when using Bing to download images (in the case of the book, some bear images), there was no output for the ‘ims’ variable using the first ‘search_images_bing’ command.
The first problem to solve is to get a valid Bing key. There are several other threads that tell how to do this. I found the following links useful (YMMV):
I was able to run the first ‘search_images_bing’ cell, but ‘ims’ was empty. The solution was to change ‘ims = results.attrgot(‘content_url’)’ to ‘ims = results.attrgot(‘contentUrl’)’. It appears the interface has changed from “snake-case” to “camel-case”. Please see a entry in the ‘results’ variable below.
print(results[0])
{‘webSearchUrl’: ‘https://www.bing.com/images/search?view=detailv2&FORM=OIIRPO&q=teddy+bear&id=4F0E26E252CB0E110486422838F8FA743803ED1C&simid=608054600839201200’, ‘name’: “The History Of The Teddy Bear | The Sit 'n Sleep Blog”, ‘thumbnailUrl’: ‘https://tse3.mm.bing.net/th?id=OIP.o4OMl6yom_BbsBZyu38vgHaGC&pid=Api’, ‘datePublished’: ‘2020-04-18T19:53:00.0000000Z’, ‘isFamilyFriendly’: True, ‘contentUrl’: ‘https://www.sitnsleep.com/blog/wp-content/uploads/2019/04/teddy-bear.jpg’, ‘hostPageUrl’: ‘https://www.sitnsleep.com/blog/the-history-of-the-teddy-bear/’, ‘contentSize’: ‘4075637 B’, ‘encodingFormat’: ‘jpeg’, ‘hostPageDisplayUrl’: ‘https://www.sitnsleep.com/blog/the-history-of-the-teddy-bear’, ‘width’: 3180, ‘height’: 2592, ‘hostPageFavIconUrl’: ‘https://www.bing.com/th?id=ODF.ljVnFDazZi5-SwOMxCCvTA&pid=Api’, ‘hostPageDomainFriendlyName’: “Sit 'n Sleep”, ‘thumbnail’: {‘width’: 474, ‘height’: 386}, ‘imageInsightsToken’: 'ccid/o4OMl6ycp_06E75F72442ADDFBF70C4F52E6F871E0mid_4F0E26E252CB0E110486422838F8FA743803ED1Csimid_608054600839201200thid_OIP.!_o4OMl6yom!_BbsBZyu38vgHaGC’, ‘insightsMetadata’: {‘pagesIncludingCount’: 11, ‘availableSizesCount’: 8}, ‘imageId’: ‘4F0E26E252CB0E110486422838F8FA743803ED1C’, ‘accentColor’: ‘AE5307’}
HTH