Case Study 2: Data Transformation Stage 2

Artificial intelligence content labels using API

I wrote a Python script, based on samples provided in the Google Cloud Vision API documentation, that runs all of the images in the same folder as the script through the Google Cloud Vision API and pulls content labels for each image. I ran this script on both the base set of full-size images and on the reduced-size set of images. The output of the script is a CSV with each result for each image on a separate line. Google Cloud Vision most commonly returned 9 or 10 labels for each image.

I did not incur any costs using the Google Cloud Vision API at this scale. Up to 1000 units of analysis are free per month. I used 766 units (1 unit each for label detection per image in the 2 datasets of 383 images). A larger scale analysis would incur costs.

The Google Cloud Vision API returned 3,704 labels for the unmodified set of New York City Instagram images. It returned 3,538 labels for the reduced resolution set of images.

The Python scripts I wrote and the output CSVs from my interaction with the Google Cloud Vision API are available at the link below this section’s commentary and critique.

 

Context and critique

As stated in the introduction, I went into this project fully aware that the Google Cloud Vision AI is opaque and the labels assigned are based on unknown machine learning image sets. The thing to keep in mind here is that the AI is not providing a definitive determination of image contents, but rather an interpretation – the foundations of which are obscured.

One potential point of weakness in the data flow at this stage is in the Python script used to interact with the Google Cloud Vision API. My script seems to be interacting with the AI as desired, but code is an easy place for undesired functionality to slip in, particularly with less experienced coders like myself. My script outputted the results as a series of bracket-enclosed lists with values in quotes separated by commas, which was not readable as a standard CSV as-was.

Another process weakness came from initially using Excel to view my generated CSV. One of the label results contained a circumflex accent mark (‘Fête’). Excel does not generate UTF-8 compliant CSVs, and so rendered this result as ‘F√™te’. I switched to LibreOffice and the word was rendered correctly.

Of note: while generating this data I included “stage1” in the output name but while writing this up I realized this is stage 2. I fix my number scheme going forward, but did not want to post-facto edit these.

Stage 2 data consists of 2 scripts and 2 output CSVs. Click the links below to download from GitHub.

RIGHT CLICK TO DOWNLOAD – NYC Script

RIGHT CLICK TO DOWNLOAD – NYC Output CSV

RIGHT CLICK TO DOWNLOAD – NYC 25% Script

RIGHT CLICK TO DOWNLOAD – NYC 25% Output CSV

 

Continue on to the next section

Return to table of contents

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *