Skip to content

Instantly share code, notes, and snippets.

Jameson Toole jamesonthecrow

Block or report user

Report or block jamesonthecrow

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jamesonthecrow / trainSubredditSuggester.swift
Created Nov 11, 2018
Train a text classification model with CreateML to suggest subreddits based on a proposed title.
View trainSubredditSuggester.swift
import CreateML
import Foundation
// Load our data into an MLDataTable object.
let dataFilename = "PATH/TO/data.json"
let data = try MLDataTable(contentsOf: URL(fileURLWithPath: dataFilename))
label string
View PoseEstimationViewController.swift
extension PoseEstimationViewController: AVCaptureVideoDataOutputSampleBufferDelegate {
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
// FritzVisionImage objects offer convient ways to manipulate
// images used as input to machine learning models.
// You can resize, crop, and scale images to your needs.
let image = FritzVisionImage(sampleBuffer: sampleBuffer, connection: connection)
// Set options for our pose estimation model using the constants
// we initialized earlier in the ViewController.
jamesonthecrow / ViewController.swift
Last active Jul 26, 2019
Pet Segmentation iOS View Controller with Fritz (
View ViewController.swift
class ViewController: UIViewController, UIImagePickerControllerDelegate,
UINavigationControllerDelegate {
/// The rest of the view controller...
/// Scores output from model greater than this value will be set as 1.
/// Lowering this value will make the mask more intense for lower confidence values.
var clippingScoresAbove: Double { return 0.6 }
/// Values lower than this value will not appear in the mask.
var zeroingScoresBelow: Double { return 0.4 }
jamesonthecrow /
Last active Jul 26, 2019
Pet Segmentation on Android with Fritz (
// Initialize the model included with the app
PetSegmentationOnDeviceModel onDeviceModel = new PetSegmentationOnDeviceModel();
FritzVisionSegmentPredictorOptions options = new FritzVisionSegmentPredictorOptions.Builder()
// Create the predictor with the Pet Segmentation model.
predictor = FritzVision.ImageSegmentation.getPredictor(onDeviceModel, options);
# Retrain the model with our new configuration and callback
model = build_model()
jamesonthecrow /
Created Jul 6, 2019
Mobile machine learning made easy with the Fritz CLI.
import fritz
import fritz.train
# Fritz needs to be configured first. Calling the fritz.Configure() method will
# read the credentials we setup for the CLI earlier.
# Create the callback
# Start by defining a training configuration and storing it as metadata
jamesonthecrow /
Last active Jul 6, 2019
Mobile machine learning with the Fritz CLI.
# Convert to mobile formats
import coremltools
import tensorflow as tf
import tempfile
def convert_to_coreml(model):
return coremltools.converters.keras.convert(
import keras
from keras.datasets import mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
def build_model():
input = keras.layers.Input((28, 28, 1))
out = keras.layers.Conv2D(16, 3, strides=2, activation='relu')(input)
jamesonthecrow / ViewController.swift
Last active Jun 11, 2019
Pet Segmentation iOS View Controller with Fritz (
View ViewController.swift
import UIKit
import AVFoundation
import Fritz
class ViewController: UIViewController, UIImagePickerControllerDelegate,
UINavigationControllerDelegate {
@IBOutlet var imageView: UIImageView!
var maskView: UIImageView!
var backgroundView: UIImageView!
jamesonthecrow /
Last active Jun 10, 2019
Pet Segmentation on Android with Fritz (
// Run the image through the model to identify pixels belonging to a pet.
FritzVisionSegmentResult segmentResult = predictor.predict(visionImage);
You can’t perform that action at this time.