Visit the following webpage: https://archive.org/details/National_Geographic_Wallpapers This webpage hosts a collection of 506 images from National Geographic Magazine with most of these images previously being part of an international photography contest. Your task is to randomly choose 5 images and identify the objects within those images using Google’s vision API. Submit your iPython notebook code, and screenshots of output as shown below. You may need to reactivate your Google vision API account (or billing information for trial cycles) if you haven’t used it recently.  Here is the sample code import base64 import urllib import os import io import PIL from IPython.display import display, Image GOOGLE_API_KEY = '' #Use your Google API key here pip install google-api-python-client from googleapiclient.discovery import build service = build('vision', 'v1', developerKey=GOOGLE_API_KEY) cat = 'C:\\Users\\Instagram and neural networks\\cat.jpg' def label_image(path=None, URL=None, max_results=5):     if URL is not None:         image_content=base64.b64encode(urllib.request.urlopen(URL).read())     else:         image_content=base64.b64encode(open(path,'rb').read())     service_request=service.images().annotate(body={         'requests':[{             'image':{                 'content': image_content.decode('UTF-8')             },             'features': [{                 'type': 'LABEL_DETECTION',                 'maxResults': max_results             }]         }]     })     labels = service_request.execute()['responses'][0]['labelAnnotations']     if URL is not None:         display(Image(url=URL))     else:         display(Image(path))     for label in labels:         print('[{0:3.0f}%]: {1}'.format(label['score']*100, label['description']))     return label_image(cat)

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter13: Web Site Applications
Section: Chapter Questions
Problem 3E
icon
Related questions
Question

Visit the following webpage: https://archive.org/details/National_Geographic_Wallpapers
This webpage hosts a collection of 506 images from National Geographic Magazine with most of these
images previously being part of an international photography contest. Your task is to randomly choose 5
images and identify the objects within those images using Google’s vision API. Submit your iPython
notebook code, and screenshots of output as shown below.

You may need to reactivate your Google vision API account (or billing information for trial cycles) if you
haven’t used it recently. 

Here is the sample code

import base64

import urllib

import os

import io

import PIL

from IPython.display import display, Image

GOOGLE_API_KEY = '' #Use your Google API key here

pip install google-api-python-client

from googleapiclient.discovery import build

service = build('vision', 'v1', developerKey=GOOGLE_API_KEY)

cat = 'C:\\Users\\Instagram and neural networks\\cat.jpg'

def label_image(path=None, URL=None, max_results=5):
    if URL is not None:
        image_content=base64.b64encode(urllib.request.urlopen(URL).read())
    else:
        image_content=base64.b64encode(open(path,'rb').read())
    service_request=service.images().annotate(body={
        'requests':[{
            'image':{
                'content': image_content.decode('UTF-8')
            },
            'features': [{
                'type': 'LABEL_DETECTION',
                'maxResults': max_results
            }]
        }]
    })
    labels = service_request.execute()['responses'][0]['labelAnnotations']
    if URL is not None:
        display(Image(url=URL))
    else:
        display(Image(path))
    for label in labels:
        print('[{0:3.0f}%]: {1}'.format(label['score']*100, label['description']))
    return

label_image(cat)

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Properties of CSS
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage