diff --git a/README.md b/README.md index aab8530..fab836b 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,7 @@ Note that after I tap `Download New Model`, app starts recognizing `Ho*gaarden` ## Requirements -* Swift 4.2 -* Xcode 10.0 +* Xcode 12.5.1 * Python 3.6 * virtualenv * pip diff --git a/iOS/BeerClassifier.xcodeproj/project.pbxproj b/iOS/BeerClassifier.xcodeproj/project.pbxproj index 5cd141d..4a1f3b4 100644 --- a/iOS/BeerClassifier.xcodeproj/project.pbxproj +++ b/iOS/BeerClassifier.xcodeproj/project.pbxproj @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ 123BA1191FDD08880044B06D /* BeerClassifier.mlmodel in Sources */ = {isa = PBXBuildFile; fileRef = 123BA1181FDD08880044B06D /* BeerClassifier.mlmodel */; }; - 126C83B02158FB64000A755E /* BeerClassifierTuri.mlmodel in Sources */ = {isa = PBXBuildFile; fileRef = 126C83AF2158FB64000A755E /* BeerClassifierTuri.mlmodel */; }; 128169A91FCA5B570051F8D6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 128169A81FCA5B570051F8D6 /* AppDelegate.swift */; }; 128169AB1FCA5B570051F8D6 /* BeerClassifierViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 128169AA1FCA5B570051F8D6 /* BeerClassifierViewController.swift */; }; 128169AE1FCA5B570051F8D6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 128169AC1FCA5B570051F8D6 /* Main.storyboard */; }; @@ -30,7 +29,6 @@ /* Begin PBXFileReference section */ 123BA1181FDD08880044B06D /* BeerClassifier.mlmodel */ = {isa = PBXFileReference; lastKnownFileType = file.mlmodel; name = BeerClassifier.mlmodel; path = ../../models/BeerClassifier.mlmodel; sourceTree = ""; }; - 126C83AF2158FB64000A755E /* BeerClassifierTuri.mlmodel */ = {isa = PBXFileReference; lastKnownFileType = file.mlmodel; name = BeerClassifierTuri.mlmodel; path = ../../models/BeerClassifierTuri.mlmodel; sourceTree = ""; }; 128169A51FCA5B570051F8D6 /* BeerClassifier.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BeerClassifier.app; sourceTree = BUILT_PRODUCTS_DIR; }; 128169A81FCA5B570051F8D6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 128169AA1FCA5B570051F8D6 /* BeerClassifierViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BeerClassifierViewController.swift; sourceTree = ""; }; @@ -88,7 +86,6 @@ 128169C81FCA5BAD0051F8D6 /* ClassificationService.swift */, 128169AC1FCA5B570051F8D6 /* Main.storyboard */, 123BA1181FDD08880044B06D /* BeerClassifier.mlmodel */, - 126C83AF2158FB64000A755E /* BeerClassifierTuri.mlmodel */, 128169AF1FCA5B570051F8D6 /* Assets.xcassets */, 128169B11FCA5B570051F8D6 /* LaunchScreen.storyboard */, 128169B41FCA5B570051F8D6 /* Info.plist */, @@ -210,7 +207,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 126C83B02158FB64000A755E /* BeerClassifierTuri.mlmodel in Sources */, 123BA1191FDD08880044B06D /* BeerClassifier.mlmodel in Sources */, 128169AB1FCA5B570051F8D6 /* BeerClassifierViewController.swift in Sources */, 128169C91FCA5BAD0051F8D6 /* ClassificationService.swift in Sources */, @@ -306,7 +302,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.1; + IPHONEOS_DEPLOYMENT_TARGET = 14.5; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -359,7 +355,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.1; + IPHONEOS_DEPLOYMENT_TARGET = 14.5; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; diff --git a/iOS/BeerClassifier/ClassificationService.swift b/iOS/BeerClassifier/ClassificationService.swift index 431cea3..8f01a16 100644 --- a/iOS/BeerClassifier/ClassificationService.swift +++ b/iOS/BeerClassifier/ClassificationService.swift @@ -58,15 +58,20 @@ final class ClassificationService { // MARK: - Private private func setupClassification() throws { - let model = loadLocal() + let model = try loadLocal() try updateClassificationRequest(model: model) } private func loadModel(classificationType: ClassificationType, completion: ((MLModel) -> ())? = nil) throws { switch classificationType { case .beer3: - let model = loadLocal() - completion?(model) + do { + let model = try loadLocal() + completion?(model) + } catch let error { + print("Failed to load model. Error: \(error)") + assertionFailure() + } case .beer4: DispatchQueue.global(qos: .userInitiated).async { // For this sample app model isn't reused on purpose, @@ -91,9 +96,10 @@ final class ClassificationService { try data.write(to: filePathUrl) } - private func loadLocal() -> MLModel { -// let model = BeerClassifier() - let model = BeerClassifierTuri() + private func loadLocal() throws -> MLModel { + let configuration = MLModelConfiguration() + let model = try BeerClassifier(configuration: configuration) +// let model = BeerClassifierTuri() return model.model } diff --git a/requirements.txt b/requirements.txt index 8380e4e..414af30 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ bleach==1.5.0 certifi==2018.4.16 chardet==3.0.4 colorama==0.3.9 -coremltools==2.0b1 +coremltools==3.0b3 decorator==4.3.0 gast==0.2.0 graphviz==0.8.3 @@ -12,31 +12,23 @@ grpcio==1.12.1 h5py==2.8.0 html5lib==0.9999999 idna==2.6 -Keras==2.2.4 Keras-Applications==1.0.6 Keras-Preprocessing==1.0.5 -Markdown==2.6.11 -mxnet==1.1.0.post0 -numpy==1.14.4 -opencv-python==3.4.1.15 -pandas==0.23.0 -Pillow==5.1.0 +llvmlite==0.29.0 +mxnet==1.5.0 +numba==0.45.1 +numpy==1.16.4 +pandas==0.25.1 +Pillow==6.1.0 prettytable==0.7.2 -protobuf==3.6.1 -pysha3==1.0.2 -python-dateutil==2.7.3 -python-dotenv==0.8.2 -pytz==2018.4 -PyYAML==3.12 -requests==2.20.1 -scikit-learn==0.19.1 +protobuf==3.9.2 +python-dateutil==2.8.0 +python-dotenv==0.10.3 +pytz==2019.2 +requests==2.22.0 +resampy==0.2.1 scipy==1.1.0 +sha3==0.2.1 six==1.10.0 -tensorboard==1.12.0 -tensorflow==1.12.0 -tensorflow-tensorboard==1.5.1 -termcolor==1.1.0 -turicreate==5.1 -urllib3==1.22 -virtualenv==16.0.0 -Werkzeug==0.14.1 +turicreate==5.7.1 +urllib3==1.25.6