I hereby claim:
- I am m25lazi on github.
- I am m25lazi (https://keybase.io/m25lazi) on keybase.
- I have a public key ASBXJ0Ym5z7ej1MlruGNMGncqXHyjm-mVtZ328UxyJC1xQo
To claim this, I am signing this object:
| /** | |
| Make a prediction using the convenience interface | |
| - parameters: | |
| - image: Input image to be classified as RGB image buffer, 299 pixels wide by 299 pixels high | |
| - throws: an NSError object that describes the problem | |
| - returns: the result of the prediction as Inceptionv3Output | |
| */ | |
| func prediction(image: CVPixelBuffer) throws -> Inceptionv3Output { | |
| let input_ = Inceptionv3Input(image: image) | |
| return try self.prediction(input: input_) |
| extension UIImage { | |
| func buffer() -> CVPixelBuffer? { | |
| return UIImage.buffer(from: self) | |
| } | |
| static func buffer(from image: UIImage) -> CVPixelBuffer? { | |
| // as explained in https://www.hackingwithswift.com/whats-new-in-ios-11 | |
| // ... | |
| } | |
I hereby claim:
To claim this, I am signing this object:
| network={ | |
| ssid="Your WiFi SSID" | |
| psk="Correct Password for the same" | |
| } |
| import Foundation | |
| import UIKit | |
| internal class ImageDownloader { | |
| let url: URL | |
| init(url: URL) { | |
| self.url = url | |
| } | |
| func fetch(then completion: @escaping (UIImage?, Error?) -> Void) { |
| /// Injecting fetcher to the fetch API, so that we get control of downloading outside of the User class | |
| func fetchProfileImage(fetcher: ImageDownloader, then completion: @escaping (Bool)-> Void) { | |
| fetcher.fetch { (image, error) in | |
| if let fetchError = error { | |
| print("Failed to fetch Image with error - \(fetchError)") | |
| completion(false) | |
| } else if let fetchedImage = image { | |
| print("Image fetched") | |
| self.iProfileImage = fetchedImage | |
| completion(true) |
| /// Mock Subclass of ImageDownloader | |
| /// Fetch API will return what you were passed while init. | |
| internal class MockImageDownloader: ImageDownloader { | |
| typealias MockResponse = (UIImage?, Error?) | |
| /// Mocked response. Pass this as part of init and this will be the response of fetch API | |
| let mockedResponse: MockResponse | |
| init(url: URL, response: MockResponse) { |
| /// Interface that fetches image from a source. | |
| /// Image can be fetched from a web service or even from a local source. | |
| internal protocol ImageFetcher { | |
| func fetch(then completion: @escaping (UIImage?, Error?) -> Void) | |
| } | |
| /// User Model | |
| public class User { | |
| // Stores the | |
| public var name: String |
| /// Interface that fetches image from a source. | |
| /// Image can be fetched from a web service or even from a local source. | |
| internal protocol ImageFetcher { | |
| func fetch(then completion: @escaping (UIImage?, Error?) -> Void) | |
| } | |
| /// ImageFetcher implementation to fetch image from web service | |
| internal class ImageDownloader: ImageFetcher { | |
| let url: URL | |
| init(url: URL) { |
| /// Mock Subclass of ImageDownloader | |
| /// Fetch API will return what you were passed while init. | |
| internal class MockImageDownloader: ImageFetcher { | |
| typealias MockResponse = (UIImage?, Error?) | |
| /// Mocked response. Pass this as part of init and this will be the response of fetch API | |
| let mockedResponse: MockResponse | |
| init(url: URL, response: MockResponse) { |