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
@objc protocol VideoRangeSliderDelegate | |
{ | |
func videoRange (videoRange:VideoRangeSlider, didChangeLeftPosition:CGFloat, rightPosition:CGFloat) | |
optional func videoRange(videoRange:VideoRangeSlider, didGestureStateEndedLeftPosition:CGFloat, rightPosition:CGFloat) | |
} | |
// Usage ensuring call if method is implemented | |
delegate?.videoRange?(self, didGestureStateEndedLeftPosition: self.leftPosition, rightPosition: self.rightPosition) |
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 | |
@IBDesignable | |
class CustomView: UIView { | |
@IBInspectable var gradient:Bool = false { | |
didSet { | |
if gradient | |
{ | |
let topColor = UIColor(red: 3/256, green: 51/256, blue: 75/256, alpha: 1.0) |
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 | |
@IBDesignable | |
class CustomView: UIView { | |
@IBInspectable var cornerRadius: CGFloat = 0 { | |
didSet { | |
layer.cornerRadius = cornerRadius | |
layer.masksToBounds = cornerRadius > 0 | |
} |
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 | |
@IBDesignable | |
class CustomView: UIView { | |
var fromColor: UIColor? | |
var toColor: UIColor? | |
var gradientLayer: CAGradientLayer? | |
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
func drawRoutes(sourceLocation:CLLocationCoordinate2D , destinationLocation:CLLocationCoordinate2D) | |
{ | |
let sourcePlacemark = MKPlacemark(coordinate: sourceLocation, addressDictionary: nil) | |
let destinationPlacemark = MKPlacemark(coordinate: destinationLocation, addressDictionary: nil) | |
let sourceMapItem = MKMapItem(placemark: sourcePlacemark) | |
let destinationMapItem = MKMapItem(placemark: destinationPlacemark) | |
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
@objc protocol LocationSelectorDelegate: class { | |
func showMap(tag: Int) | |
} | |
@IBDesignable | |
class LocationSelectorView: UIView { | |
@IBOutlet weak var delegate: LocationSelectorDelegate? | |
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
def get_model(): | |
input_tensor = Input(shape=(224, 224, 3)) # this assumes K.image_data_format() == 'channels_last' | |
# create the base pre-trained model | |
base_model = ResNet50(input_tensor=input_tensor,weights='imagenet',include_top=False) | |
for layer in base_model.layers: | |
layer.trainable=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
def compile_model(compiledModel): | |
compiledModel.compile(loss=keras.losses.categorical_crossentropy, | |
optimizer=Adadelta(), | |
metrics=['accuracy']) |
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
def modelFitGenerator(fitModel): | |
num_train_samples = sum([len(files) for r, d, files in os.walk(train_data_dir)]) | |
num_valid_samples = sum([len(files) for r, d, files in os.walk(validation_data_dir)]) | |
num_train_steps = math.floor(num_train_samples/batch_size) | |
num_valid_steps = math.floor(num_valid_samples/batch_size) | |
train_datagen = ImageDataGenerator( | |
rotation_range=90, |
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
def saveCoreMLModel(kerasModel): | |
coreml_model = coremltools.converters.keras.convert(kerasModel, | |
input_names=['input'], | |
output_names=['probs'], | |
image_input_names='input', | |
predicted_feature_name='predictedMoney', | |
class_labels = 'drive/Resnet/labels.txt') | |
coreml_model.save('resnet50custom.mlmodel') | |
print('CoreML model saved') |
OlderNewer