DoreDeepStyle
Getting Started
The following instructions will guide you on how to implement the DoreDeepStyle SDK on a specific platform.
IOS
Technical Specifications:
Xcode | 14.2 or Above |
IOS Version | 13.0 or Above |
Supported Device | Min iPhoneSE |
You can implement DoreDeepStyle SDK in your existing/new IOS Xcode project with in just 3 Steps
Step 1:
1. Add this line in your pod file
pod 'DoreDeepStyle'
2. Run pod install, and open project
pod install
3. Cocoapod version should be 1.12.1 or above
Step 2:
Initiate DoreDeepStyle Manager
private var modelManager: DeepStyleManager?
modelManager = DeepStyleManager()
modelManager?.delegate = self
//load license
let isValid:Bool = (modelManager?.init_data(licKey: "insert your license key here") ?? false)
if(!isValid){
print("Lic not valid")
}
Step 3:
insert "DoreDeepStyleLoadDelegate" to get style load callback
class ImageFilter: UIViewController, DoreDeepStyleLoadDelegate
Load style (ID : s1 to s189 ) - Internet connection required to load style
modelManager?.load_style(styleID: "s2")
Load styles in offline mode :
There are two ways to load styles in offline mode -
1. Load from Bundle path
2. Load from self hosted server
you can download all style template files from this link : https://github.com/doreai/DeepStyleFilters/tree/master/ios
Load From Bundle path :
Add required style template file into your bundle, and use load style method with specific style ID
Example:
Add "s122.dat" file in your project and load style using load
modelManager?.load_style(styleID: "s122")
if that specific style ID is available in your bundle it will load from local or it will load from DoreAI CDN server
Load From self hosted server :
Place your style template file in to your server, and use load style method with web URL path as below
modelManager?.load_stylebyURL(URLPath: "https://yourserver.com/stylepath/", styleID: "s122")
DoreDeepStyleLoad Callback
func onDeepStyleLoadSuccess(_ info: String) {
//style loaded...!
run_filter()
}
func onDeepStyleLoadFailure(_ error: String) {
print(error)
}
func onDeepStyleLoadProgressUpdate(_ progress: String) {
print(progress)
}
func onDeepStyleLoadDownloadSpeed(_ dps: String) {
print(dps)
}
Execute with input image
func run_filter(){
let result:TextureOut = TextureOut ( features: (modelManager?.run_model(onFrame: curPixelBuffr))! )
let ciImage = CIImage(cvPixelBuffer: (result.semanticPredictions))
let context = CIContext()
guard let cgImage = context.createCGImage(ciImage, from: ciImage.extent) else { return }
let setImage = UIImage(cgImage: cgImage)
DispatchQueue.main.async {
self.outputview.image = setImage
}
}