From 6ec7d791fe942faf95025738890c1c863f0ad2b5 Mon Sep 17 00:00:00 2001 From: liuruilong Date: Mon, 10 Sep 2018 14:12:47 +0800 Subject: [PATCH] update paddle-mobile demo --- .../paddle-mobile-demo/ViewController.swift | 7 ++++--- .../paddle-mobile-demo-Bridging-Header.h | 2 +- metal/paddle-mobile/paddle-mobile/Genet.swift | 6 +++--- metal/paddle-mobile/paddle-mobile/MobileNetSSD.swift | 6 +++--- metal/paddle-mobile/paddle-mobile/PaddleMobile.swift | 2 +- metal/paddle-mobile/paddle-mobile/PaddleMobileGPU.h | 6 +++--- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift b/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift index 69fb820cd5..e249c3aea9 100644 --- a/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift +++ b/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift @@ -17,11 +17,11 @@ import MetalKit import paddle_mobile import MetalPerformanceShaders -let platform: Platform = .CPU +let platform: Platform = .GPU let threadSupport = [1] -let modelHelperMap: [SupportModel : Runner] = [.mobilenet_ssd : Runner.init(inNet: MobileNet_ssd_hand.init(), commandQueue: MetalHelper.shared.queue, inPlatform: platform), - .genet : Runner.init(inNet: Genet.init(), commandQueue: MetalHelper.shared.queue, inPlatform: platform)] +let modelHelperMap: [SupportModel : Runner] = [.mobilenet_ssd : Runner.init(inNet: MobileNet_ssd_hand.init(device: MetalHelper.shared.device), commandQueue: MetalHelper.shared.queue, inPlatform: platform), + .genet : Runner.init(inNet: Genet.init(device: MetalHelper.shared.device), commandQueue: MetalHelper.shared.queue, inPlatform: platform)] //, .genet : Genet.init() //let modelHelperMap: [SupportModel : Net] = [.mobilenet : MobileNet.init(), .mobilenet_ssd : MobileNet_ssd_hand.init()] @@ -48,6 +48,7 @@ class ViewController: UIViewController { var toPredictTexture: MTLTexture? var runner: Runner { + get { return modelHelperMap[modelType] ?! " has no this type " } diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo/paddle-mobile-demo-Bridging-Header.h b/metal/paddle-mobile-demo/paddle-mobile-demo/paddle-mobile-demo-Bridging-Header.h index 7a56ca282a..25434fa4b6 100644 --- a/metal/paddle-mobile-demo/paddle-mobile-demo/paddle-mobile-demo-Bridging-Header.h +++ b/metal/paddle-mobile-demo/paddle-mobile-demo/paddle-mobile-demo-Bridging-Header.h @@ -4,4 +4,4 @@ -#import "CPUCompute.h" +//#import diff --git a/metal/paddle-mobile/paddle-mobile/Genet.swift b/metal/paddle-mobile/paddle-mobile/Genet.swift index 2479cdf26e..40c190ef87 100644 --- a/metal/paddle-mobile/paddle-mobile/Genet.swift +++ b/metal/paddle-mobile/paddle-mobile/Genet.swift @@ -14,8 +14,8 @@ import Foundation -class Genet: Net { - @objc override init(device: MTLDevice) { +public class Genet: Net { + @objc public override init(device: MTLDevice) { super.init(device: device) means = [128.0, 128.0, 128.0] scale = 0.017 @@ -34,7 +34,7 @@ class Genet: Net { } } - override func resultStr(res: [Float]) -> String { + override public func resultStr(res: [Float]) -> String { return " \(Array(res.suffix(10))) ... " } diff --git a/metal/paddle-mobile/paddle-mobile/MobileNetSSD.swift b/metal/paddle-mobile/paddle-mobile/MobileNetSSD.swift index a7901d0552..47003043d9 100644 --- a/metal/paddle-mobile/paddle-mobile/MobileNetSSD.swift +++ b/metal/paddle-mobile/paddle-mobile/MobileNetSSD.swift @@ -14,8 +14,8 @@ import Foundation -class MobileNet_ssd_hand: Net{ - @objc override init(device: MTLDevice) { +public class MobileNet_ssd_hand: Net{ + @objc public override init(device: MTLDevice) { super.init(device: device) means = [123.68, 116.78, 103.94] scale = 0.017 @@ -34,7 +34,7 @@ class MobileNet_ssd_hand: Net{ } } - override func resultStr(res: [Float]) -> String { + override public func resultStr(res: [Float]) -> String { return " \(res)" } diff --git a/metal/paddle-mobile/paddle-mobile/PaddleMobile.swift b/metal/paddle-mobile/paddle-mobile/PaddleMobile.swift index d3f089e902..be768f665f 100644 --- a/metal/paddle-mobile/paddle-mobile/PaddleMobile.swift +++ b/metal/paddle-mobile/paddle-mobile/PaddleMobile.swift @@ -33,7 +33,7 @@ public class Net: NSObject { var modelPath: String = "" var paramPath: String = "" var modelDir: String = "" - func resultStr(res: [Float]) -> String { + public func resultStr(res: [Float]) -> String { fatalError() } func fetchResult(paddleMobileRes: ResultHolder) -> [Float32] { diff --git a/metal/paddle-mobile/paddle-mobile/PaddleMobileGPU.h b/metal/paddle-mobile/paddle-mobile/PaddleMobileGPU.h index 459a5b4bc1..0f3235d5e8 100644 --- a/metal/paddle-mobile/paddle-mobile/PaddleMobileGPU.h +++ b/metal/paddle-mobile/paddle-mobile/PaddleMobileGPU.h @@ -16,9 +16,9 @@ #import typedef enum : NSUInteger { - MobileNet, - MobileNetSSD, - Genet, + MobileNetType, + MobileNetSSDType, + GenetType, } NetType; @interface ModelConfig: NSObject -- GitLab