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 Foundation | |
import UIKit | |
import PlaygroundSupport | |
var myCanvas = MyDoodleCanvas() | |
myCanvas.backgroundColor = .white | |
myCanvas.isUserInteractionEnabled = true | |
var canvasView = UIView(frame: CGRect(x: 0, y: 0, width: 450, height: 630)) | |
myCanvas.frame = canvasView.frame |
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
module.exports = function(context, req) { | |
//context.log('Node.js HTTP trigger function processed a request. RequestUri=%s', req.originalUrl); | |
context.log('push data:', req.body); | |
var str = req.body; | |
var results = str.split("&"); | |
var slackText = getParam(results, "text").replace(/\+/g, " ").replace(/mytodo/g, ""); | |
var userName = getParam(results, "user_name").replace(/\+/g, " "); | |
context.log(getParam(results, "token")); |
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
#r "Newtonsoft.Json" | |
using System; | |
using System.Net; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Linq; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Linq; |
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
from coremltools.converters import sklearn as sklearn_to_ml | |
from sklearn.externals import joblib | |
model = joblib.load('mymodel.pkl') | |
print('Converting model') | |
coreml_model = sklearn_to_ml.convert(model) | |
print('Saving CoreML model') | |
coreml_model.save('mycoremlmodel.mlmodel') |
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 | |
#print(__doc__) | |
# Author: Gael Varoquaux <gael dot varoquaux at normalesup dot org> | |
# License: BSD 3 clause | |
# Standard scientific Python imports | |
import matplotlib.pyplot as plt | |
import pickle |
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
func drawStroke(context: CGContext?, touch: UITouch) { | |
let location = touch.location(in: self) | |
if touch.type == .stylus { | |
minX = min(minX, Int(location.x)) | |
minY = min(minY, Int(location.y)) | |
maxX = max(maxX, Int(location.x)) | |
maxY = max(maxY, Int(location.y)) | |
//.... | |
} | |
//.... |
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
func generateMultiArrayFrom(image: UIImage) -> MLMultiArray? { | |
guard let data = try? MLMultiArray(shape: [8,8], dataType: .double) else { | |
return nil | |
} | |
let hTileWidth = image.size.width / 8 | |
let vTileWidth = image.size.height / 8 | |
var xPos : CGFloat = 0 | |
var yPos : CGFloat = 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
func recognizeWithLocalModel(_ image: UIImage) { | |
if let data = generateMultiArrayFrom(image: image) { | |
guard let modelOutput = try? singleNumberModel?.prediction(input: data) else { | |
return | |
} | |
if let result = modelOutput?.classLabel { | |
self.addLabelForOCR(text: "\(result)") | |
} else { | |
print("no result available") |
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
let model = try VNCoreMLModel(for: catmoodprediction().model) | |
let request = VNCoreMLRequest(model: model, completionHandler: self.handleClassification) | |
var classificationRequest = [ request ] |
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
let image = UIImage(named:"catinmood") | |
do { | |
let pixelBuffer = image.pixelBuffer(width: 227, height:227) | |
let classifierRequestHandler = VNImageRequestHandler(cvPixelBuffer: pixelBuffer!, options: [:]) | |
try classifierRequestHandler.perform(classificationRequest!) | |
} catch { | |
print("something went terribly wrong during classification") | |
} |