Skip to content

Instantly share code, notes, and snippets.

View azamsharp's full-sized avatar

Mohammad Azam azamsharp

View GitHub Profile
@azamsharp
azamsharp / .py
Created December 18, 2017 20:17
convertor output feature names
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'])
@azamsharp
azamsharp / .py
Created December 18, 2017 21:02
converting file
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'
)
@azamsharp
azamsharp / .py
Created December 18, 2017 21:23
convertor.py
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
@azamsharp
azamsharp / .py
Created December 20, 2017 15:22
Downloading Images Using Python
# 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
@azamsharp
azamsharp / .py
Created December 20, 2017 15:53
Tagging Images
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
@azamsharp
azamsharp / .py
Created December 20, 2017 16:21
Training Models Using Turi Create
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)
@azamsharp
azamsharp / .swift
Created December 22, 2017 21:43
Block class
class Block {
var index :Int = 0
var dateCreated :String
var previousHash :String!
var hash :String!
var nonce :Int
var data :String
var key :String {
@azamsharp
azamsharp / .swift
Created December 22, 2017 23:30
Blockchain class
class Blockchain {
private (set) var blocks :[Block] = [Block]()
init(_ genesisBlock :Block) {
addBlock(genesisBlock)
}
func addBlock(_ block :Block) {
@azamsharp
azamsharp / .swift
Created December 29, 2017 19:49
Block class
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]()
@azamsharp
azamsharp / .swift
Created December 29, 2017 19:54
Transactions
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