Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv_extra
提交
89d03b05
O
opencv_extra
项目概览
OpenCV
/
opencv_extra
10 个月 前同步成功
通知
118
Star
882
Fork
1584
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv_extra
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
89d03b05
编写于
7月 18, 2023
作者:
D
Dmitry Kurtaev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update test data
上级
06b91360
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
14 addition
and
15 deletion
+14
-15
testdata/dnn/tflite/generate.py
testdata/dnn/tflite/generate.py
+14
-15
testdata/dnn/tflite/replicate_by_pack.tflite
testdata/dnn/tflite/replicate_by_pack.tflite
+0
-0
testdata/dnn/tflite/replicate_by_pack_inp.npy
testdata/dnn/tflite/replicate_by_pack_inp.npy
+0
-0
testdata/dnn/tflite/replicate_by_pack_out_Identity.npy
testdata/dnn/tflite/replicate_by_pack_out_Identity.npy
+0
-0
未找到文件。
testdata/dnn/tflite/generate.py
浏览文件 @
89d03b05
...
...
@@ -48,31 +48,30 @@ run_mediapipe_solution(mp.solutions.selfie_segmentation.SelfieSegmentation(model
# Save TensorFlow model as TFLite
def
save_tflite_model
(
model
,
inp
,
name
):
func
=
model
.
__call__
.
get_concrete_function
()
converter
=
tf
.
lite
.
TFLiteConverter
.
from_concrete_functions
([
func
]
,
model
)
func
=
model
.
get_concrete_function
()
converter
=
tf
.
lite
.
TFLiteConverter
.
from_concrete_functions
([
func
])
tflite_model
=
converter
.
convert
()
interpreter
=
tf
.
lite
.
Interpreter
(
model_content
=
tflite_model
)
with
open
(
f
'
{
name
}
.tflite'
,
'wb'
)
as
f
:
f
.
write
(
tflite_model
)
out
=
model
(
inp
)
np
.
save
(
f
'
{
name
}
_inp.npy'
,
inp
.
transpose
(
0
,
3
,
1
,
2
))
np
.
save
(
f
'
{
name
}
_out_
PartitionedCall:0
.npy'
,
np
.
array
(
out
).
transpose
(
0
,
3
,
1
,
2
))
np
.
save
(
f
'
{
name
}
_out_
Identity
.npy'
,
np
.
array
(
out
).
transpose
(
0
,
3
,
1
,
2
))
class
ReplicateByPack
(
tf
.
Module
):
@
tf
.
function
(
input_signature
=
[
tf
.
TensorSpec
(
shape
=
[
1
,
3
,
3
,
1
],
dtype
=
tf
.
float32
)])
def
__call__
(
self
,
x
):
pack_1
=
tf
.
stack
([
x
,
x
],
axis
=
3
)
reshape_1
=
tf
.
reshape
(
pack_1
,
[
1
,
3
,
6
,
1
])
pack_2
=
tf
.
stack
([
reshape_1
,
reshape_1
],
axis
=
2
)
reshape_2
=
tf
.
reshape
(
pack_2
,
[
1
,
6
,
6
,
1
])
scaled
=
tf
.
image
.
resize
(
reshape_2
,
size
=
(
3
,
3
),
method
=
tf
.
image
.
ResizeMethod
.
NEAREST_NEIGHBOR
)
return
scaled
+
x
@
tf
.
function
(
input_signature
=
[
tf
.
TensorSpec
(
shape
=
[
1
,
3
,
3
,
1
],
dtype
=
tf
.
float32
)])
def
replicate_by_pack
(
x
):
pack_1
=
tf
.
stack
([
x
,
x
],
axis
=
3
)
reshape_1
=
tf
.
reshape
(
pack_1
,
[
1
,
3
,
6
,
1
])
pack_2
=
tf
.
stack
([
reshape_1
,
reshape_1
],
axis
=
2
)
reshape_2
=
tf
.
reshape
(
pack_2
,
[
1
,
6
,
6
,
1
])
scaled
=
tf
.
image
.
resize
(
reshape_2
,
size
=
(
3
,
3
),
method
=
tf
.
image
.
ResizeMethod
.
NEAREST_NEIGHBOR
)
return
scaled
+
x
model
=
ReplicateByPack
()
inp
=
np
.
random
.
standard_normal
((
1
,
3
,
3
,
1
)).
astype
(
np
.
float32
)
save_tflite_model
(
model
,
inp
,
'replicate_by_pack'
)
save_tflite_model
(
replicate_by_pack
,
inp
,
'replicate_by_pack'
)
testdata/dnn/tflite/replicate_by_pack.tflite
浏览文件 @
89d03b05
无法预览此类型文件
testdata/dnn/tflite/replicate_by_pack_inp.npy
浏览文件 @
89d03b05
无法预览此类型文件
testdata/dnn/tflite/replicate_by_pack_out_
PartitionedCall:0
.npy
→
testdata/dnn/tflite/replicate_by_pack_out_
Identity
.npy
浏览文件 @
89d03b05
无法预览此类型文件
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录