Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Pytorch-Encoding
Commits
3ba8d2f7
Unverified
Commit
3ba8d2f7
authored
Jun 04, 2018
by
Hang Zhang
Committed by
GitHub
Jun 04, 2018
Browse files
rm (#62)
* rm * Delete demo.py
parent
ed5456d3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
40 deletions
+0
-40
experiments/segmentation/demo.py
experiments/segmentation/demo.py
+0
-21
experiments/segmentation/test_models.py
experiments/segmentation/test_models.py
+0
-19
No files found.
experiments/segmentation/demo.py
deleted
100644 → 0
View file @
ed5456d3
import
torch
import
encoding
# Get the model
model
=
encoding
.
models
.
get_model
(
'fcn_resnet50_ade'
,
pretrained
=
True
).
cuda
()
model
.
eval
()
# Prepare the image
url
=
'https://github.com/zhanghang1989/image-data/blob/master/'
+
\
'encoding/segmentation/ade20k/ADE_val_00001142.jpg?raw=true'
filename
=
'example.jpg'
img
=
encoding
.
utils
.
load_image
(
encoding
.
utils
.
download
(
url
,
filename
)).
cuda
().
unsqueeze
(
0
)
# Make prediction
output
=
model
.
evaluate
(
img
)
predict
=
torch
.
max
(
output
,
1
)[
1
].
cpu
().
numpy
()
+
1
# Get color pallete for visualization
mask
=
encoding
.
utils
.
get_mask_pallete
(
predict
,
'ade20k'
)
mask
.
save
(
'output.png'
)
experiments/segmentation/test_models.py
deleted
100644 → 0
View file @
ed5456d3
import
importlib
import
torch
import
encoding
from
option
import
Options
from
torch.autograd
import
Variable
if
__name__
==
"__main__"
:
args
=
Options
().
parse
()
model
=
encoding
.
models
.
get_segmentation_model
(
args
.
model
,
dataset
=
args
.
dataset
,
aux
=
args
.
aux
,
se_loss
=
args
.
se_loss
,
norm_layer
=
torch
.
nn
.
BatchNorm2d
)
print
(
'Creating the model:'
)
print
(
model
)
model
.
cuda
()
x
=
Variable
(
torch
.
Tensor
(
4
,
3
,
480
,
480
)).
cuda
()
with
torch
.
no_grad
():
out
=
model
(
x
)
for
y
in
out
:
print
(
y
.
size
())
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment