├── BasicCoreML.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── brianadvent.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── BasicCoreML ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── img1.imageset │ │ ├── Contents.json │ │ └── img1.jpg │ ├── img2.imageset │ │ ├── Contents.json │ │ └── img2.jpg │ └── img3.imageset │ │ ├── Contents.json │ │ └── img3.jpg ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── GoogLeNetPlaces.mlmodel ├── ImageProcessor.swift ├── Info.plist └── ViewController.swift └── README.md /BasicCoreML.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 529091681EEB1A5700F2D83E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 529091671EEB1A5700F2D83E /* AppDelegate.swift */; }; 11 | 5290916A1EEB1A5700F2D83E /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 529091691EEB1A5700F2D83E /* ViewController.swift */; }; 12 | 5290916D1EEB1A5700F2D83E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5290916B1EEB1A5700F2D83E /* Main.storyboard */; }; 13 | 5290916F1EEB1A5700F2D83E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5290916E1EEB1A5700F2D83E /* Assets.xcassets */; }; 14 | 529091721EEB1A5700F2D83E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 529091701EEB1A5700F2D83E /* LaunchScreen.storyboard */; }; 15 | 5290917A1EEB1D1000F2D83E /* ImageProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 529091791EEB1D1000F2D83E /* ImageProcessor.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 529091641EEB1A5700F2D83E /* BasicCoreML.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BasicCoreML.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 529091671EEB1A5700F2D83E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | 529091691EEB1A5700F2D83E /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 22 | 5290916C1EEB1A5700F2D83E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | 5290916E1EEB1A5700F2D83E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 24 | 529091711EEB1A5700F2D83E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 25 | 529091731EEB1A5700F2D83E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | 529091791EEB1D1000F2D83E /* ImageProcessor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageProcessor.swift; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | 529091611EEB1A5700F2D83E /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | 5290915B1EEB1A5700F2D83E = { 41 | isa = PBXGroup; 42 | children = ( 43 | 529091661EEB1A5700F2D83E /* BasicCoreML */, 44 | 529091651EEB1A5700F2D83E /* Products */, 45 | ); 46 | sourceTree = ""; 47 | }; 48 | 529091651EEB1A5700F2D83E /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | 529091641EEB1A5700F2D83E /* BasicCoreML.app */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | 529091661EEB1A5700F2D83E /* BasicCoreML */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 529091671EEB1A5700F2D83E /* AppDelegate.swift */, 60 | 529091691EEB1A5700F2D83E /* ViewController.swift */, 61 | 529091791EEB1D1000F2D83E /* ImageProcessor.swift */, 62 | 5290916B1EEB1A5700F2D83E /* Main.storyboard */, 63 | 5290916E1EEB1A5700F2D83E /* Assets.xcassets */, 64 | 529091701EEB1A5700F2D83E /* LaunchScreen.storyboard */, 65 | 529091731EEB1A5700F2D83E /* Info.plist */, 66 | ); 67 | path = BasicCoreML; 68 | sourceTree = ""; 69 | }; 70 | /* End PBXGroup section */ 71 | 72 | /* Begin PBXNativeTarget section */ 73 | 529091631EEB1A5700F2D83E /* BasicCoreML */ = { 74 | isa = PBXNativeTarget; 75 | buildConfigurationList = 529091761EEB1A5700F2D83E /* Build configuration list for PBXNativeTarget "BasicCoreML" */; 76 | buildPhases = ( 77 | 529091601EEB1A5700F2D83E /* Sources */, 78 | 529091611EEB1A5700F2D83E /* Frameworks */, 79 | 529091621EEB1A5700F2D83E /* Resources */, 80 | ); 81 | buildRules = ( 82 | ); 83 | dependencies = ( 84 | ); 85 | name = BasicCoreML; 86 | productName = BasicCoreML; 87 | productReference = 529091641EEB1A5700F2D83E /* BasicCoreML.app */; 88 | productType = "com.apple.product-type.application"; 89 | }; 90 | /* End PBXNativeTarget section */ 91 | 92 | /* Begin PBXProject section */ 93 | 5290915C1EEB1A5700F2D83E /* Project object */ = { 94 | isa = PBXProject; 95 | attributes = { 96 | LastSwiftUpdateCheck = 0900; 97 | LastUpgradeCheck = 0900; 98 | ORGANIZATIONNAME = "Brian Advent"; 99 | TargetAttributes = { 100 | 529091631EEB1A5700F2D83E = { 101 | CreatedOnToolsVersion = 9.0; 102 | }; 103 | }; 104 | }; 105 | buildConfigurationList = 5290915F1EEB1A5700F2D83E /* Build configuration list for PBXProject "BasicCoreML" */; 106 | compatibilityVersion = "Xcode 8.0"; 107 | developmentRegion = en; 108 | hasScannedForEncodings = 0; 109 | knownRegions = ( 110 | en, 111 | Base, 112 | ); 113 | mainGroup = 5290915B1EEB1A5700F2D83E; 114 | productRefGroup = 529091651EEB1A5700F2D83E /* Products */; 115 | projectDirPath = ""; 116 | projectRoot = ""; 117 | targets = ( 118 | 529091631EEB1A5700F2D83E /* BasicCoreML */, 119 | ); 120 | }; 121 | /* End PBXProject section */ 122 | 123 | /* Begin PBXResourcesBuildPhase section */ 124 | 529091621EEB1A5700F2D83E /* Resources */ = { 125 | isa = PBXResourcesBuildPhase; 126 | buildActionMask = 2147483647; 127 | files = ( 128 | 529091721EEB1A5700F2D83E /* LaunchScreen.storyboard in Resources */, 129 | 5290916F1EEB1A5700F2D83E /* Assets.xcassets in Resources */, 130 | 5290916D1EEB1A5700F2D83E /* Main.storyboard in Resources */, 131 | ); 132 | runOnlyForDeploymentPostprocessing = 0; 133 | }; 134 | /* End PBXResourcesBuildPhase section */ 135 | 136 | /* Begin PBXSourcesBuildPhase section */ 137 | 529091601EEB1A5700F2D83E /* Sources */ = { 138 | isa = PBXSourcesBuildPhase; 139 | buildActionMask = 2147483647; 140 | files = ( 141 | 5290916A1EEB1A5700F2D83E /* ViewController.swift in Sources */, 142 | 5290917A1EEB1D1000F2D83E /* ImageProcessor.swift in Sources */, 143 | 529091681EEB1A5700F2D83E /* AppDelegate.swift in Sources */, 144 | ); 145 | runOnlyForDeploymentPostprocessing = 0; 146 | }; 147 | /* End PBXSourcesBuildPhase section */ 148 | 149 | /* Begin PBXVariantGroup section */ 150 | 5290916B1EEB1A5700F2D83E /* Main.storyboard */ = { 151 | isa = PBXVariantGroup; 152 | children = ( 153 | 5290916C1EEB1A5700F2D83E /* Base */, 154 | ); 155 | name = Main.storyboard; 156 | sourceTree = ""; 157 | }; 158 | 529091701EEB1A5700F2D83E /* LaunchScreen.storyboard */ = { 159 | isa = PBXVariantGroup; 160 | children = ( 161 | 529091711EEB1A5700F2D83E /* Base */, 162 | ); 163 | name = LaunchScreen.storyboard; 164 | sourceTree = ""; 165 | }; 166 | /* End PBXVariantGroup section */ 167 | 168 | /* Begin XCBuildConfiguration section */ 169 | 529091741EEB1A5700F2D83E /* Debug */ = { 170 | isa = XCBuildConfiguration; 171 | buildSettings = { 172 | ALWAYS_SEARCH_USER_PATHS = NO; 173 | CLANG_ANALYZER_NONNULL = YES; 174 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 175 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 176 | CLANG_CXX_LIBRARY = "libc++"; 177 | CLANG_ENABLE_MODULES = YES; 178 | CLANG_ENABLE_OBJC_ARC = YES; 179 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 180 | CLANG_WARN_BOOL_CONVERSION = YES; 181 | CLANG_WARN_COMMA = YES; 182 | CLANG_WARN_CONSTANT_CONVERSION = YES; 183 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 184 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 185 | CLANG_WARN_EMPTY_BODY = YES; 186 | CLANG_WARN_ENUM_CONVERSION = YES; 187 | CLANG_WARN_INFINITE_RECURSION = YES; 188 | CLANG_WARN_INT_CONVERSION = YES; 189 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 190 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 191 | CLANG_WARN_STRICT_PROTOTYPES = YES; 192 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 193 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 194 | CLANG_WARN_UNREACHABLE_CODE = YES; 195 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 196 | CODE_SIGN_IDENTITY = "iPhone Developer"; 197 | COPY_PHASE_STRIP = NO; 198 | DEBUG_INFORMATION_FORMAT = dwarf; 199 | ENABLE_STRICT_OBJC_MSGSEND = YES; 200 | ENABLE_TESTABILITY = YES; 201 | GCC_C_LANGUAGE_STANDARD = gnu11; 202 | GCC_DYNAMIC_NO_PIC = NO; 203 | GCC_NO_COMMON_BLOCKS = YES; 204 | GCC_OPTIMIZATION_LEVEL = 0; 205 | GCC_PREPROCESSOR_DEFINITIONS = ( 206 | "DEBUG=1", 207 | "$(inherited)", 208 | ); 209 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 210 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 211 | GCC_WARN_UNDECLARED_SELECTOR = YES; 212 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 213 | GCC_WARN_UNUSED_FUNCTION = YES; 214 | GCC_WARN_UNUSED_VARIABLE = YES; 215 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 216 | MTL_ENABLE_DEBUG_INFO = YES; 217 | ONLY_ACTIVE_ARCH = YES; 218 | SDKROOT = iphoneos; 219 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 220 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 221 | }; 222 | name = Debug; 223 | }; 224 | 529091751EEB1A5700F2D83E /* Release */ = { 225 | isa = XCBuildConfiguration; 226 | buildSettings = { 227 | ALWAYS_SEARCH_USER_PATHS = NO; 228 | CLANG_ANALYZER_NONNULL = YES; 229 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 230 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 231 | CLANG_CXX_LIBRARY = "libc++"; 232 | CLANG_ENABLE_MODULES = YES; 233 | CLANG_ENABLE_OBJC_ARC = YES; 234 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 235 | CLANG_WARN_BOOL_CONVERSION = YES; 236 | CLANG_WARN_COMMA = YES; 237 | CLANG_WARN_CONSTANT_CONVERSION = YES; 238 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 239 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 240 | CLANG_WARN_EMPTY_BODY = YES; 241 | CLANG_WARN_ENUM_CONVERSION = YES; 242 | CLANG_WARN_INFINITE_RECURSION = YES; 243 | CLANG_WARN_INT_CONVERSION = YES; 244 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 245 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 246 | CLANG_WARN_STRICT_PROTOTYPES = YES; 247 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 248 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 249 | CLANG_WARN_UNREACHABLE_CODE = YES; 250 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 251 | CODE_SIGN_IDENTITY = "iPhone Developer"; 252 | COPY_PHASE_STRIP = NO; 253 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 254 | ENABLE_NS_ASSERTIONS = NO; 255 | ENABLE_STRICT_OBJC_MSGSEND = YES; 256 | GCC_C_LANGUAGE_STANDARD = gnu11; 257 | GCC_NO_COMMON_BLOCKS = YES; 258 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 259 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 260 | GCC_WARN_UNDECLARED_SELECTOR = YES; 261 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 262 | GCC_WARN_UNUSED_FUNCTION = YES; 263 | GCC_WARN_UNUSED_VARIABLE = YES; 264 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 265 | MTL_ENABLE_DEBUG_INFO = NO; 266 | SDKROOT = iphoneos; 267 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 268 | VALIDATE_PRODUCT = YES; 269 | }; 270 | name = Release; 271 | }; 272 | 529091771EEB1A5700F2D83E /* Debug */ = { 273 | isa = XCBuildConfiguration; 274 | buildSettings = { 275 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 276 | DEVELOPMENT_TEAM = ""; 277 | INFOPLIST_FILE = BasicCoreML/Info.plist; 278 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 279 | PRODUCT_BUNDLE_IDENTIFIER = com.brianadvent.BasicCoreML; 280 | PRODUCT_NAME = "$(TARGET_NAME)"; 281 | SWIFT_VERSION = 4.0; 282 | TARGETED_DEVICE_FAMILY = "1,2"; 283 | }; 284 | name = Debug; 285 | }; 286 | 529091781EEB1A5700F2D83E /* Release */ = { 287 | isa = XCBuildConfiguration; 288 | buildSettings = { 289 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 290 | DEVELOPMENT_TEAM = ""; 291 | INFOPLIST_FILE = BasicCoreML/Info.plist; 292 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 293 | PRODUCT_BUNDLE_IDENTIFIER = com.brianadvent.BasicCoreML; 294 | PRODUCT_NAME = "$(TARGET_NAME)"; 295 | SWIFT_VERSION = 4.0; 296 | TARGETED_DEVICE_FAMILY = "1,2"; 297 | }; 298 | name = Release; 299 | }; 300 | /* End XCBuildConfiguration section */ 301 | 302 | /* Begin XCConfigurationList section */ 303 | 5290915F1EEB1A5700F2D83E /* Build configuration list for PBXProject "BasicCoreML" */ = { 304 | isa = XCConfigurationList; 305 | buildConfigurations = ( 306 | 529091741EEB1A5700F2D83E /* Debug */, 307 | 529091751EEB1A5700F2D83E /* Release */, 308 | ); 309 | defaultConfigurationIsVisible = 0; 310 | defaultConfigurationName = Release; 311 | }; 312 | 529091761EEB1A5700F2D83E /* Build configuration list for PBXNativeTarget "BasicCoreML" */ = { 313 | isa = XCConfigurationList; 314 | buildConfigurations = ( 315 | 529091771EEB1A5700F2D83E /* Debug */, 316 | 529091781EEB1A5700F2D83E /* Release */, 317 | ); 318 | defaultConfigurationIsVisible = 0; 319 | defaultConfigurationName = Release; 320 | }; 321 | /* End XCConfigurationList section */ 322 | }; 323 | rootObject = 5290915C1EEB1A5700F2D83E /* Project object */; 324 | } 325 | -------------------------------------------------------------------------------- /BasicCoreML.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /BasicCoreML.xcodeproj/xcuserdata/brianadvent.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | BasicCoreML.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /BasicCoreML/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // BasicCoreML 4 | // 5 | // Created by Brian Advent on 09.06.17. 6 | // Copyright © 2017 Brian Advent. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /BasicCoreML/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /BasicCoreML/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /BasicCoreML/Assets.xcassets/img1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img1.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /BasicCoreML/Assets.xcassets/img1.imageset/img1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianadvent/CoreML-Introduction/450f25f7f8ca41c5b8caf26944d68a7c2d9ba617/BasicCoreML/Assets.xcassets/img1.imageset/img1.jpg -------------------------------------------------------------------------------- /BasicCoreML/Assets.xcassets/img2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img2.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /BasicCoreML/Assets.xcassets/img2.imageset/img2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianadvent/CoreML-Introduction/450f25f7f8ca41c5b8caf26944d68a7c2d9ba617/BasicCoreML/Assets.xcassets/img2.imageset/img2.jpg -------------------------------------------------------------------------------- /BasicCoreML/Assets.xcassets/img3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img3.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /BasicCoreML/Assets.xcassets/img3.imageset/img3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianadvent/CoreML-Introduction/450f25f7f8ca41c5b8caf26944d68a7c2d9ba617/BasicCoreML/Assets.xcassets/img3.imageset/img3.jpg -------------------------------------------------------------------------------- /BasicCoreML/Base.lproj/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 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /BasicCoreML/Base.lproj/Main.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 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /BasicCoreML/GoogLeNetPlaces.mlmodel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brianadvent/CoreML-Introduction/450f25f7f8ca41c5b8caf26944d68a7c2d9ba617/BasicCoreML/GoogLeNetPlaces.mlmodel -------------------------------------------------------------------------------- /BasicCoreML/ImageProcessor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // File.swift 3 | // BasicCoreML 4 | // 5 | // Created by Brian Advent on 09.06.17. 6 | // Copyright © 2017 Brian Advent. All rights reserved. 7 | // 8 | 9 | import CoreVideo 10 | 11 | struct ImageProcessor { 12 | static func pixelBuffer (forImage image:CGImage) -> CVPixelBuffer? { 13 | 14 | 15 | let frameSize = CGSize(width: image.width, height: image.height) 16 | 17 | var pixelBuffer:CVPixelBuffer? = nil 18 | let status = CVPixelBufferCreate(kCFAllocatorDefault, Int(frameSize.width), Int(frameSize.height), kCVPixelFormatType_32BGRA , nil, &pixelBuffer) 19 | 20 | if status != kCVReturnSuccess { 21 | return nil 22 | 23 | } 24 | 25 | CVPixelBufferLockBaseAddress(pixelBuffer!, CVPixelBufferLockFlags.init(rawValue: 0)) 26 | let data = CVPixelBufferGetBaseAddress(pixelBuffer!) 27 | let rgbColorSpace = CGColorSpaceCreateDeviceRGB() 28 | let bitmapInfo = CGBitmapInfo(rawValue: CGBitmapInfo.byteOrder32Little.rawValue | CGImageAlphaInfo.premultipliedFirst.rawValue) 29 | let context = CGContext(data: data, width: Int(frameSize.width), height: Int(frameSize.height), bitsPerComponent: 8, bytesPerRow: CVPixelBufferGetBytesPerRow(pixelBuffer!), space: rgbColorSpace, bitmapInfo: bitmapInfo.rawValue) 30 | 31 | 32 | context?.draw(image, in: CGRect(x: 0, y: 0, width: image.width, height: image.height)) 33 | 34 | CVPixelBufferUnlockBaseAddress(pixelBuffer!, CVPixelBufferLockFlags(rawValue: 0)) 35 | 36 | return pixelBuffer 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /BasicCoreML/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 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /BasicCoreML/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // BasicCoreML 4 | // 5 | // Created by Brian Advent on 09.06.17. 6 | // Copyright © 2017 Brian Advent. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | @IBOutlet weak var categoryLabel: UILabel! 14 | 15 | let model = GoogLeNetPlaces() 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | // Do any additional setup after loading the view, typically from a nib. 20 | } 21 | 22 | @IBAction func imageTapped(_ sender: UITapGestureRecognizer) { 23 | let imageView = sender.view as? UIImageView 24 | 25 | if let imageToAnalyse = imageView?.image { 26 | if let sceneLabelString = sceneLabel(forImage: imageToAnalyse) { 27 | categoryLabel.text = sceneLabelString 28 | } 29 | } 30 | 31 | 32 | } 33 | 34 | func sceneLabel (forImage image:UIImage) -> String? { 35 | if let pixelBuffer = ImageProcessor.pixelBuffer(forImage: image.cgImage!) { 36 | guard let scene = try? model.prediction(sceneImage: pixelBuffer) else {fatalError("Unexpected runtime error")} 37 | return scene.sceneLabel 38 | 39 | } 40 | 41 | return nil 42 | } 43 | 44 | 45 | 46 | override func didReceiveMemoryWarning() { 47 | super.didReceiveMemoryWarning() 48 | // Dispose of any resources that can be recreated. 49 | } 50 | 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Core ML Tutorial: Create a Simple Machine Learning App - Image Classification 2 | 3 | This tutorial is a simple introduction into how to use Core ML in Xcode 9. We are going to create a demo app for image classification with the GoogLeNet Machine Learning Model. 4 | 5 | ## Machine Learning Models 6 | A ML Model needs to be added to the project and can be downloaded e.g. at 7 | [Apple](http://developer.apple.com/machine-learning) 8 | 9 | ➡️ [Video on YouTube](https://youtu.be/NNKPbdT9gXU) 10 | 11 | [![Video](https://img.youtube.com/vi/NNKPbdT9gXU/0.jpg)](https://www.youtube.com/watch?v=NNKPbdT9gXU) 12 | --------------------------------------------------------------------------------