Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Oneflow-Inc
OneFlow-Benchmark
提交
a09a8126
O
OneFlow-Benchmark
项目概览
Oneflow-Inc
/
OneFlow-Benchmark
上一次同步 2 年多
通知
1
Star
92
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
OneFlow-Benchmark
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a09a8126
编写于
7月 29, 2020
作者:
F
Flowingsun007
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify functions with new api >> global_function
上级
8b9075ab
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
9 addition
and
8 deletion
+9
-8
Classification/cnns/of_cnn_inference.py
Classification/cnns/of_cnn_inference.py
+7
-6
Classification/cnns/of_cnn_train_val.py
Classification/cnns/of_cnn_train_val.py
+2
-2
未找到文件。
Classification/cnns/of_cnn_inference.py
浏览文件 @
a09a8126
...
...
@@ -7,6 +7,7 @@ import numpy as np
from
PIL
import
Image
import
config
as
configs
parser
=
configs
.
get_parser
()
args
=
parser
.
parse_args
()
configs
.
print_args
(
args
)
...
...
@@ -38,9 +39,9 @@ def load_image(image_path='test_img/ILSVRC2012_val_00020287.JPEG'):
return
np
.
ascontiguousarray
(
im
,
'float32'
)
@
flow
.
global_function
(
flow
.
function_config
())
def
InferenceNet
(
images
:
tp
.
Numpy
.
Placeholder
((
1
,
3
,
224
,
224
),
dtype
=
flow
.
float
))
:
logits
=
model_dict
[
args
.
model
](
images
,
training
=
False
)
@
flow
.
global_function
(
"predict"
,
flow
.
function_config
())
def
InferenceNet
(
images
:
tp
.
Numpy
.
Placeholder
((
1
,
3
,
224
,
224
),
dtype
=
flow
.
float
))
->
tp
.
Numpy
:
logits
=
model_dict
[
args
.
model
](
images
,
training
=
False
)
predictions
=
flow
.
nn
.
softmax
(
logits
)
return
predictions
...
...
@@ -52,9 +53,9 @@ def main():
check_point
.
load
(
args
.
model_load_dir
)
image
=
load_image
(
args
.
image_path
)
predictions
=
InferenceNet
(
image
)
.
get
()
clsidx
=
predictions
.
numpy
().
argmax
()
print
(
predictions
.
numpy
().
max
(),
clsidx_2_labels
[
clsidx
])
predictions
=
InferenceNet
(
image
)
clsidx
=
predictions
.
argmax
()
print
(
predictions
.
max
(),
clsidx_2_labels
[
clsidx
])
if
__name__
==
"__main__"
:
...
...
Classification/cnns/of_cnn_train_val.py
浏览文件 @
a09a8126
...
...
@@ -43,7 +43,7 @@ def label_smoothing(labels, classes, eta, dtype):
on_value
=
1
-
eta
+
eta
/
classes
,
off_value
=
eta
/
classes
)
@
flow
.
global_function
(
get_train_config
(
args
))
@
flow
.
global_function
(
"train"
,
get_train_config
(
args
))
def
TrainNet
():
if
args
.
train_data_dir
:
assert
os
.
path
.
exists
(
args
.
train_data_dir
)
...
...
@@ -68,7 +68,7 @@ def TrainNet():
return
outputs
@
flow
.
global_function
(
get_val_config
(
args
))
@
flow
.
global_function
(
"predict"
,
get_val_config
(
args
))
def
InferenceNet
():
if
args
.
val_data_dir
:
assert
os
.
path
.
exists
(
args
.
val_data_dir
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录