添加链接
注册
登录
link管理
链接快照平台
输入网页链接,自动生成快照
标签化管理网页链接
相关文章推荐
纯真的马铃薯
·
Results - OpenURL ...
·
1 月前
·
知识渊博的硬币
·
日式快餐,败走中国 | CBNData
·
1 月前
·
满身肌肉的野马
·
京港澳高速扩能东移,长沙四环要来了?_项目_ ...
·
2 月前
·
淡定的橙子
·
canvasvg · PyPI
·
2 月前
·
不羁的课本
·
“奔跑吧·少年”!第四届河南省少儿趣味田径锦 ...
·
3 月前
·
link管理
›
mc-cnn-chainer/demo.py at master · t-taniai/mc-cnn-chainer · GitHub
https://github.com/t-taniai/mc-cnn-chainer/blob/master/demo.py
完美的领带
1 月前
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Files
master
Breadcrumbs
mc-cnn-chainer
/
demo.py
Blame
Blame
Latest commit
History
History
82 lines (64 loc) · 2.65 KB
master
Breadcrumbs
mc-cnn-chainer
/
demo.py
Top
File metadata and controls
Code
Blame
82 lines (64 loc) · 2.65 KB
Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from
__future__
import
print_function
import
argparse
import
chainer
import
cv2
import
numpy
as
np
import
mcnet
import
os
def
str2bool
(
v
):
if
v
.
lower
()
in
(
'yes'
,
'true'
,
't'
,
'y'
,
'1'
):
return
True
elif
v
.
lower
()
in
(
'no'
,
'false'
,
'f'
,
'n'
,
'0'
):
return
False
else
:
raise
argparse
.
ArgumentTypeError
(
'Boolean value expected.'
)
def
load_image
(
file
):
img
=
cv2
.
imread
(
file
,
cv2
.
IMREAD_ANYCOLOR
)
if
img
.
ndim
==
3
:
img
=
np
.
rollaxis
(
img
,
2
,
0
)
else
:
img
=
img
[
None
]
return
img
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
'Dynamic SGM Net'
)
parser
.
add_argument
(
'--gpu'
,
'-g'
,
type
=
int
,
default
=
-
1
,
help
=
'GPU ID (negative value indicates CPU)'
)
parser
.
add_argument
(
'--out'
,
'-o'
,
default
=
'output'
,
help
=
'Directory to output the result'
)
parser
.
add_argument
(
'--vol'
,
'-v'
,
type
=
str2bool
,
default
=
False
,
help
=
'Save cost volume data'
)
args
=
parser
.
parse_args
()
outdir
=
args
.
out
print
(
'cuda:'
+
str
(
chainer
.
cuda
.
available
))
print
(
'cudnn:'
+
str
(
chainer
.
cuda
.
cudnn_enabled
))
print
(
'GPU: {}'
.
format
(
args
.
gpu
))
print
(
'outdir: '
,
outdir
)
print
(
''
)
chainer
.
config
.
train
=
False
chainer
.
set_debug
(
False
)
chainer
.
using_config
(
'use_cudnn'
,
'auto'
)
# Load MC-CNN pre-trained models from
# kitti_fast, kitti_slow, kitti2015_fast, kitti2015_slow, mb_fast, mb_slow
model_kitti
=
mcnet
.
MCCNN_pretrained
(
'mccnn/kitti_fast'
)
model_mb
=
mcnet
.
MCCNN_pretrained
(
'mccnn/mb_slow'
)
if
args
.
gpu
>=
0
:
# Make a specified GPU current
chainer
.
cuda
.
get_device_from_id
(
args
.
gpu
).
use
()
model_kitti
.
to_gpu
()
# Copy the model to the GPU
model_mb
.
to_gpu
()
# Copy the model to the GPU
samples
=
[]
#samples.append((model_mb, 'mb2014', 145))
samples
.
append
((
model_kitti
,
'kitti'
,
70
))
for
sample
in
samples
:
model
,
target
,
ndisp
=
sample
print
(
'Processing '
+
target
)
im0
=
load_image
(
os
.
path
.
join
(
'input'
,
target
,
'im0.png'
)).
astype
(
np
.
float32
)
im1
=
load_image
(
os
.
path
.
join
(
'input'
,
target
,
'im1.png'
)).
astype
(
np
.
float32
)
inputs
=
(
im0
,
im1
,
np
.
array
([
ndisp
]))
batch
=
chainer
.
dataset
.
concat_examples
([
inputs
],
args
.
gpu
)
with
chainer
.
no_backprop_mode
():
vol
=
model
(
*
batch
)[
0
].
array
disp
=
vol
.
argmin
(
0
).
astype
(
np
.
float32
)
*
(
255
/
ndisp
)
os
.
makedirs
(
os
.
path
.
join
(
args
.
out
,
target
),
exist_ok
=
True
)
cv2
.
imwrite
(
os
.
path
.
join
(
args
.
out
,
target
,
'disp0.png'
),
chainer
.
cuda
.
to_cpu
(
disp
))
if
args
.
vol
:
vol
.
tofile
(
os
.
path
.
join
(
args
.
out
,
target
,
'im0.bin'
))
if
__name__
==
'__main__'
:
main
()
推荐文章
纯真的马铃薯
·
Results - OpenURL Connection - EBSCO
1 月前
知识渊博的硬币
·
日式快餐,败走中国 | CBNData
1 月前
满身肌肉的野马
·
京港澳高速扩能东移,长沙四环要来了?_项目_发展_湖南省
2 月前
淡定的橙子
·
canvasvg · PyPI
2 月前
不羁的课本
·
“奔跑吧·少年”!第四届河南省少儿趣味田径锦标赛在宜阳县举行_青少年体育_河南省体育局
3 月前