This file contains 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 Checkpoint { | |
/// ... | |
var userInfo: [String: Codable] = [:] | |
} | |
protocol Checkpointable { | |
init(checkpoint: Checkpoint) | |
This file contains 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
public class VisionFaceDetector { | |
private var faceRectangleRequest: VNDetectFaceRectanglesRequest! | |
public var boundingBoxes: [CGRect] = [] | |
public init() { | |
self.faceRectangleRequest = VNDetectFaceRectanglesRequest(completionHandler: { [weak self] (request, error) in | |
self?.handleFaces(request: request, error: error) | |
}) | |
self.faceRectangleRequest.preferBackgroundProcessing = false |
This file contains 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
DebugMenu.sharedManager.set(options: | |
[BoolOption(name: "Show feature points", | |
initialValue: false) | |
{ (showFeatures: Bool) in | |
if showFeatures { | |
self.sceneView.debugOptions.formUnion(ARSCNDebugOptions.showFeaturePoints) | |
} else { | |
self.sceneView.debugOptions.remove(ARSCNDebugOptions.showFeaturePoints) | |
} | |
}, |
This file contains 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 UIKit | |
class UserOptionsViewController: UITableViewController { | |
// 1 | |
var options: [Option] = [] | |
// 2 | |
fileprivate var registeredTypes: [ObjectIdentifier: UITableViewCell.Type] = [:] | |
This file contains 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
// Declare model class for the option | |
public class BoolOption: Option { | |
public typealias Handler = (Bool) -> Void | |
public var name: String | |
public internal(set) var value: Bool { | |
didSet { | |
self.onChangeHandler?(self.value) | |
} |
This file contains 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
public protocol OptionCell { | |
func configure(for option: Option) | |
} |
This file contains 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
public protocol Option: class { | |
var name: String { get } | |
} |
This file contains 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
// Retrieve results | |
guard let outputFeatures = featureProvider.featureValue(for: selectedModel.outputLayerName)?.multiArrayValue else { | |
fatalError("Couldn't retrieve features") | |
} | |
// Calculate total buffer size by multiplying shape tensor's dimensions | |
let bufferSize = outputFeatures.shape.lazy.map { $0.intValue }.reduce(1, { $0 * $1 }) | |
// Get data pointer to the buffer | |
let dataPointer = UnsafeMutableBufferPointer(start: outputFeatures.dataPointer.assumingMemoryBound(to: Double.self), |
This file contains 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 coremltools | |
coreml_model = coremltools.converters.caffe.convert(('hed_pretrained_bsds.caffemodel', 'deploy_main.prototxt'), | |
image_input_names='data', | |
is_bgr=True, | |
red_bias=122.67891434, green_bias=116.66876762, blue_bias=104.00698793) | |
coreml_model.author = 'Original paper: Xie, Saining and Tu, Zhuowen. Caffe implementation: Yangqing Jia. CoreML port: Andrey Volodin' | |
coreml_model.license = 'Unknown' | |
coreml_model.short_description = "Holistically-Nested Edge Detection" |