Skip to content

Instantly share code, notes, and snippets.

@anyashka
anyashka / lunch_model.py
Last active January 24, 2024 16:34
Updatable Lunch Classifier for Core ML
# Creating a model with TuriCreate
import turicreate as tc
data = tc.image_analysis.load_images('image/train', with_path=True)
data['label'] = data['path'].apply(lambda path: 'healthy' if '/healthy' in path else 'fast food')
model = tc.image_classifier.create(data, target='label')
model.save("LunchImageClassifier.model")
model.export_coreml('LunchImageClassifier.mlmodel')