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

Merge pull request #934 from codeWorm2015/metal

 update paddle-mobile demo
......@@ -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 "
}
......
......@@ -4,4 +4,4 @@
#import "CPUCompute.h"
//#import <paddle_mobile/>
......@@ -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<Float>(res.suffix(10))) ... "
}
......
......@@ -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)"
}
......
......@@ -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] {
......
......@@ -16,9 +16,9 @@
#import <Foundation/Foundation.h>
typedef enum : NSUInteger {
MobileNet,
MobileNetSSD,
Genet,
MobileNetType,
MobileNetSSDType,
GenetType,
} NetType;
@interface ModelConfig: NSObject
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册