{"action":"created","comment":{"url":"https://api.github.com/repos/xmartlabs/Bender/pulls/comments/174565025","pull_request_review_id":103940805,"id":174565025,"diff_hunk":"@@ -0,0 +1,162 @@\n+//\n+//  InceptionExample.swift\n+//  Example\n+//\n+//  Created by Mathias Claassen on 2/7/18.\n+//\n+\n+import MetalPerformanceShaders\n+import MetalPerformanceShadersProxy\n+import MetalKit\n+import MetalBender\n+import UIKit\n+\n+@available(iOS 11.0, *)\n+class InceptionViewController: UIViewController, UINavigationControllerDelegate {\n+\n+    var inception: Network?\n+    var mobilenetwork: Network!\n+    var model: mobilenet!\n+\n+    var selectedIndex = 0\n+    var commandQueue: MTLCommandQueue!\n+\n+    var textureLoader: MTKTextureLoader!\n+    @IBOutlet weak var imageView: UIImageView!\n+    @IBOutlet weak var label: UILabel!\n+    var classLabels: [String]?\n+    var inceptionLabels: [String]?\n+    \n+    override func viewDidLoad() {\n+        super.viewDidLoad()\n+        self.commandQueue = Device.shared.makeCommandQueue()\n+        textureLoader = MTKTextureLoader(device: Device.shared)\n+        setupNetwork()\n+        classLabels = readClassLabels(\"mobilenet_labels\")\n+        inceptionLabels = readClassLabels(\"imagenet_label_strings\")\n+        model = mobilenet()\n+    }\n+\n+    func setupNetwork() {\n+        guard let mobilenetUrl = Bundle.main.url(forResource: \"mobilenet_frozen\", withExtension: \"pb\") else {\n+            return\n+        }\n+        let converter = TFConverter.default()\n+\n+        mobilenetwork = Network.load(url: mobilenetUrl, inputSize: LayerSize(h: 224, w: 224, f: 3), converter: converter, performInitialize: false)\n+\n+        // after adding all our layers we are able to initialize the network\n+        mobilenetwork.addPreProcessing(layers: [Neuron(type: ActivationNeuronType.custom(neuron: MPSCNNNeuronLinear(device: Device.shared, a: 2.0, b: -1)), id: \"scale_neuron\")])\n+        mobilenetwork.initialize()\n+\n+        guard let inceptionUrl = Bundle.main.url(forResource: \"inception_v3\", withExtension: \"pb\") else {\n+            print(\"Download Inception from: http://download.tensorflow.org/models/inception_v3_2016_08_28.tar.gz\" +\n+                  \" and freeze it using Benderthon or download a frozen .pb file. Leave it as 'inception_v3.pb' in the Example/data folder\")\n+            return\n+        }\n+        inception = Network.load(url: inceptionUrl, inputSize: LayerSize(h: 299, w: 299, f: 3), converter: converter, performInitialize: false)\n+\n+        // after adding all our layers we are able to initialize the network\n+        inception?.addPreProcessing(layers: [Neuron(type: ActivationNeuronType.custom(neuron: MPSCNNNeuronLinear(device: Device.shared, a: 2.0, b: -1)))])\n+        inception?.initialize()\n+    }\n+\n+    @IBAction func runNetwork(_ sender: Any) {\n+        if selectedIndex == 0 {\n+            guard let image = imageView.image?.toMPS(loader: textureLoader) else {\n+                return\n+            }\n+            mobilenetwork.run(input: image, queue: commandQueue) { [weak self] result in\n+                let arr = result.toArray()\n+                let top5 = arr.argsort(by: > ).prefix(5)\n+                self?.label.text = top5.reduce(\"\") {\n+                    return $0 + (self?.classLabels?[$1] ?? \"__\") + \"\\n\"\n+                }\n+            }\n+        } else if selectedIndex == 2 {\n+            guard let inception = inception, let image = imageView.image?.toMPS(loader: textureLoader) else {\n+                return\n+            }\n+            inception.run(input: image, queue: commandQueue) { [weak self] result in","path":"Example/Example/InceptionExample.swift","position":80,"original_position":80,"commit_id":"18ee67f61c74be8663e22db8f78c5128e5368fdc","original_commit_id":"18ee67f61c74be8663e22db8f78c5128e5368fdc","user":{"login":"dernster","id":5302420,"avatar_url":"https://avatars3.githubusercontent.com/u/5302420?v=4","gravatar_id":"","url":"https://api.github.com/users/dernster","html_url":"https://github.com/dernster","followers_url":"https://api.github.com/users/dernster/followers","following_url":"https://api.github.com/users/dernster/following{/other_user}","gists_url":"https://api.github.com/users/dernster/gists{/gist_id}","starred_url":"https://api.github.com/users/dernster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dernster/subscriptions","organizations_url":"https://api.github.com/users/dernster/orgs","repos_url":"https://api.github.com/users/dernster/repos","events_url":"https://api.github.com/users/dernster/events{/privacy}","received_events_url":"https://api.github.com/users/dernster/received_events","type":"User","site_admin":false},"body":"maybe encapsulate this repeated logic of getting the image from the imageView and running the network","created_at":"2018-03-14T18:29:21Z","updated_at":"2018-03-14T18:45:48Z","html_url":"https://github.com/xmartlabs/Bender/pull/98#discussion_r174565025","pull_request_url":"https://api.github.com/repos/xmartlabs/Bender/pulls/98","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/xmartlabs/Bender/pulls/comments/174565025"},"html":{"href":"https://github.com/xmartlabs/Bender/pull/98#discussion_r174565025"},"pull_request":{"href":"https://api.github.com/repos/xmartlabs/Bender/pulls/98"}}},"pull_request":{"url":"https://api.github.com/repos/xmartlabs/Bender/pulls/98","id":174426703,"html_url":"https://github.com/xmartlabs/Bender/pull/98","diff_url":"https://github.com/xmartlabs/Bender/pull/98.diff","patch_url":"https://github.com/xmartlabs/Bender/pull/98.patch","issue_url":"https://api.github.com/repos/xmartlabs/Bender/issues/98","number":98,"state":"open","locked":false,"title":"Add Mobilenet and Inception example","user":{"login":"mats-claassen","id":8573865,"avatar_url":"https://avatars2.githubusercontent.com/u/8573865?v=4","gravatar_id":"","url":"https://api.github.com/users/mats-claassen","html_url":"https://github.com/mats-claassen","followers_url":"https://api.github.com/users/mats-claassen/followers","following_url":"https://api.github.com/users/mats-claassen/following{/other_user}","gists_url":"https://api.github.com/users/mats-claassen/gists{/gist_id}","starred_url":"https://api.github.com/users/mats-claassen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mats-claassen/subscriptions","organizations_url":"https://api.github.com/users/mats-claassen/orgs","repos_url":"https://api.github.com/users/mats-claassen/repos","events_url":"https://api.github.com/users/mats-claassen/events{/privacy}","received_events_url":"https://api.github.com/users/mats-claassen/received_events","type":"User","site_admin":false},"body":"Additionally:\r\n* Add tests for FullyConnected (Dense) layer.\r\n* Also added support for FusedBatchNorm and relu6 for MobileNet\r\n\r\n\r\n","created_at":"2018-03-12T16:40:19Z","updated_at":"2018-03-14T18:45:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"103b5ecff2fbcb306066e224b7d85ce0bbf754f1","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/xmartlabs/Bender/pulls/98/commits","review_comments_url":"https://api.github.com/repos/xmartlabs/Bender/pulls/98/comments","review_comment_url":"https://api.github.com/repos/xmartlabs/Bender/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xmartlabs/Bender/issues/98/comments","statuses_url":"https://api.github.com/repos/xmartlabs/Bender/statuses/18ee67f61c74be8663e22db8f78c5128e5368fdc","head":{"label":"xmartlabs:mobilenet-example","ref":"mobilenet-example","sha":"18ee67f61c74be8663e22db8f78c5128e5368fdc","user":{"login":"xmartlabs","id":2227731,"avatar_url":"https://avatars0.githubusercontent.com/u/2227731?v=4","gravatar_id":"","url":"https://api.github.com/users/xmartlabs","html_url":"https://github.com/xmartlabs","followers_url":"https://api.github.com/users/xmartlabs/followers","following_url":"https://api.github.com/users/xmartlabs/following{/other_user}","gists_url":"https://api.github.com/users/xmartlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/xmartlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xmartlabs/subscriptions","organizations_url":"https://api.github.com/users/xmartlabs/orgs","repos_url":"https://api.github.com/users/xmartlabs/repos","events_url":"https://api.github.com/users/xmartlabs/events{/privacy}","received_events_url":"https://api.github.com/users/xmartlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":90192362,"name":"Bender","full_name":"xmartlabs/Bender","owner":{"login":"xmartlabs","id":2227731,"avatar_url":"https://avatars0.githubusercontent.com/u/2227731?v=4","gravatar_id":"","url":"https://api.github.com/users/xmartlabs","html_url":"https://github.com/xmartlabs","followers_url":"https://api.github.com/users/xmartlabs/followers","following_url":"https://api.github.com/users/xmartlabs/following{/other_user}","gists_url":"https://api.github.com/users/xmartlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/xmartlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xmartlabs/subscriptions","organizations_url":"https://api.github.com/users/xmartlabs/orgs","repos_url":"https://api.github.com/users/xmartlabs/repos","events_url":"https://api.github.com/users/xmartlabs/events{/privacy}","received_events_url":"https://api.github.com/users/xmartlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xmartlabs/Bender","description":"Easily craft fast Neural Networks on iOS! Use TensorFlow models. Metal under the hood.","fork":false,"url":"https://api.github.com/repos/xmartlabs/Bender","forks_url":"https://api.github.com/repos/xmartlabs/Bender/forks","keys_url":"https://api.github.com/repos/xmartlabs/Bender/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xmartlabs/Bender/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xmartlabs/Bender/teams","hooks_url":"https://api.github.com/repos/xmartlabs/Bender/hooks","issue_events_url":"https://api.github.com/repos/xmartlabs/Bender/issues/events{/number}","events_url":"https://api.github.com/repos/xmartlabs/Bender/events","assignees_url":"https://api.github.com/repos/xmartlabs/Bender/assignees{/user}","branches_url":"https://api.github.com/repos/xmartlabs/Bender/branches{/branch}","tags_url":"https://api.github.com/repos/xmartlabs/Bender/tags","blobs_url":"https://api.github.com/repos/xmartlabs/Bender/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xmartlabs/Bender/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xmartlabs/Bender/git/refs{/sha}","trees_url":"https://api.github.com/repos/xmartlabs/Bender/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xmartlabs/Bender/statuses/{sha}","languages_url":"https://api.github.com/repos/xmartlabs/Bender/languages","stargazers_url":"https://api.github.com/repos/xmartlabs/Bender/stargazers","contributors_url":"https://api.github.com/repos/xmartlabs/Bender/contributors","subscribers_url":"https://api.github.com/repos/xmartlabs/Bender/subscribers","subscription_url":"https://api.github.com/repos/xmartlabs/Bender/subscription","commits_url":"https://api.github.com/repos/xmartlabs/Bender/commits{/sha}","git_commits_url":"https://api.github.com/repos/xmartlabs/Bender/git/commits{/sha}","comments_url":"https://api.github.com/repos/xmartlabs/Bender/comments{/number}","issue_comment_url":"https://api.github.com/repos/xmartlabs/Bender/issues/comments{/number}","contents_url":"https://api.github.com/repos/xmartlabs/Bender/contents/{+path}","compare_url":"https://api.github.com/repos/xmartlabs/Bender/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xmartlabs/Bender/merges","archive_url":"https://api.github.com/repos/xmartlabs/Bender/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xmartlabs/Bender/downloads","issues_url":"https://api.github.com/repos/xmartlabs/Bender/issues{/number}","pulls_url":"https://api.github.com/repos/xmartlabs/Bender/pulls{/number}","milestones_url":"https://api.github.com/repos/xmartlabs/Bender/milestones{/number}","notifications_url":"https://api.github.com/repos/xmartlabs/Bender/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xmartlabs/Bender/labels{/name}","releases_url":"https://api.github.com/repos/xmartlabs/Bender/releases{/id}","deployments_url":"https://api.github.com/repos/xmartlabs/Bender/deployments","created_at":"2017-05-03T20:52:12Z","updated_at":"2018-03-14T10:26:08Z","pushed_at":"2018-03-13T12:54:33Z","git_url":"git://github.com/xmartlabs/Bender.git","ssh_url":"git@github.com:xmartlabs/Bender.git","clone_url":"https://github.com/xmartlabs/Bender.git","svn_url":"https://github.com/xmartlabs/Bender","homepage":"https://xmartlabs.github.io/Bender/","size":72659,"stargazers_count":1447,"watchers_count":1447,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":72,"mirror_url":null,"archived":false,"open_issues_count":19,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":72,"open_issues":19,"watchers":1447,"default_branch":"master"}},"base":{"label":"xmartlabs:master","ref":"master","sha":"d3ad89d1d60a7c006e69e3e0d697c1ff9f0ca1a0","user":{"login":"xmartlabs","id":2227731,"avatar_url":"https://avatars0.githubusercontent.com/u/2227731?v=4","gravatar_id":"","url":"https://api.github.com/users/xmartlabs","html_url":"https://github.com/xmartlabs","followers_url":"https://api.github.com/users/xmartlabs/followers","following_url":"https://api.github.com/users/xmartlabs/following{/other_user}","gists_url":"https://api.github.com/users/xmartlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/xmartlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xmartlabs/subscriptions","organizations_url":"https://api.github.com/users/xmartlabs/orgs","repos_url":"https://api.github.com/users/xmartlabs/repos","events_url":"https://api.github.com/users/xmartlabs/events{/privacy}","received_events_url":"https://api.github.com/users/xmartlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":90192362,"name":"Bender","full_name":"xmartlabs/Bender","owner":{"login":"xmartlabs","id":2227731,"avatar_url":"https://avatars0.githubusercontent.com/u/2227731?v=4","gravatar_id":"","url":"https://api.github.com/users/xmartlabs","html_url":"https://github.com/xmartlabs","followers_url":"https://api.github.com/users/xmartlabs/followers","following_url":"https://api.github.com/users/xmartlabs/following{/other_user}","gists_url":"https://api.github.com/users/xmartlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/xmartlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xmartlabs/subscriptions","organizations_url":"https://api.github.com/users/xmartlabs/orgs","repos_url":"https://api.github.com/users/xmartlabs/repos","events_url":"https://api.github.com/users/xmartlabs/events{/privacy}","received_events_url":"https://api.github.com/users/xmartlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xmartlabs/Bender","description":"Easily craft fast Neural Networks on iOS! Use TensorFlow models. Metal under the hood.","fork":false,"url":"https://api.github.com/repos/xmartlabs/Bender","forks_url":"https://api.github.com/repos/xmartlabs/Bender/forks","keys_url":"https://api.github.com/repos/xmartlabs/Bender/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xmartlabs/Bender/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xmartlabs/Bender/teams","hooks_url":"https://api.github.com/repos/xmartlabs/Bender/hooks","issue_events_url":"https://api.github.com/repos/xmartlabs/Bender/issues/events{/number}","events_url":"https://api.github.com/repos/xmartlabs/Bender/events","assignees_url":"https://api.github.com/repos/xmartlabs/Bender/assignees{/user}","branches_url":"https://api.github.com/repos/xmartlabs/Bender/branches{/branch}","tags_url":"https://api.github.com/repos/xmartlabs/Bender/tags","blobs_url":"https://api.github.com/repos/xmartlabs/Bender/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xmartlabs/Bender/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xmartlabs/Bender/git/refs{/sha}","trees_url":"https://api.github.com/repos/xmartlabs/Bender/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xmartlabs/Bender/statuses/{sha}","languages_url":"https://api.github.com/repos/xmartlabs/Bender/languages","stargazers_url":"https://api.github.com/repos/xmartlabs/Bender/stargazers","contributors_url":"https://api.github.com/repos/xmartlabs/Bender/contributors","subscribers_url":"https://api.github.com/repos/xmartlabs/Bender/subscribers","subscription_url":"https://api.github.com/repos/xmartlabs/Bender/subscription","commits_url":"https://api.github.com/repos/xmartlabs/Bender/commits{/sha}","git_commits_url":"https://api.github.com/repos/xmartlabs/Bender/git/commits{/sha}","comments_url":"https://api.github.com/repos/xmartlabs/Bender/comments{/number}","issue_comment_url":"https://api.github.com/repos/xmartlabs/Bender/issues/comments{/number}","contents_url":"https://api.github.com/repos/xmartlabs/Bender/contents/{+path}","compare_url":"https://api.github.com/repos/xmartlabs/Bender/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xmartlabs/Bender/merges","archive_url":"https://api.github.com/repos/xmartlabs/Bender/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xmartlabs/Bender/downloads","issues_url":"https://api.github.com/repos/xmartlabs/Bender/issues{/number}","pulls_url":"https://api.github.com/repos/xmartlabs/Bender/pulls{/number}","milestones_url":"https://api.github.com/repos/xmartlabs/Bender/milestones{/number}","notifications_url":"https://api.github.com/repos/xmartlabs/Bender/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xmartlabs/Bender/labels{/name}","releases_url":"https://api.github.com/repos/xmartlabs/Bender/releases{/id}","deployments_url":"https://api.github.com/repos/xmartlabs/Bender/deployments","created_at":"2017-05-03T20:52:12Z","updated_at":"2018-03-14T10:26:08Z","pushed_at":"2018-03-13T12:54:33Z","git_url":"git://github.com/xmartlabs/Bender.git","ssh_url":"git@github.com:xmartlabs/Bender.git","clone_url":"https://github.com/xmartlabs/Bender.git","svn_url":"https://github.com/xmartlabs/Bender","homepage":"https://xmartlabs.github.io/Bender/","size":72659,"stargazers_count":1447,"watchers_count":1447,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":72,"mirror_url":null,"archived":false,"open_issues_count":19,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":72,"open_issues":19,"watchers":1447,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/xmartlabs/Bender/pulls/98"},"html":{"href":"https://github.com/xmartlabs/Bender/pull/98"},"issue":{"href":"https://api.github.com/repos/xmartlabs/Bender/issues/98"},"comments":{"href":"https://api.github.com/repos/xmartlabs/Bender/issues/98/comments"},"review_comments":{"href":"https://api.github.com/repos/xmartlabs/Bender/pulls/98/comments"},"review_comment":{"href":"https://api.github.com/repos/xmartlabs/Bender/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xmartlabs/Bender/pulls/98/commits"},"statuses":{"href":"https://api.github.com/repos/xmartlabs/Bender/statuses/18ee67f61c74be8663e22db8f78c5128e5368fdc"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"dernster"}}