Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
let modelConfig = MLModelConfiguration() | |
modelConfig.computeUnits = .cpuAndGPU | |
let updateTask = try MLUpdateTask(forModelAt: modelURL, trainingData: batchProvider(), configuration: modelConfig, | |
progressHandlers: MLUpdateProgressHandlers(forEvents: [.trainingBegin,.epochEnd], | |
progressHandler: { (contextProgress) in | |
print(contextProgress.event) | |
}) { (finalContext) in | |
if finalContext.task.error?.localizedDescription == nil |
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 <Foundation/Foundation.h> | |
NS_ASSUME_NONNULL_BEGIN | |
@interface TorchModule : NSObject | |
- (nullable instancetype)initWithFileAtPath:(NSString*)filePath | |
NS_SWIFT_NAME(init(fileAtPath:))NS_DESIGNATED_INITIALIZER; | |
+ (instancetype)new NS_UNAVAILABLE; | |
- (instancetype)init NS_UNAVAILABLE; |
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 "TorchModule.h" | |
#import <LibTorch/LibTorch.h> | |
@implementation TorchModule { | |
@protected | |
torch::jit::script::Module _impl; | |
} | |
- (nullable instancetype)initWithFileAtPath:(NSString*)filePath { | |
self = [super init]; |
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
var imageView: UIImageView? | |
var button: UIButton? | |
var predictionLabel : UILabel? | |
func buildUI() | |
{ | |
imageView = UIImageView(frame: .zero) | |
imageView?.image = UIImage(named: "placeholder") | |
imageView?.contentMode = .scaleAspectFit |
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 func showActionSheet(sender: UIButton) | |
{ | |
let alert = UIAlertController(title: "Select Image", message: nil, preferredStyle: .actionSheet) | |
alert.addAction(UIAlertAction(title: "Camera", style: .default, handler: { _ in | |
self.launchCamera() | |
})) | |
alert.addAction(UIAlertAction(title: "Photos Library", style: .default, handler: { _ in | |
self.showPhotosLibrary() | |
})) |
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 | |
extension UIImage { | |
func resized(to newSize: CGSize, scale: CGFloat = 1) -> UIImage { | |
let format = UIGraphicsImageRendererFormat.default() | |
format.scale = scale | |
let renderer = UIGraphicsImageRenderer(size: newSize, format: format) | |
let image = renderer.image { _ in | |
draw(in: CGRect(origin: .zero, size: newSize)) | |
} |
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.keras.convert('model.h5', input_names=['image'], output_names=['output'], | |
image_input_names='image') | |
coreml_model.author = 'Anupam Chugh' | |
coreml_model.short_description = 'Cat Dog Classifier converted from a Keras model' | |
coreml_model.input_description['image'] = 'Takes as input an image' | |
coreml_model.output_description['output'] = 'Prediction as cat or dog' |
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
struct ContentView: View { | |
var body: some View { | |
PolylineMapView() | |
} | |
} | |
struct PolylineMapView: UIViewRepresentable { | |
func makeCoordinator() -> MapViewCoordinator{ | |
return MapViewCoordinator(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
func makeUIView(context: Context) -> ASAuthorizationAppleIDButton { | |
if UIScreen.main.traitCollection.userInterfaceStyle == .dark{ | |
return ASAuthorizationAppleIDButton(authorizationButtonType: .signIn, authorizationButtonStyle: .white) | |
} | |
else{ | |
return ASAuthorizationAppleIDButton(authorizationButtonType: .signIn, authorizationButtonStyle: .black) | |
} | |
} |
OlderNewer