├── .gitignore ├── Convert ├── convert.py ├── download.sh └── styles.txt ├── LICENSE ├── Podfile ├── Podfile.lock ├── README.md ├── Screenshot.png ├── Styles.xcodeproj └── project.pbxproj ├── Styles.xcworkspace └── contents.xcworkspacedata └── Styles ├── AppDelegate.swift ├── ClassificationService.swift ├── Resources ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-40.png │ │ ├── Icon-40@2x.png │ │ ├── Icon-40@3x.png │ │ ├── Icon-60@2x.png │ │ ├── Icon-60@3x.png │ │ ├── Icon-72.png │ │ ├── Icon-72@2x.png │ │ ├── Icon-76.png │ │ ├── Icon-76@2x.png │ │ ├── Icon-83.5@2x.png │ │ ├── Icon-Small-50.png │ │ ├── Icon-Small-50@2x.png │ │ ├── Icon-Small.png │ │ ├── Icon-Small@2x.png │ │ ├── Icon-Small@3x.png │ │ ├── Icon.png │ │ ├── Icon@2x.png │ │ ├── NotificationIcon@2x.png │ │ ├── NotificationIcon@3x.png │ │ ├── NotificationIcon~ipad.png │ │ └── NotificationIcon~ipad@2x.png │ └── Contents.json ├── Info.plist └── LaunchScreen.storyboard └── ViewController.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | .AppleDouble 4 | .LSOverride 5 | Icon 6 | ._* 7 | .Spotlight-V100 8 | .Trashes 9 | 10 | # Xcode 11 | # 12 | build/ 13 | *.pbxuser 14 | !default.pbxuser 15 | *.mode1v3 16 | !default.mode1v3 17 | *.mode2v3 18 | !default.mode2v3 19 | *.perspectivev3 20 | !default.perspectivev3 21 | xcuserdata 22 | *.xccheckout 23 | *.moved-aside 24 | DerivedData 25 | *.hmap 26 | *.ipa 27 | *.xcuserstate 28 | .idea/ 29 | *.xcworkspace/xcshareddata/*.xcscmblueprint 30 | 31 | # CocoaPods 32 | Pods 33 | 34 | # Carthage 35 | Carthage 36 | 37 | # SPM 38 | .build/ 39 | 40 | ## CoreML models 41 | *.mlmodel 42 | -------------------------------------------------------------------------------- /Convert/convert.py: -------------------------------------------------------------------------------- 1 | import coremltools 2 | 3 | coreml_model = coremltools.converters.caffe.convert(('finetune_flickr_style.caffemodel', 'deploy.prototxt'), image_input_names = 'data', class_labels = 'styles.txt') 4 | coreml_model.author = 'Sergey Karayev' 5 | coreml_model.license = 'Unknown' 6 | coreml_model.short_description = 'Finetuning CaffeNet on Flickr Style' 7 | coreml_model.input_description['data'] = 'An image.' 8 | coreml_model.output_description['prob'] = 'The probabilities for each style type, for the given input.' 9 | coreml_model.output_description['classLabel'] = 'The most likely style of image, for the given input.' 10 | coreml_model.save('FlickrStyle.mlmodel') 11 | -------------------------------------------------------------------------------- /Convert/download.sh: -------------------------------------------------------------------------------- 1 | wget http://dl.caffe.berkeleyvision.org/finetune_flickr_style.caffemodel 2 | wget https://github.com/BVLC/caffe/raw/master/models/finetune_flickr_style/deploy.prototxt 3 | -------------------------------------------------------------------------------- /Convert/styles.txt: -------------------------------------------------------------------------------- 1 | Detailed 2 | Pastel 3 | Melancholy 4 | Noir 5 | HDR 6 | Vintage 7 | Long Exposure 8 | Horror 9 | Sunny 10 | Bright 11 | Hazy 12 | Bokeh 13 | Serene 14 | Texture 15 | Ethereal 16 | Macro 17 | Depth of Field 18 | Geometric Composition 19 | Minimal 20 | Romantic 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Vadym Markov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | platform :ios, '11.0' 3 | pod 'VisionLab', git: 'https://github.com/cocoa-ai/VisionLab' 4 | target 'Styles' 5 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - VisionLab (0.2.0) 3 | 4 | DEPENDENCIES: 5 | - VisionLab (from `https://github.com/cocoa-ai/VisionLab`) 6 | 7 | EXTERNAL SOURCES: 8 | VisionLab: 9 | :git: https://github.com/cocoa-ai/VisionLab 10 | 11 | CHECKOUT OPTIONS: 12 | VisionLab: 13 | :commit: aea33bfae9755aa9f175f2783f97593775f664e5 14 | :git: https://github.com/cocoa-ai/VisionLab 15 | 16 | SPEC CHECKSUMS: 17 | VisionLab: 6fc2dcc1f731dd21891c7bd9878a93c0526bfc91 18 | 19 | PODFILE CHECKSUM: b03eda12bfd65507b772f89f60456ef4345908d2 20 | 21 | COCOAPODS: 1.3.1 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Styles Vision Demo 2 | 3 | A Demo application using `Vision` and `CoreML` frameworks to detect the most 4 | likely style of the given image. 5 | 6 |
7 | StylesVisionDemo 8 |
9 | 10 | ## Model 11 | 12 | This demo is based on the "Finetuning CaffeNet on Flickr Style" neural network 13 | classifier, which was converted from original [Caffe model](https://gist.github.com/sergeyk/034c6ac3865563b69e60) 14 | to [CoreML model](https://drive.google.com/file/d/0B1ghKa_MYL6maFFWR3drLUFNQ1E/view?usp=sharing) 15 | using [coremltools](https://pypi.python.org/pypi/coremltools) python package. 16 | 17 | ## Requirements 18 | 19 | - Xcode 9 20 | - iOS 11 21 | 22 | ## Installation 23 | 24 | ```sh 25 | git clone https://github.com/cocoa-ai/StylesVisionDemo.git 26 | cd StylesVisionDemo 27 | pod install 28 | open Styles.xcworkspace/ 29 | ``` 30 | 31 | Download the [CoreMl model](https://drive.google.com/file/d/1aF-3p8zyrTzFE1tPpdBgLeWa0kanCN--/view?usp=sharing) 32 | and add the file to "Resources" folder in the project's directory. 33 | 34 | Build the project and run it on a simulator or a device with iOS 11. 35 | 36 | ## Conversion 37 | 38 | ```sh 39 | cd Convert 40 | ./download.sh 41 | python convert.py 42 | ``` 43 | 44 | ## Author 45 | 46 | Vadym Markov, markov.vadym@gmail.com 47 | 48 | ## Credits 49 | 50 | Original "Finetuning CaffeNet on Flickr Style" [Caffe model](https://gist.github.com/sergeyk/034c6ac3865563b69e60) 51 | 52 | ## References 53 | - [Caffe Model Zoo](https://github.com/caffe2/caffe2/wiki/Model-Zoo) 54 | - [Apple Machine Learning](https://developer.apple.com/machine-learning/) 55 | - [Vision Framework](https://developer.apple.com/documentation/vision) 56 | - [CoreML Framework](https://developer.apple.com/documentation/coreml) 57 | - [coremltools](https://pypi.python.org/pypi/coremltools) 58 | -------------------------------------------------------------------------------- /Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Screenshot.png -------------------------------------------------------------------------------- /Styles.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D523F30F1EFC91130004AE29 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D523F30E1EFC91130004AE29 /* AppDelegate.swift */; }; 11 | D523F3111EFC91130004AE29 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D523F3101EFC91130004AE29 /* ViewController.swift */; }; 12 | D523F3161EFC91130004AE29 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D523F3151EFC91130004AE29 /* Assets.xcassets */; }; 13 | D523F3271EFC91E50004AE29 /* FlickrStyle.mlmodel in Sources */ = {isa = PBXBuildFile; fileRef = D523F3261EFC91DB0004AE29 /* FlickrStyle.mlmodel */; }; 14 | D523F3281EFC91E50004AE29 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D523F3251EFC91DB0004AE29 /* LaunchScreen.storyboard */; }; 15 | D523F32A1EFC92050004AE29 /* ClassificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D523F3291EFC92050004AE29 /* ClassificationService.swift */; }; 16 | F7F337658A3AC6B349229E0C /* Pods_Styles.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D67527A243E0D525045BDAE6 /* Pods_Styles.framework */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXCopyFilesBuildPhase section */ 20 | D523F3231EFC914D0004AE29 /* Embed Frameworks */ = { 21 | isa = PBXCopyFilesBuildPhase; 22 | buildActionMask = 2147483647; 23 | dstPath = ""; 24 | dstSubfolderSpec = 10; 25 | files = ( 26 | ); 27 | name = "Embed Frameworks"; 28 | runOnlyForDeploymentPostprocessing = 0; 29 | }; 30 | /* End PBXCopyFilesBuildPhase section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | 42AB8B4CE329244197D2B200 /* Pods-Styles.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Styles.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Styles/Pods-Styles.debug.xcconfig"; sourceTree = ""; }; 34 | D523F30B1EFC91130004AE29 /* Styles.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Styles.app; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | D523F30E1EFC91130004AE29 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 36 | D523F3101EFC91130004AE29 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 37 | D523F3151EFC91130004AE29 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 38 | D523F31A1EFC91130004AE29 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 39 | D523F3251EFC91DB0004AE29 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; 40 | D523F3261EFC91DB0004AE29 /* FlickrStyle.mlmodel */ = {isa = PBXFileReference; lastKnownFileType = file.mlmodel; path = FlickrStyle.mlmodel; sourceTree = ""; }; 41 | D523F3291EFC92050004AE29 /* ClassificationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClassificationService.swift; sourceTree = ""; }; 42 | D67527A243E0D525045BDAE6 /* Pods_Styles.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Styles.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | F8AA5FDD0398F6EBA533CD66 /* Pods-Styles.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Styles.release.xcconfig"; path = "Pods/Target Support Files/Pods-Styles/Pods-Styles.release.xcconfig"; sourceTree = ""; }; 44 | /* End PBXFileReference section */ 45 | 46 | /* Begin PBXFrameworksBuildPhase section */ 47 | D523F3081EFC91130004AE29 /* Frameworks */ = { 48 | isa = PBXFrameworksBuildPhase; 49 | buildActionMask = 2147483647; 50 | files = ( 51 | F7F337658A3AC6B349229E0C /* Pods_Styles.framework in Frameworks */, 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 4FDD5876934D577E16A12E5E /* Frameworks */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | D67527A243E0D525045BDAE6 /* Pods_Styles.framework */, 62 | ); 63 | name = Frameworks; 64 | sourceTree = ""; 65 | }; 66 | D523F3021EFC91130004AE29 = { 67 | isa = PBXGroup; 68 | children = ( 69 | D523F30D1EFC91130004AE29 /* Styles */, 70 | D523F30C1EFC91130004AE29 /* Products */, 71 | E9CD3DD671A205B6BF44829E /* Pods */, 72 | 4FDD5876934D577E16A12E5E /* Frameworks */, 73 | ); 74 | sourceTree = ""; 75 | }; 76 | D523F30C1EFC91130004AE29 /* Products */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | D523F30B1EFC91130004AE29 /* Styles.app */, 80 | ); 81 | name = Products; 82 | sourceTree = ""; 83 | }; 84 | D523F30D1EFC91130004AE29 /* Styles */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | D523F3241EFC91560004AE29 /* Resources */, 88 | D523F30E1EFC91130004AE29 /* AppDelegate.swift */, 89 | D523F3101EFC91130004AE29 /* ViewController.swift */, 90 | D523F3291EFC92050004AE29 /* ClassificationService.swift */, 91 | ); 92 | path = Styles; 93 | sourceTree = ""; 94 | }; 95 | D523F3241EFC91560004AE29 /* Resources */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | D523F3261EFC91DB0004AE29 /* FlickrStyle.mlmodel */, 99 | D523F3251EFC91DB0004AE29 /* LaunchScreen.storyboard */, 100 | D523F3151EFC91130004AE29 /* Assets.xcassets */, 101 | D523F31A1EFC91130004AE29 /* Info.plist */, 102 | ); 103 | path = Resources; 104 | sourceTree = ""; 105 | }; 106 | E9CD3DD671A205B6BF44829E /* Pods */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 42AB8B4CE329244197D2B200 /* Pods-Styles.debug.xcconfig */, 110 | F8AA5FDD0398F6EBA533CD66 /* Pods-Styles.release.xcconfig */, 111 | ); 112 | name = Pods; 113 | sourceTree = ""; 114 | }; 115 | /* End PBXGroup section */ 116 | 117 | /* Begin PBXNativeTarget section */ 118 | D523F30A1EFC91130004AE29 /* Styles */ = { 119 | isa = PBXNativeTarget; 120 | buildConfigurationList = D523F31D1EFC91130004AE29 /* Build configuration list for PBXNativeTarget "Styles" */; 121 | buildPhases = ( 122 | 6DC716139F49DEB0DC511010 /* [CP] Check Pods Manifest.lock */, 123 | D523F3071EFC91130004AE29 /* Sources */, 124 | D523F3081EFC91130004AE29 /* Frameworks */, 125 | D523F3091EFC91130004AE29 /* Resources */, 126 | D523F3231EFC914D0004AE29 /* Embed Frameworks */, 127 | EA6802E98BB3703FD5013CD2 /* [CP] Embed Pods Frameworks */, 128 | 10227215E46CA0E2254CA724 /* [CP] Copy Pods Resources */, 129 | ); 130 | buildRules = ( 131 | ); 132 | dependencies = ( 133 | ); 134 | name = Styles; 135 | productName = Styles; 136 | productReference = D523F30B1EFC91130004AE29 /* Styles.app */; 137 | productType = "com.apple.product-type.application"; 138 | }; 139 | /* End PBXNativeTarget section */ 140 | 141 | /* Begin PBXProject section */ 142 | D523F3031EFC91130004AE29 /* Project object */ = { 143 | isa = PBXProject; 144 | attributes = { 145 | LastSwiftUpdateCheck = 0900; 146 | LastUpgradeCheck = 0900; 147 | ORGANIZATIONNAME = "Vadym Markov"; 148 | TargetAttributes = { 149 | D523F30A1EFC91130004AE29 = { 150 | CreatedOnToolsVersion = 9.0; 151 | ProvisioningStyle = Manual; 152 | }; 153 | }; 154 | }; 155 | buildConfigurationList = D523F3061EFC91130004AE29 /* Build configuration list for PBXProject "Styles" */; 156 | compatibilityVersion = "Xcode 8.0"; 157 | developmentRegion = en; 158 | hasScannedForEncodings = 0; 159 | knownRegions = ( 160 | en, 161 | Base, 162 | ); 163 | mainGroup = D523F3021EFC91130004AE29; 164 | productRefGroup = D523F30C1EFC91130004AE29 /* Products */; 165 | projectDirPath = ""; 166 | projectRoot = ""; 167 | targets = ( 168 | D523F30A1EFC91130004AE29 /* Styles */, 169 | ); 170 | }; 171 | /* End PBXProject section */ 172 | 173 | /* Begin PBXResourcesBuildPhase section */ 174 | D523F3091EFC91130004AE29 /* Resources */ = { 175 | isa = PBXResourcesBuildPhase; 176 | buildActionMask = 2147483647; 177 | files = ( 178 | D523F3161EFC91130004AE29 /* Assets.xcassets in Resources */, 179 | D523F3281EFC91E50004AE29 /* LaunchScreen.storyboard in Resources */, 180 | ); 181 | runOnlyForDeploymentPostprocessing = 0; 182 | }; 183 | /* End PBXResourcesBuildPhase section */ 184 | 185 | /* Begin PBXShellScriptBuildPhase section */ 186 | 10227215E46CA0E2254CA724 /* [CP] Copy Pods Resources */ = { 187 | isa = PBXShellScriptBuildPhase; 188 | buildActionMask = 2147483647; 189 | files = ( 190 | ); 191 | inputPaths = ( 192 | ); 193 | name = "[CP] Copy Pods Resources"; 194 | outputPaths = ( 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | shellPath = /bin/sh; 198 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Styles/Pods-Styles-resources.sh\"\n"; 199 | showEnvVarsInLog = 0; 200 | }; 201 | 6DC716139F49DEB0DC511010 /* [CP] Check Pods Manifest.lock */ = { 202 | isa = PBXShellScriptBuildPhase; 203 | buildActionMask = 2147483647; 204 | files = ( 205 | ); 206 | inputPaths = ( 207 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 208 | "${PODS_ROOT}/Manifest.lock", 209 | ); 210 | name = "[CP] Check Pods Manifest.lock"; 211 | outputPaths = ( 212 | "$(DERIVED_FILE_DIR)/Pods-Styles-checkManifestLockResult.txt", 213 | ); 214 | runOnlyForDeploymentPostprocessing = 0; 215 | shellPath = /bin/sh; 216 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 217 | showEnvVarsInLog = 0; 218 | }; 219 | EA6802E98BB3703FD5013CD2 /* [CP] Embed Pods Frameworks */ = { 220 | isa = PBXShellScriptBuildPhase; 221 | buildActionMask = 2147483647; 222 | files = ( 223 | ); 224 | inputPaths = ( 225 | "${SRCROOT}/Pods/Target Support Files/Pods-Styles/Pods-Styles-frameworks.sh", 226 | "${BUILT_PRODUCTS_DIR}/VisionLab/VisionLab.framework", 227 | ); 228 | name = "[CP] Embed Pods Frameworks"; 229 | outputPaths = ( 230 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/VisionLab.framework", 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | shellPath = /bin/sh; 234 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Styles/Pods-Styles-frameworks.sh\"\n"; 235 | showEnvVarsInLog = 0; 236 | }; 237 | /* End PBXShellScriptBuildPhase section */ 238 | 239 | /* Begin PBXSourcesBuildPhase section */ 240 | D523F3071EFC91130004AE29 /* Sources */ = { 241 | isa = PBXSourcesBuildPhase; 242 | buildActionMask = 2147483647; 243 | files = ( 244 | D523F3111EFC91130004AE29 /* ViewController.swift in Sources */, 245 | D523F30F1EFC91130004AE29 /* AppDelegate.swift in Sources */, 246 | D523F3271EFC91E50004AE29 /* FlickrStyle.mlmodel in Sources */, 247 | D523F32A1EFC92050004AE29 /* ClassificationService.swift in Sources */, 248 | ); 249 | runOnlyForDeploymentPostprocessing = 0; 250 | }; 251 | /* End PBXSourcesBuildPhase section */ 252 | 253 | /* Begin XCBuildConfiguration section */ 254 | D523F31B1EFC91130004AE29 /* Debug */ = { 255 | isa = XCBuildConfiguration; 256 | buildSettings = { 257 | ALWAYS_SEARCH_USER_PATHS = NO; 258 | CLANG_ANALYZER_NONNULL = YES; 259 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 260 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 261 | CLANG_CXX_LIBRARY = "libc++"; 262 | CLANG_ENABLE_MODULES = YES; 263 | CLANG_ENABLE_OBJC_ARC = YES; 264 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 265 | CLANG_WARN_BOOL_CONVERSION = YES; 266 | CLANG_WARN_COMMA = YES; 267 | CLANG_WARN_CONSTANT_CONVERSION = YES; 268 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 269 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 270 | CLANG_WARN_EMPTY_BODY = YES; 271 | CLANG_WARN_ENUM_CONVERSION = YES; 272 | CLANG_WARN_INFINITE_RECURSION = YES; 273 | CLANG_WARN_INT_CONVERSION = YES; 274 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 275 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 276 | CLANG_WARN_STRICT_PROTOTYPES = YES; 277 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 278 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 279 | CLANG_WARN_UNREACHABLE_CODE = YES; 280 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 281 | CODE_SIGN_IDENTITY = "iPhone Developer"; 282 | COPY_PHASE_STRIP = NO; 283 | DEBUG_INFORMATION_FORMAT = dwarf; 284 | ENABLE_STRICT_OBJC_MSGSEND = YES; 285 | ENABLE_TESTABILITY = YES; 286 | GCC_C_LANGUAGE_STANDARD = gnu11; 287 | GCC_DYNAMIC_NO_PIC = NO; 288 | GCC_NO_COMMON_BLOCKS = YES; 289 | GCC_OPTIMIZATION_LEVEL = 0; 290 | GCC_PREPROCESSOR_DEFINITIONS = ( 291 | "DEBUG=1", 292 | "$(inherited)", 293 | ); 294 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 295 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 296 | GCC_WARN_UNDECLARED_SELECTOR = YES; 297 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 298 | GCC_WARN_UNUSED_FUNCTION = YES; 299 | GCC_WARN_UNUSED_VARIABLE = YES; 300 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 301 | MTL_ENABLE_DEBUG_INFO = YES; 302 | ONLY_ACTIVE_ARCH = YES; 303 | SDKROOT = iphoneos; 304 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 305 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 306 | }; 307 | name = Debug; 308 | }; 309 | D523F31C1EFC91130004AE29 /* Release */ = { 310 | isa = XCBuildConfiguration; 311 | buildSettings = { 312 | ALWAYS_SEARCH_USER_PATHS = NO; 313 | CLANG_ANALYZER_NONNULL = YES; 314 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 315 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 316 | CLANG_CXX_LIBRARY = "libc++"; 317 | CLANG_ENABLE_MODULES = YES; 318 | CLANG_ENABLE_OBJC_ARC = YES; 319 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 320 | CLANG_WARN_BOOL_CONVERSION = YES; 321 | CLANG_WARN_COMMA = YES; 322 | CLANG_WARN_CONSTANT_CONVERSION = YES; 323 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 324 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 325 | CLANG_WARN_EMPTY_BODY = YES; 326 | CLANG_WARN_ENUM_CONVERSION = YES; 327 | CLANG_WARN_INFINITE_RECURSION = YES; 328 | CLANG_WARN_INT_CONVERSION = YES; 329 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 330 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 331 | CLANG_WARN_STRICT_PROTOTYPES = YES; 332 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 333 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 334 | CLANG_WARN_UNREACHABLE_CODE = YES; 335 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 336 | CODE_SIGN_IDENTITY = "iPhone Developer"; 337 | COPY_PHASE_STRIP = NO; 338 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 339 | ENABLE_NS_ASSERTIONS = NO; 340 | ENABLE_STRICT_OBJC_MSGSEND = YES; 341 | GCC_C_LANGUAGE_STANDARD = gnu11; 342 | GCC_NO_COMMON_BLOCKS = YES; 343 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 344 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 345 | GCC_WARN_UNDECLARED_SELECTOR = YES; 346 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 347 | GCC_WARN_UNUSED_FUNCTION = YES; 348 | GCC_WARN_UNUSED_VARIABLE = YES; 349 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 350 | MTL_ENABLE_DEBUG_INFO = NO; 351 | SDKROOT = iphoneos; 352 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 353 | VALIDATE_PRODUCT = YES; 354 | }; 355 | name = Release; 356 | }; 357 | D523F31E1EFC91130004AE29 /* Debug */ = { 358 | isa = XCBuildConfiguration; 359 | baseConfigurationReference = 42AB8B4CE329244197D2B200 /* Pods-Styles.debug.xcconfig */; 360 | buildSettings = { 361 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 362 | CODE_SIGN_STYLE = Manual; 363 | DEVELOPMENT_TEAM = ""; 364 | INFOPLIST_FILE = Styles/Resources/Info.plist; 365 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 366 | PRODUCT_BUNDLE_IDENTIFIER = com.cocoaml.Styles; 367 | PRODUCT_NAME = "$(TARGET_NAME)"; 368 | PROVISIONING_PROFILE = ""; 369 | PROVISIONING_PROFILE_SPECIFIER = ""; 370 | SWIFT_VERSION = 4.0; 371 | TARGETED_DEVICE_FAMILY = "1,2"; 372 | }; 373 | name = Debug; 374 | }; 375 | D523F31F1EFC91130004AE29 /* Release */ = { 376 | isa = XCBuildConfiguration; 377 | baseConfigurationReference = F8AA5FDD0398F6EBA533CD66 /* Pods-Styles.release.xcconfig */; 378 | buildSettings = { 379 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 380 | CODE_SIGN_STYLE = Manual; 381 | DEVELOPMENT_TEAM = ""; 382 | INFOPLIST_FILE = Styles/Resources/Info.plist; 383 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 384 | PRODUCT_BUNDLE_IDENTIFIER = com.cocoaml.Styles; 385 | PRODUCT_NAME = "$(TARGET_NAME)"; 386 | PROVISIONING_PROFILE = ""; 387 | PROVISIONING_PROFILE_SPECIFIER = ""; 388 | SWIFT_VERSION = 4.0; 389 | TARGETED_DEVICE_FAMILY = "1,2"; 390 | }; 391 | name = Release; 392 | }; 393 | /* End XCBuildConfiguration section */ 394 | 395 | /* Begin XCConfigurationList section */ 396 | D523F3061EFC91130004AE29 /* Build configuration list for PBXProject "Styles" */ = { 397 | isa = XCConfigurationList; 398 | buildConfigurations = ( 399 | D523F31B1EFC91130004AE29 /* Debug */, 400 | D523F31C1EFC91130004AE29 /* Release */, 401 | ); 402 | defaultConfigurationIsVisible = 0; 403 | defaultConfigurationName = Release; 404 | }; 405 | D523F31D1EFC91130004AE29 /* Build configuration list for PBXNativeTarget "Styles" */ = { 406 | isa = XCConfigurationList; 407 | buildConfigurations = ( 408 | D523F31E1EFC91130004AE29 /* Debug */, 409 | D523F31F1EFC91130004AE29 /* Release */, 410 | ); 411 | defaultConfigurationIsVisible = 0; 412 | defaultConfigurationName = Release; 413 | }; 414 | /* End XCConfigurationList section */ 415 | }; 416 | rootObject = D523F3031EFC91130004AE29 /* Project object */; 417 | } 418 | -------------------------------------------------------------------------------- /Styles.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Styles/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | @UIApplicationMain 4 | final class AppDelegate: UIResponder, UIApplicationDelegate { 5 | var window: UIWindow? 6 | private lazy var controller: UIViewController = ViewController() 7 | 8 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 9 | window = UIWindow() 10 | window?.rootViewController = controller 11 | window?.makeKeyAndVisible() 12 | 13 | return true 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Styles/ClassificationService.swift: -------------------------------------------------------------------------------- 1 | import CoreML 2 | import Vision 3 | import VisionLab 4 | 5 | protocol ClassificationServiceDelegate: class { 6 | func classificationService(_ service: ClassificationService, didDetectStyles styles: String) 7 | } 8 | 9 | /// Service used to perform gender, age and emotion classification 10 | final class ClassificationService: ClassificationServiceProtocol { 11 | /// The service's delegate 12 | weak var delegate: ClassificationServiceDelegate? 13 | /// Array of vision requests 14 | private var requests = [VNRequest]() 15 | 16 | /// Create CoreML model and classification requests 17 | func setup() { 18 | do { 19 | // Styles request 20 | requests.append(VNCoreMLRequest( 21 | model: try VNCoreMLModel(for: FlickrStyle().model), 22 | completionHandler: handleClassification 23 | )) 24 | } catch { 25 | assertionFailure("Can't load Vision ML model: \(error)") 26 | } 27 | } 28 | 29 | /// Run individual requests one by one. 30 | func classify(image: CIImage) { 31 | do { 32 | for request in self.requests { 33 | let handler = VNImageRequestHandler(ciImage: image) 34 | try handler.perform([request]) 35 | } 36 | } catch { 37 | print(error) 38 | } 39 | } 40 | 41 | // MARK: - Handling 42 | 43 | @objc private func handleClassification(request: VNRequest, error: Error?) { 44 | let result = extractClassificationResult(from: request, count: 3) 45 | delegate?.classificationService(self, didDetectStyles: result) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "NotificationIcon@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "NotificationIcon@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-Small.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-Small@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-Small@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "57x57", 47 | "idiom" : "iphone", 48 | "filename" : "Icon.png", 49 | "scale" : "1x" 50 | }, 51 | { 52 | "size" : "57x57", 53 | "idiom" : "iphone", 54 | "filename" : "Icon@2x.png", 55 | "scale" : "2x" 56 | }, 57 | { 58 | "size" : "60x60", 59 | "idiom" : "iphone", 60 | "filename" : "Icon-60@2x.png", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "size" : "60x60", 65 | "idiom" : "iphone", 66 | "filename" : "Icon-60@3x.png", 67 | "scale" : "3x" 68 | }, 69 | { 70 | "size" : "20x20", 71 | "idiom" : "ipad", 72 | "filename" : "NotificationIcon~ipad.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "20x20", 77 | "idiom" : "ipad", 78 | "filename" : "NotificationIcon~ipad@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "29x29", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-Small.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "29x29", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-Small@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "40x40", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-40.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "40x40", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-40@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "50x50", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-Small-50.png", 109 | "scale" : "1x" 110 | }, 111 | { 112 | "size" : "50x50", 113 | "idiom" : "ipad", 114 | "filename" : "Icon-Small-50@2x.png", 115 | "scale" : "2x" 116 | }, 117 | { 118 | "size" : "72x72", 119 | "idiom" : "ipad", 120 | "filename" : "Icon-72.png", 121 | "scale" : "1x" 122 | }, 123 | { 124 | "size" : "72x72", 125 | "idiom" : "ipad", 126 | "filename" : "Icon-72@2x.png", 127 | "scale" : "2x" 128 | }, 129 | { 130 | "size" : "76x76", 131 | "idiom" : "ipad", 132 | "filename" : "Icon-76.png", 133 | "scale" : "1x" 134 | }, 135 | { 136 | "size" : "76x76", 137 | "idiom" : "ipad", 138 | "filename" : "Icon-76@2x.png", 139 | "scale" : "2x" 140 | }, 141 | { 142 | "size" : "83.5x83.5", 143 | "idiom" : "ipad", 144 | "filename" : "Icon-83.5@2x.png", 145 | "scale" : "2x" 146 | }, 147 | { 148 | "idiom" : "ios-marketing", 149 | "size" : "1024x1024", 150 | "scale" : "1x" 151 | } 152 | ], 153 | "info" : { 154 | "version" : 1, 155 | "author" : "xcode" 156 | } 157 | } -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-40.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-72.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-72@2x.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-76.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-83.5@2x.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-Small-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-Small-50.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-Small-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-Small-50@2x.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-Small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-Small.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/Icon@2x.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/NotificationIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/NotificationIcon@2x.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/NotificationIcon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/NotificationIcon@3x.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/NotificationIcon~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/NotificationIcon~ipad.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/AppIcon.appiconset/NotificationIcon~ipad@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cocoa-ai/StylesVisionDemo/60536c892d5db881bed501c11e23f9c2673e418f/Styles/Resources/Assets.xcassets/AppIcon.appiconset/NotificationIcon~ipad@2x.png -------------------------------------------------------------------------------- /Styles/Resources/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } -------------------------------------------------------------------------------- /Styles/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSCameraUsageDescription 24 | To demonstrate image recognition. 25 | NSPhotoLibraryUsageDescription 26 | To demonstrate image recognition. 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UIStatusBarStyle 34 | UIStatusBarStyleLightContent 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Styles/Resources/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 30 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /Styles/ViewController.swift: -------------------------------------------------------------------------------- 1 | import VisionLab 2 | 3 | final class ViewController: ImageClassificationController { 4 | override func viewDidLoad() { 5 | super.viewDidLoad() 6 | mainView.button.setTitle("Choose a picture", for: .normal) 7 | classificationService.delegate = self 8 | } 9 | } 10 | 11 | // MARK: - ClassificationServiceDelegate 12 | 13 | extension ViewController: ClassificationServiceDelegate { 14 | func classificationService(_ service: ClassificationService, didDetectStyles styles: String) { 15 | DispatchQueue.main.async { [weak mainView] in 16 | mainView?.label.text = styles.capitalized 17 | } 18 | } 19 | } 20 | --------------------------------------------------------------------------------