{"cells":[{"metadata":{"_uuid":"348e7562b7b2e0db614e14c57088c1cedfc1cdc1"},"cell_type":"markdown","source":"This short and simple notebook provides code to compare image metadata with images on a one-by-one basis. The purpose of which is to promote an understanding of how the output of Google's Vision API relates to each image. This is useful for those looking to explore and incorporate the image metadata into their solution for this competition. See https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate for details regarding the contents of the json files. I'm new to Kaggle kernels and a novice coder in R so any suggestions on improvements are greatly appreciated."},{"metadata":{"_uuid":"db35173ccdb6d7f80bb2fe0a3c88a3ff935d12ef","_execution_state":"idle","trusted":true,"_kg_hide-output":true,"scrolled":true},"cell_type":"code","source":"#Loading necessary libraries.\nlibrary(jsonlite)\nlibrary(imager)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"30dab4742b59f014e0bd9a21a7659468eec92870"},"cell_type":"code","source":"#Create a string vector of the filenames of all images in train_metadata.zip.\ntrain_metadata_filenames <- dir('../input/train_metadata', '*.json', full.names = T)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"adf008d4ff51450bccf68a2fbed02f6490edbee9"},"cell_type":"code","source":"#Inpect image metadata interactively.\nimage_metadata_name <- '015c75c9e-3' #use the Data Environment to interactively explore images within train_images.zip. Enter image name here.\nimage_metadata_index_pos <- which(train_metadata_filenames %in% paste0('../input/train_metadata/',image_metadata_name,'.json'))\nmetadata_sample <- fromJSON(train_metadata_filenames[image_metadata_index_pos])\nprint(train_metadata_filenames[image_metadata_index_pos])\nprint(metadata_sample)\nplot(load.image(paste0('../input/train_images/',image_metadata_name,'.jpg')), axes = F)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"scrolled":true,"_uuid":"968a64eef346006edc5676dcba8404447e846b73"},"cell_type":"code","source":"#Inpect randomly selected image metadata.\nimage_metadata_name <- (image_metadata_name <- sample(train_metadata_filenames,1)) #use the Data Environment to interactively explore images within train_images.zip. Enter image name here.\nimage_metadata_index_pos <- which(train_metadata_filenames %in% image_metadata_name)\nmetadata_sample <- fromJSON(train_metadata_filenames[image_metadata_index_pos])\nprint(train_metadata_filenames[image_metadata_index_pos])\nprint(metadata_sample)\nplot(load.image(paste0(sub('metadata', 'images', substr(image_metadata_name,1, nchar(image_metadata_name)-5)), '.jpg')), axes = F)","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"R","language":"R","name":"ir"},"language_info":{"mimetype":"text/x-r-source","name":"R","pygments_lexer":"r","version":"3.4.2","file_extension":".r","codemirror_mode":"r"}},"nbformat":4,"nbformat_minor":1}