未验证 提交 4791da97 编写于 作者: R Ruilong Liu 提交者: GitHub

Merge pull request #934 from codeWorm2015/metal

 update paddle-mobile demo
...@@ -17,11 +17,11 @@ import MetalKit ...@@ -17,11 +17,11 @@ import MetalKit
import paddle_mobile import paddle_mobile
import MetalPerformanceShaders import MetalPerformanceShaders
let platform: Platform = .CPU let platform: Platform = .GPU
let threadSupport = [1] let threadSupport = [1]
let modelHelperMap: [SupportModel : Runner] = [.mobilenet_ssd : Runner.init(inNet: MobileNet_ssd_hand.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(), 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() //, .genet : Genet.init()
//let modelHelperMap: [SupportModel : Net] = [.mobilenet : MobileNet.init(), .mobilenet_ssd : MobileNet_ssd_hand.init()] //let modelHelperMap: [SupportModel : Net] = [.mobilenet : MobileNet.init(), .mobilenet_ssd : MobileNet_ssd_hand.init()]
...@@ -48,6 +48,7 @@ class ViewController: UIViewController { ...@@ -48,6 +48,7 @@ class ViewController: UIViewController {
var toPredictTexture: MTLTexture? var toPredictTexture: MTLTexture?
var runner: Runner { var runner: Runner {
get { get {
return modelHelperMap[modelType] ?! " has no this type " return modelHelperMap[modelType] ?! " has no this type "
} }
......
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
#import "CPUCompute.h" //#import <paddle_mobile/>
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
import Foundation import Foundation
class Genet: Net { public class Genet: Net {
@objc override init(device: MTLDevice) { @objc public override init(device: MTLDevice) {
super.init(device: device) super.init(device: device)
means = [128.0, 128.0, 128.0] means = [128.0, 128.0, 128.0]
scale = 0.017 scale = 0.017
...@@ -34,7 +34,7 @@ class Genet: Net { ...@@ -34,7 +34,7 @@ class Genet: Net {
} }
} }
override func resultStr(res: [Float]) -> String { override public func resultStr(res: [Float]) -> String {
return " \(Array<Float>(res.suffix(10))) ... " return " \(Array<Float>(res.suffix(10))) ... "
} }
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
import Foundation import Foundation
class MobileNet_ssd_hand: Net{ public class MobileNet_ssd_hand: Net{
@objc override init(device: MTLDevice) { @objc public override init(device: MTLDevice) {
super.init(device: device) super.init(device: device)
means = [123.68, 116.78, 103.94] means = [123.68, 116.78, 103.94]
scale = 0.017 scale = 0.017
...@@ -34,7 +34,7 @@ class MobileNet_ssd_hand: Net{ ...@@ -34,7 +34,7 @@ class MobileNet_ssd_hand: Net{
} }
} }
override func resultStr(res: [Float]) -> String { override public func resultStr(res: [Float]) -> String {
return " \(res)" return " \(res)"
} }
......
...@@ -33,7 +33,7 @@ public class Net: NSObject { ...@@ -33,7 +33,7 @@ public class Net: NSObject {
var modelPath: String = "" var modelPath: String = ""
var paramPath: String = "" var paramPath: String = ""
var modelDir: String = "" var modelDir: String = ""
func resultStr(res: [Float]) -> String { public func resultStr(res: [Float]) -> String {
fatalError() fatalError()
} }
func fetchResult(paddleMobileRes: ResultHolder) -> [Float32] { func fetchResult(paddleMobileRes: ResultHolder) -> [Float32] {
......
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
typedef enum : NSUInteger { typedef enum : NSUInteger {
MobileNet, MobileNetType,
MobileNetSSD, MobileNetSSDType,
Genet, GenetType,
} NetType; } NetType;
@interface ModelConfig: NSObject @interface ModelConfig: NSObject
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册