Skip to content

Instantly share code, notes, and snippets.

@oem
Last active July 4, 2018 08:51
Show Gist options
  • Save oem/322dae2ed45a34fcc84ce324b84df7ed to your computer and use it in GitHub Desktop.
Save oem/322dae2ed45a34fcc84ce324b84df7ed to your computer and use it in GitHub Desktop.
labelling the beer dataset for our beer-o-mat app
import turicreate as tc
import re
import os
def path_as_label(path):
label = re.search('(?<=raw/)(.+)?/.+$', path).group(1)
label = label.replace('_', ' ')
return label.title()
img_path = os.path.join(os.path.dirname(__file__), 'data/raw')
data = tc.image_analysis.load_images(img_path, with_path=True)
data['label'] = data['path'].apply(path_as_label)
data.save(os.path.join(os.path.dirname(__file__),
'data/processed/beers.sframe'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment