hot dog not hot dog

Job ID: 35452649

Budget: $30 – $250 USD

There are 2 functions in hot_dog_not_hot_dog.py, which you must complete, each are marked with TODO in comments and details of each are in the docstring comments in the file as well as below. You may add additional helper functions to hot_dog_not_hot_dog.py as desired. However, YOU MAY NOT CHANGE ANY OF THE FUCTION NAMES, RETURN TYPES, OR PARAMETER LISTS IN hot_dog_not_hot_dog.py.

The (already imported) hdnhd_utils.py module contains a function named detect_image_labels which takes a string which is either a filename for an image or a URL to an image. It returns an list of dictionaries that contains the information about the objects that are contained in the image as detected by Google Cloud Vision.

Functions You Must Implement: label_image

This function takes a single parameter, filename, a string that is the filename for the image. It then uses Google Cloud Vision API by calling hdnhd_utils.detect_image_labels to get a list of dictionaries that are what objects Google Cloud Vision thinks are in the image. The dictionary has keys as follows:

description - basically an object that Google Cloud Vision thinks is in the image, for example "Food"

score - how certain Google Cloud Vision is about it's guess, while this can be useful it is not something that is needed in this assignment so you can ignore it

topicality - you can ignore this (sometimes API's return stuff we don't need and so we just need to ignore it)

mid - you can ignore this one too

Using the list of dictionaries described above, your code will determine if the image contains a hot dog or not. HINT A linear search would be helpful. The function will then display the image using the 3rd party module Pillow. If the image contains a hot dog, then centered text with a green background and white text saying "Hot Dog" should be added at the top of the image, like so.IMPORTANT NOTE your code must work for any JPEG or PNG file fed to it. In other words, you cannot use a simple selection (if or switch) statement that checks the filename and displays "Hot Dog" or "Not Hot Dog" based off of that. Your decision about whether a hot dog exists in the image must come from code you write that (correctly) checks the results from hdnhd_utils.detect_image_labels.

As noted in the TODO comments in main, you must write the code to call the appropriate functions to do the following:

1. Prompt the user for a either a local (on the disc) JPG (JPEG) or PNG the URL to a JPG (JPEG) or PNG file.

2. then, as long as the user has entered a file, display the image in with either "Hot Dog" or "Not Hot Dog" displayed in the appropriate place/color on the image depending on whether Google Cloud Vision detects a hot dog in the image. If the user has NOT selected a file, then print an error, and exit the program with exit code 1.
Related categories: Python Coding