Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
dde099b1
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
dde099b1
编写于
9月 21, 2018
作者:
X
xiaohaichun
提交者:
GitHub
9月 21, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1003 from xiaohaichun/metal
update ssdar
上级
05316393
ad4730f9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
17 deletion
+37
-17
metal/paddle-mobile-demo/paddle-mobile-demo/LoadPointerViewController.m
...obile-demo/paddle-mobile-demo/LoadPointerViewController.m
+14
-6
metal/paddle-mobile/paddle-mobile/MobilenetSSD_AR.swift
metal/paddle-mobile/paddle-mobile/MobilenetSSD_AR.swift
+22
-10
metal/paddle-mobile/paddle-mobile/PaddleMobileGPU.m
metal/paddle-mobile/paddle-mobile/PaddleMobileGPU.m
+1
-1
未找到文件。
metal/paddle-mobile-demo/paddle-mobile-demo/LoadPointerViewController.m
浏览文件 @
dde099b1
...
...
@@ -31,8 +31,11 @@
self
.
queue
=
[
self
.
device
newCommandQueue
];
// Do any additional setup after loading the view.
NSString
*
modelPath
=
[[
NSBundle
mainBundle
]
URLForResource
:
@"genet_model"
withExtension
:
nil
].
path
;
NSString
*
paramPath
=
[[
NSBundle
mainBundle
]
URLForResource
:
@"genet_params"
withExtension
:
nil
].
path
;
// NSString *modelPath = [[NSBundle mainBundle] URLForResource:@"genet_model" withExtension:nil].path;
// NSString *paramPath = [[NSBundle mainBundle] URLForResource:@"genet_params" withExtension:nil].path;
NSString
*
modelPath
=
[[
NSBundle
mainBundle
]
URLForResource
:
@"ar_model"
withExtension
:
nil
].
path
;
NSString
*
paramPath
=
[[
NSBundle
mainBundle
]
URLForResource
:
@"ar_params"
withExtension
:
nil
].
path
;
long
fileSize
;
FILE
*
fp
;
...
...
@@ -55,16 +58,21 @@
fclose
(
parmaFilePointer
);
_modelConfig
=
[[
ModelConfig
alloc
]
init
];
_modelConfig
.
means
=
@[[
NSNumber
numberWithFloat
:
128
.
0
],
[
NSNumber
numberWithFloat
:
128
.
0
],
[
NSNumber
numberWithFloat
:
128
.
0
]];
_modelConfig
.
scale
=
0
.
017
;
_modelConfig
.
dims
=
@[[
NSNumber
numberWithFloat
:
1
],
[
NSNumber
numberWithFloat
:
128
.],
[
NSNumber
numberWithFloat
:
128
.
0
],[
NSNumber
numberWithFloat
:
3
.
0
]];
// _modelConfig.means = @[[NSNumber numberWithFloat:128.0], [NSNumber numberWithFloat:128.0], [NSNumber numberWithFloat:128.0]];
// _modelConfig.scale = 0.017;
// _modelConfig.dims = @[[NSNumber numberWithFloat:1], [NSNumber numberWithFloat:128.], [NSNumber numberWithFloat:128.0],[NSNumber numberWithFloat:3.0]];
_modelConfig
.
means
=
@[[
NSNumber
numberWithFloat
:
103
.
94
],
[
NSNumber
numberWithFloat
:
116
.
78
],
[
NSNumber
numberWithFloat
:
123
.
68
]];
_modelConfig
.
scale
=
1
;
_modelConfig
.
dims
=
@[[
NSNumber
numberWithFloat
:
1
],
[
NSNumber
numberWithFloat
:
160
.],
[
NSNumber
numberWithFloat
:
160
.
0
],[
NSNumber
numberWithFloat
:
3
.
0
]];
_modelConfig
.
modelPointer
=
buffer
;
_modelConfig
.
modelSize
=
(
int
)
fileSize
;
_modelConfig
.
paramPointer
=
parmaBuffer
;
_modelConfig
.
paramSize
=
(
int
)
paramfileSize
;
}
-
(
IBAction
)
loaderButtonPressed
:(
id
)
sender
{
_runner
=
[[
PaddleMobileGPU
alloc
]
initWithCommandQueue
:
self
.
queue
net
:
GenetType
modelConfig
:
_modelConfig
];
// _runner = [[PaddleMobileGPU alloc] initWithCommandQueue:self.queue net:GenetType modelConfig:_modelConfig];
_runner
=
[[
PaddleMobileGPU
alloc
]
initWithCommandQueue
:
self
.
queue
net
:
MobileNetSSDType
modelConfig
:
_modelConfig
];
[
_runner
load
];
}
-
(
IBAction
)
predictButtonPressed
:(
id
)
sender
{
...
...
metal/paddle-mobile/paddle-mobile/MobilenetSSD_AR.swift
浏览文件 @
dde099b1
...
...
@@ -27,6 +27,18 @@ public class MobileNet_ssd_AR: Net{
dim
=
(
n
:
1
,
h
:
160
,
w
:
160
,
c
:
3
)
}
@objc
override
public
init
(
device
:
MTLDevice
,
paramPointer
:
UnsafeMutableRawPointer
,
paramSize
:
Int
,
modePointer
:
UnsafeMutableRawPointer
,
modelSize
:
Int
)
{
super
.
init
(
device
:
device
,
paramPointer
:
paramPointer
,
paramSize
:
paramSize
,
modePointer
:
modePointer
,
modelSize
:
modelSize
)
means
=
[
103.94
,
116.78
,
123.68
]
scale
=
1
except
=
2
modelPath
=
""
paramPath
=
""
modelDir
=
""
preprocessKernel
=
MobilenetssdPreProccess
.
init
(
device
:
device
)
dim
=
(
n
:
1
,
h
:
160
,
w
:
160
,
c
:
3
)
}
class
MobilenetssdPreProccess
:
CusomKernel
{
init
(
device
:
MTLDevice
)
{
let
s
=
CusomKernel
.
Shape
.
init
(
inWidth
:
160
,
inHeight
:
160
,
inChannel
:
3
)
...
...
@@ -90,32 +102,32 @@ public class MobileNet_ssd_AR: Net{
let
v
=
program
.
scope
[
output
]
!
let
originTexture
=
v
as!
Texture
<
Float32
>
originTexture
.
tensorDim
=
Dim
.
init
(
inDim
:
[
originTexture
.
tensorDim
[
1
]
/
7
,
originTexture
.
tensorDim
[
0
]
*
7
])
originTexture
.
dim
=
Dim
.
init
(
inDim
:
[
1
,
1
,
originTexture
.
dim
[
3
]
/
7
,
originTexture
.
dim
[
2
]
*
7
])
originTexture
.
padToFourDim
=
Dim
.
init
(
inDim
:
[
1
,
1
,
originTexture
.
padToFourDim
[
3
]
/
7
,
originTexture
.
padToFourDim
[
2
]
*
7
])
program
.
scope
[
output
]
=
originTexture
if
i
==
99
{
opDesc
.
attrs
[
"axis"
]
=
0
}
else
{
opDesc
.
attrs
[
"shape"
]
=
originTexture
.
tensorDim
.
dims
.
map
{
Int32
(
$0
)
}
}
}
for
i
in
[
58
,
59
,
88
,
89
,
95
,
96
,
68
,
69
,
78
,
79
]
{
let
opDesc
=
program
.
programDesc
.
blocks
[
0
]
.
ops
[
i
]
let
output
=
opDesc
.
outputs
[
"Out"
]
!.
first
!
let
v
=
program
.
scope
[
output
]
!
let
originTexture
=
v
as!
Texture
<
Float32
>
originTexture
.
tensorDim
=
Dim
.
init
(
inDim
:
[
originTexture
.
tensorDim
[
1
],
originTexture
.
tensorDim
[
2
]])
opDesc
.
attrs
[
"shape"
]
=
originTexture
.
tensorDim
.
dims
.
map
{
Int32
(
$0
)
}
}
for
i
in
[
60
,
101
,
90
,
97
,
70
,
80
]
{
let
opDesc
=
program
.
programDesc
.
blocks
[
0
]
.
ops
[
i
]
let
output
=
opDesc
.
outputs
[
"Out"
]
!.
first
!
...
...
@@ -124,7 +136,7 @@ public class MobileNet_ssd_AR: Net{
originTexture
.
tensorDim
=
Dim
.
init
(
inDim
:
[
originTexture
.
tensorDim
[
1
],
originTexture
.
tensorDim
[
2
]])
opDesc
.
attrs
[
"axis"
]
=
(
opDesc
.
attrs
[
"axis"
]
!
as!
Int
)
-
1
}
for
i
in
[
102
]
{
let
opDesc
=
program
.
programDesc
.
blocks
[
0
]
.
ops
[
i
]
for
output
in
opDesc
.
outputs
[
"Out"
]
!
{
...
...
metal/paddle-mobile/paddle-mobile/PaddleMobileGPU.m
浏览文件 @
dde099b1
...
...
@@ -49,7 +49,7 @@
if
(
netType
==
GenetType
)
{
net
=
[[
Genet
alloc
]
initWithDevice
:
queue
.
device
paramPointer
:
config
.
paramPointer
paramSize
:
config
.
paramSize
modePointer
:
config
.
modelPointer
modelSize
:
config
.
modelSize
];
}
else
if
(
netType
==
MobileNetSSDType
)
{
net
=
[[
MobileNet_ssd_
hand
alloc
]
initWithDevice
:
queue
.
device
paramPointer
:
config
.
paramPointer
paramSize
:
config
.
paramSize
modePointer
:
config
.
modelPointer
modelSize
:
config
.
modelSize
];
net
=
[[
MobileNet_ssd_
AR
alloc
]
initWithDevice
:
queue
.
device
paramPointer
:
config
.
paramPointer
paramSize
:
config
.
paramSize
modePointer
:
config
.
modelPointer
modelSize
:
config
.
modelSize
];
}
else
if
(
netType
==
MobileNetType
)
{
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录