Created
December 13, 2018 20:13
-
-
Save CibelePaulinoAndrade/1eaafad03ed4901f2150056af57a0b60 to your computer and use it in GitHub Desktop.
Core ML - Códigos utilizados na apresentação - Inteligência Computacional
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var model = Flowers() | |
guard let prediction = try? model.prediction(data: pixelBuffer!) else { | |
return | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
# In[1]: | |
import coremltools | |
# In[5]: | |
coreml_model = coremltools.converters.caffe.convert(('oxford102.caffemodel', 'deploy.prototxt'), image_input_names='data', class_labels='class_labels.txt') | |
# In[4]: | |
coreml_model.save('Flowers.mlmodel') | |
# In[ ]: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CreateMLUI | |
let builder = MLImageClassifierBuilder() | |
builder.showInLiveView() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
# In[1]: | |
import turicreate as tc | |
# In[14]: | |
data = tc.image_analysis.load_images('Pets-100', with_path=True) | |
# In[16]: | |
data['label'] = data['path'].apply(lambda path: 'dog' if '/Dog' in path else 'cat') | |
# In[17]: | |
train_data, test_data = data.random_split(0.8) | |
# In[15]: | |
model = tc.image_classifier.create(train_data, target = 'label') | |
# In[7]: | |
predictions = model.predict(test_data) | |
# In[8]: | |
metrics = model.evaluate(test_data) | |
# In[10]: | |
metrics['accuracy'] | |
# In[11]: | |
metrics['confusion_matrix'] | |
# In[12]: | |
model.save('mymodel.model') | |
# In[13]: | |
model.export_coreml('Pets.mlmodel') | |
# In[ ]: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment