# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 2
#     language: python
#     name: python2
# ---

import turicreate as tc

# ### Engenharia de Dados

# Carregando dataset
url = './dataset/'

data = tc.image_analysis.load_images(url)

# label (o que é)
data['foodType'] = data['path'].apply(lambda path: "Rice" if "rice" in path else "Soup")

# salvando no formato do turi
data.save("rice_or_soup.sframe")

# ### Aplicando modelo

dataBuffer = tc.SFrame("rice_or_soup.sframe")

# divisao treino e test
trainingBuffers, testingBuffers = dataBuffer.random_split(0.8)

# chamando e treiando o modelo
model = tc.image_classifier.create(trainingBuffers, target='foodType',model='squeezenet_v1.1')

# testando modelo
evaluations = model.evaluate(testingBuffers)

# Exportando para mlmodel, serve para usar em aplicativos iOS
model.export_coreml('RiceSoupClassifier.mlmodel')



StarcoderdataJupyterScriptsDedupFiltered