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 tfcoreml as tf_converter | |
tf_converter.convert(tf_model_path = 'inception_v1_2016_08_28_frozen.pb', | |
mlmodel_path = 'InceptionV1.mlmodel', | |
output_feature_names = ['InceptionV1/Logits/Predictions/Softmax:0']) |
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 tfcoreml as tf_converter | |
tf_converter.convert(tf_model_path = 'inception_v1_2016_08_28_frozen.pb', | |
mlmodel_path = 'InceptionV1.mlmodel', | |
output_feature_names = ['InceptionV1/Logits/Predictions/Softmax:0'], | |
image_input_names = 'input:0', | |
class_labels = 'imagenet_slim_labels.txt' | |
) |
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 tfcoreml as tf_converter | |
tf_converter.convert(tf_model_path = 'inception_v1_2016_08_28_frozen.pb', | |
mlmodel_path = 'InceptionV1.mlmodel', | |
output_feature_names = ['InceptionV1/Logits/Predictions/Softmax:0'], | |
image_input_names = 'input:0', | |
class_labels = 'imagenet_slim_labels.txt', | |
red_bias = -1, | |
green_bias = -1, | |
blue_bias = -1, | |
image_scale = 2.0/255.0 |
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
# this script is used to download the images using the provided url | |
import requests | |
import ntpath | |
# the file which contain the images | |
image_urls_file_name = 'images_urls_cats.txt' | |
# the destination of the images inside the images folder | |
destination_folder = 'images/cat/' | |
# save image data |
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 turicreate as tc | |
# load the images | |
data = tc.image_analysis.load_images('images', with_path = True) | |
data['label'] = data['path'].apply(lambda path:'dog' if 'dog' in path else 'cat') | |
print(data.groupby('label',[tc.aggregate.COUNT])) | |
# save the data |
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 turicreate as tc | |
# load the data | |
data = tc.SFrame('cats-dogs.sframe') | |
train_data, test_data = data.random_split(0.8) | |
model = tc.image_classifier.create(train_data, target='label') | |
predictions = model.predict(test_data) |
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
class Block { | |
var index :Int = 0 | |
var dateCreated :String | |
var previousHash :String! | |
var hash :String! | |
var nonce :Int | |
var data :String | |
var key :String { |
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
class Blockchain { | |
private (set) var blocks :[Block] = [Block]() | |
init(_ genesisBlock :Block) { | |
addBlock(genesisBlock) | |
} | |
func addBlock(_ block :Block) { |
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
class Block : Codable { | |
var index :Int = 0 | |
var dateCreated :String | |
var previousHash :String! | |
var hash :String! | |
var nonce :Int | |
var message :String = "" | |
private (set) var transactions :[Transaction] = [Transaction]() | |
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
class Transaction :Codable { | |
var from :String | |
var to :String | |
var amount :Double | |
init(from :String, to :String, amount :Double) { | |
self.from = from | |
self.to = to | |
self.amount = amount |