Skip to content

Commit

Permalink
update evil model download configure formatter.
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGong2013 committed Jan 30, 2018
1 parent 891a9bf commit 40dd939
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
13 changes: 8 additions & 5 deletions Source/Recognizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ public enum Recognizer {
case chineseIDCard
case custom(name: String, model: URL, needComplie: Bool, processor: Processor?) // local complied model url

static var modelBaseURL: URL = {
static func modelBaseURL(_ name: String) -> URL {
let info = Bundle.main.infoDictionary
guard let baseURL = info?["EvilModelBaseURL"] as? String else {
guard let baseURL = (info?["Evil"] as? [String: String])?[name] else {
fatalError("please set `EvilModelBaseURL` in `info.plist`")
}
return URL(string: baseURL)!
}()
guard let url = URL(string: baseURL) else {
fatalError("please double check \(name)'s download url: \(baseURL)")
}
return url
}

static let documentURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] as URL
static let cacheURL = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0] as URL
Expand All @@ -61,7 +64,7 @@ public enum Recognizer {
if case .custom(_, let url, let needComplie, _) = self {
return needComplie ? url : nil
}
return Recognizer.modelBaseURL.appendingPathComponent("\(name).mlmodel")
return Recognizer.modelBaseURL(name)
}

// 已经编译好的model 可以直接使用
Expand Down
7 changes: 5 additions & 2 deletions iOS Example/iOS Example/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>EvilModelBaseURL</key>
<string>http://ou5pk1mdu.bkt.clouddn.com</string>
<key>Evil</key>
<dict>
<key>ChineseIDCard</key>
<string>http://ou5pk1mdu.bkt.clouddn.com</string>
</dict>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down

0 comments on commit 40dd939

Please sign in to comment.