Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv_extra
提交
8c6a0fa3
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 搜索 >>
提交
8c6a0fa3
编写于
7月 27, 2023
作者:
A
Alexander Smorkalov
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 4.x
上级
2976f0ef
7c077a7e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
32 addition
and
2 deletion
+32
-2
testdata/dnn/tensorflow/generate_tf2_models.py
testdata/dnn/tensorflow/generate_tf2_models.py
+2
-2
testdata/dnn/tensorflow/tf2_prelu_in.npy
testdata/dnn/tensorflow/tf2_prelu_in.npy
+0
-0
testdata/dnn/tensorflow/tf2_prelu_net.pb
testdata/dnn/tensorflow/tf2_prelu_net.pb
+0
-0
testdata/dnn/tensorflow/tf2_prelu_out.npy
testdata/dnn/tensorflow/tf2_prelu_out.npy
+0
-0
testdata/dnn/tflite/generate.py
testdata/dnn/tflite/generate.py
+30
-0
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/tensorflow/generate_tf2_models.py
浏览文件 @
8c6a0fa3
...
...
@@ -76,9 +76,9 @@ model = tf.keras.models.Sequential([
save
(
model
,
'tf2_dense'
,
flatten_input
=
tf
.
TensorSpec
(
shape
=
[
None
,
1
,
2
,
3
],
dtype
=
tf
.
float32
))
################################################################################
model
=
tf
.
keras
.
models
.
Sequential
([
tf
.
keras
.
layers
.
PReLU
(
input_shape
=
(
1
,
2
,
3
)
),
tf
.
keras
.
layers
.
PReLU
(
input_shape
=
(
1
,
4
,
6
),
alpha_initializer
=
'random_normal'
),
])
save
(
model
,
'tf2_prelu'
,
p_re_lu_input
=
tf
.
TensorSpec
(
shape
=
[
None
,
1
,
2
,
3
],
dtype
=
tf
.
float32
))
save
(
model
,
'tf2_prelu'
,
p_re_lu_input
=
tf
.
TensorSpec
(
shape
=
[
None
,
1
,
4
,
6
],
dtype
=
tf
.
float32
))
################################################################################
model
=
tf
.
keras
.
models
.
Sequential
([
tf
.
keras
.
layers
.
AveragePooling2D
(
input_shape
=
(
4
,
6
,
3
),
pool_size
=
(
2
,
2
)),
...
...
testdata/dnn/tensorflow/tf2_prelu_in.npy
浏览文件 @
8c6a0fa3
无法预览此类型文件
testdata/dnn/tensorflow/tf2_prelu_net.pb
浏览文件 @
8c6a0fa3
无法预览此类型文件
testdata/dnn/tensorflow/tf2_prelu_out.npy
浏览文件 @
8c6a0fa3
无法预览此类型文件
testdata/dnn/tflite/generate.py
浏览文件 @
8c6a0fa3
...
...
@@ -45,3 +45,33 @@ run_tflite_model("face_landmark", (192, 192))
run_tflite_model
(
"face_detection_short_range"
,
(
128
,
128
))
run_mediapipe_solution
(
mp
.
solutions
.
selfie_segmentation
.
SelfieSegmentation
(
model_selection
=
0
),
(
256
,
256
))
# Save TensorFlow model as TFLite
def
save_tflite_model
(
model
,
inp
,
name
):
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_Identity.npy'
,
np
.
array
(
out
).
transpose
(
0
,
3
,
1
,
2
))
@
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
inp
=
np
.
random
.
standard_normal
((
1
,
3
,
3
,
1
)).
astype
(
np
.
float32
)
save_tflite_model
(
replicate_by_pack
,
inp
,
'replicate_by_pack'
)
testdata/dnn/tflite/replicate_by_pack.tflite
0 → 100644
浏览文件 @
8c6a0fa3
文件已添加
testdata/dnn/tflite/replicate_by_pack_inp.npy
0 → 100644
浏览文件 @
8c6a0fa3
文件已添加
testdata/dnn/tflite/replicate_by_pack_out_Identity.npy
0 → 100644
浏览文件 @
8c6a0fa3
文件已添加
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录