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
c4d27a8f
Unverified
Commit
c4d27a8f
authored
Apr 09, 2020
by
Hang Zhang
Committed by
GitHub
Apr 09, 2020
Browse files
table indent (#255)
parent
e11e8fa6
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
274 additions
and
33 deletions
+274
-33
docs/requirements.txt
docs/requirements.txt
+1
-0
docs/source/_static/theme_overrides.css
docs/source/_static/theme_overrides.css
+13
-0
docs/source/conf.py
docs/source/conf.py
+24
-7
docs/source/custom_directives.py
docs/source/custom_directives.py
+208
-0
docs/source/experiments/segmentation.rst
docs/source/experiments/segmentation.rst
+28
-26
No files found.
docs/requirements.txt
View file @
c4d27a8f
sphinx
sphinx
sphinx-gallery
sphinxcontrib-googleanalytics
sphinxcontrib-googleanalytics
-e git://github.com/zhanghang1989/autorch_sphinx_theme.git#egg=autorch_sphinx_theme
-e git://github.com/zhanghang1989/autorch_sphinx_theme.git#egg=autorch_sphinx_theme
docs/source/_static/theme_overrides.css
0 → 100644
View file @
c4d27a8f
/* override table width restrictions */
@media
screen
and
(
min-width
:
767px
)
{
.wy-table-responsive
table
td
{
/* !important prevents the common CSS stylesheets from overriding
this as on RTD they are loaded after this stylesheet */
white-space
:
normal
!important
;
}
.wy-table-responsive
{
overflow
:
visible
!important
;
}
}
docs/source/conf.py
View file @
c4d27a8f
...
@@ -20,8 +20,14 @@
...
@@ -20,8 +20,14 @@
# import os
# import os
# import sys
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# sys.path.insert(0, os.path.abspath('.'))
import
os
import
sys
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
'.'
))
import
encoding
import
encoding
import
autorch_sphinx_theme
import
autorch_sphinx_theme
import
glob
import
shutil
from
custom_directives
import
IncludeDirective
,
GalleryItemDirective
,
CustomGalleryItemDirective
# -- General configuration ------------------------------------------------
# -- General configuration ------------------------------------------------
...
@@ -33,6 +39,7 @@ import autorch_sphinx_theme
...
@@ -33,6 +39,7 @@ import autorch_sphinx_theme
# Add any Sphinx extension module names here, as strings. They can be
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
# ones.
extensions
=
[
extensions
=
[
'sphinx.ext.autodoc'
,
'sphinx.ext.autodoc'
,
'sphinx.ext.autosummary'
,
'sphinx.ext.autosummary'
,
...
@@ -43,6 +50,7 @@ extensions = [
...
@@ -43,6 +50,7 @@ extensions = [
'sphinx.ext.mathjax'
,
'sphinx.ext.mathjax'
,
'sphinx.ext.napoleon'
,
'sphinx.ext.napoleon'
,
'sphinx.ext.viewcode'
,
'sphinx.ext.viewcode'
,
#'sphinx_gallery.gen_gallery',
# 'sphinxcontrib.googleanalytics',
# 'sphinxcontrib.googleanalytics',
]
]
...
@@ -88,7 +96,8 @@ language = None
...
@@ -88,7 +96,8 @@ language = None
# List of patterns, relative to source directory, that match files and
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns
=
[]
exclude_patterns
=
[
'_build'
,
'Thumbs.db'
,
'.DS_Store'
]
exclude_patterns
+=
[
'*/index.rst'
]
# The name of the Pygments (syntax highlighting) style to use.
# The name of the Pygments (syntax highlighting) style to use.
pygments_style
=
'sphinx'
pygments_style
=
'sphinx'
...
@@ -124,12 +133,9 @@ html_static_path = ['_static']
...
@@ -124,12 +133,9 @@ html_static_path = ['_static']
html_context
=
{
html_context
=
{
'css_files'
:
[
'css_files'
:
[
'https://fonts.googleapis.com/css?family=Lato'
,
'_static/theme_overrides.css'
,
# override wide tables in RTD theme
'_static/css/encoding.css'
],
],
}
}
#'_static/css/hangzh.css'
# -- Options for HTMLHelp output ------------------------------------------
# -- Options for HTMLHelp output ------------------------------------------
...
@@ -155,6 +161,11 @@ latex_elements = {
...
@@ -155,6 +161,11 @@ latex_elements = {
# Latex figure (float) alignment
# Latex figure (float) alignment
#
#
# 'figure_align': 'htbp',
# 'figure_align': 'htbp',
'preamble'
:
r
'''
\newcolumntype{\Yl}[1]{>{\raggedright\arraybackslash}\Y{#1}}
\newcolumntype{\Yr}[1]{>{\raggedleft\arraybackslash}\Y{#1}}
\newcolumntype{\Yc}[1]{>{\centering\arraybackslash}\Y{#1}}
'''
,
}
}
# Grouping the document tree into LaTeX files. List of tuples
# Grouping the document tree into LaTeX files. List of tuples
...
@@ -186,3 +197,9 @@ texinfo_documents = [
...
@@ -186,3 +197,9 @@ texinfo_documents = [
author
,
'Encoding'
,
'One line description of project.'
,
author
,
'Encoding'
,
'One line description of project.'
,
'Miscellaneous'
),
'Miscellaneous'
),
]
]
#def setup(app):
# # Custom directives
# app.add_directive('includenodoc', IncludeDirective)
# app.add_directive('galleryitem', GalleryItemDirective)
# app.add_directive('customgalleryitem', CustomGalleryItemDirective)
docs/source/custom_directives.py
0 → 100644
View file @
c4d27a8f
from
docutils.parsers.rst
import
Directive
,
directives
from
docutils.statemachine
import
StringList
from
docutils
import
nodes
import
re
import
os
import
sphinx_gallery
try
:
FileNotFoundError
except
NameError
:
FileNotFoundError
=
IOError
class
IncludeDirective
(
Directive
):
"""Include source file without docstring at the top of file.
Implementation just replaces the first docstring found in file
with '' once.
Example usage:
.. includenodoc:: /beginner/examples_tensor/two_layer_net_tensor.py
"""
# defines the parameter the directive expects
# directives.unchanged means you get the raw value from RST
required_arguments
=
1
optional_arguments
=
0
final_argument_whitespace
=
True
has_content
=
False
add_index
=
False
docstring_pattern
=
r
'"""(?P<docstring>(?:.|[\r\n])*?)"""\n'
docstring_regex
=
re
.
compile
(
docstring_pattern
)
def
run
(
self
):
document
=
self
.
state
.
document
env
=
document
.
settings
.
env
rel_filename
,
filename
=
env
.
relfn2path
(
self
.
arguments
[
0
])
try
:
text
=
open
(
filename
).
read
()
text_no_docstring
=
self
.
docstring_regex
.
sub
(
''
,
text
,
count
=
1
)
code_block
=
nodes
.
literal_block
(
text
=
text_no_docstring
)
return
[
code_block
]
except
FileNotFoundError
as
e
:
print
(
e
)
return
[]
class
GalleryItemDirective
(
Directive
):
"""
Create a sphinx gallery thumbnail for insertion anywhere in docs.
Optionally, you can specify the custom figure and intro/tooltip for the
thumbnail.
Example usage:
.. galleryitem:: intermediate/char_rnn_generation_tutorial.py
:figure: _static/img/char_rnn_generation.png
:intro: Put your custom intro here.
If figure is specified, a thumbnail will be made out of it and stored in
_static/thumbs. Therefore, consider _static/thumbs as a 'built' directory.
"""
required_arguments
=
1
optional_arguments
=
0
final_argument_whitespace
=
True
option_spec
=
{
'figure'
:
directives
.
unchanged
,
'intro'
:
directives
.
unchanged
}
has_content
=
False
add_index
=
False
def
run
(
self
):
args
=
self
.
arguments
fname
=
args
[
-
1
]
env
=
self
.
state
.
document
.
settings
.
env
fname
,
abs_fname
=
env
.
relfn2path
(
fname
)
basename
=
os
.
path
.
basename
(
fname
)
dirname
=
os
.
path
.
dirname
(
fname
)
try
:
if
'intro'
in
self
.
options
:
intro
=
self
.
options
[
'intro'
][:
195
]
+
'...'
else
:
_
,
blocks
=
sphinx_gallery
.
gen_rst
.
split_code_and_text_blocks
(
abs_fname
)
intro
,
_
=
sphinx_gallery
.
gen_rst
.
extract_intro_and_title
(
abs_fname
,
blocks
[
0
][
1
])
thumbnail_rst
=
sphinx_gallery
.
backreferences
.
_thumbnail_div
(
dirname
,
basename
,
intro
)
if
'figure'
in
self
.
options
:
rel_figname
,
figname
=
env
.
relfn2path
(
self
.
options
[
'figure'
])
save_figname
=
os
.
path
.
join
(
'_static/thumbs/'
,
os
.
path
.
basename
(
figname
))
try
:
os
.
makedirs
(
'_static/thumbs'
)
except
OSError
:
pass
sphinx_gallery
.
gen_rst
.
scale_image
(
figname
,
save_figname
,
400
,
280
)
# replace figure in rst with simple regex
thumbnail_rst
=
re
.
sub
(
r
'..\sfigure::\s.*\.png'
,
'.. figure:: /{}'
.
format
(
save_figname
),
thumbnail_rst
)
thumbnail
=
StringList
(
thumbnail_rst
.
split
(
'
\n
'
))
thumb
=
nodes
.
paragraph
()
self
.
state
.
nested_parse
(
thumbnail
,
self
.
content_offset
,
thumb
)
return
[
thumb
]
except
FileNotFoundError
as
e
:
print
(
e
)
return
[]
GALLERY_TEMPLATE
=
"""
.. raw:: html
<div class="sphx-glr-thumbcontainer" tooltip="{tooltip}">
.. only:: html
.. figure:: {thumbnail}
{description}
.. raw:: html
</div>
"""
class
CustomGalleryItemDirective
(
Directive
):
"""Create a sphinx gallery style thumbnail.
tooltip and figure are self explanatory. Description could be a link to
a document like in below example.
Example usage:
.. customgalleryitem::
:tooltip: I am writing this tutorial to focus specifically on NLP for people who have never written code in any deep learning framework
:figure: /_static/img/thumbnails/babel.jpg
:description: :doc:`/beginner/deep_learning_nlp_tutorial`
If figure is specified, a thumbnail will be made out of it and stored in
_static/thumbs. Therefore, consider _static/thumbs as a 'built' directory.
"""
required_arguments
=
0
optional_arguments
=
0
final_argument_whitespace
=
True
option_spec
=
{
'tooltip'
:
directives
.
unchanged
,
'figure'
:
directives
.
unchanged
,
'description'
:
directives
.
unchanged
}
has_content
=
False
add_index
=
False
def
run
(
self
):
try
:
if
'tooltip'
in
self
.
options
:
tooltip
=
self
.
options
[
'tooltip'
][:
195
]
+
'...'
else
:
raise
ValueError
(
'tooltip not found'
)
if
'figure'
in
self
.
options
:
env
=
self
.
state
.
document
.
settings
.
env
rel_figname
,
figname
=
env
.
relfn2path
(
self
.
options
[
'figure'
])
thumbnail
=
os
.
path
.
join
(
'_static/thumbs/'
,
os
.
path
.
basename
(
figname
))
try
:
os
.
makedirs
(
'_static/thumbs'
)
except
FileExistsError
:
pass
sphinx_gallery
.
gen_rst
.
scale_image
(
figname
,
thumbnail
,
400
,
280
)
else
:
thumbnail
=
'_static/img/thumbnails/default.png'
if
'description'
in
self
.
options
:
description
=
self
.
options
[
'description'
]
else
:
raise
ValueError
(
'description not doc found'
)
except
FileNotFoundError
as
e
:
print
(
e
)
return
[]
except
ValueError
as
e
:
print
(
e
)
raise
return
[]
thumbnail_rst
=
GALLERY_TEMPLATE
.
format
(
tooltip
=
tooltip
,
thumbnail
=
thumbnail
,
description
=
description
)
thumbnail
=
StringList
(
thumbnail_rst
.
split
(
'
\n
'
))
thumb
=
nodes
.
paragraph
()
self
.
state
.
nested_parse
(
thumbnail
,
self
.
content_offset
,
thumb
)
return
[
thumb
]
docs/source/experiments/segmentation.rst
View file @
c4d27a8f
...
@@ -10,8 +10,8 @@ Install Package
...
@@ -10,8 +10,8 @@ Install Package
-
Install
PyTorch
Encoding
(
if
not
yet
).
Please
follow
the
installation
guide
`
Installing
PyTorch
Encoding
<../
notes
/
compile
.
html
>`
_
.
-
Install
PyTorch
Encoding
(
if
not
yet
).
Please
follow
the
installation
guide
`
Installing
PyTorch
Encoding
<../
notes
/
compile
.
html
>`
_
.
Tes
t
Pre
-
trained
Model
Ge
t
Pre
-
trained
Model
---------------------
-
---------------------
..
hint
::
..
hint
::
The
model
names
contain
the
training
information
.
For
instance
``
FCN_ResNet50_PContext
``:
The
model
names
contain
the
training
information
.
For
instance
``
FCN_ResNet50_PContext
``:
...
@@ -23,34 +23,23 @@ Test Pre-trained Model
...
@@ -23,34 +23,23 @@ Test Pre-trained Model
model
=
encoding
.
models
.
get_model
(
'FCN_ResNet50_PContext'
,
pretrained
=
True
)
model
=
encoding
.
models
.
get_model
(
'FCN_ResNet50_PContext'
,
pretrained
=
True
)
Prepare
the
datasets
by
runing
the
scripts
in
the
``
scripts
/``
folder
,
for
example
preparing
``
PASCAL
Context
``
dataset
::
After
clicking
``
cmd
``
in
the
table
,
the
command
for
training
the
model
can
be
found
below
the
table
.
python
scripts
/
prepare_pcontext
.
py
The
test
script
is
in
the
``
experiments
/
segmentation
/``
folder
.
For
evaluating
the
model
(
using
MS
),
for
example
``
Encnet_ResNet50_PContext
``::
python
test
.
py
--
dataset
PContext
--
model
-
zoo
Encnet_ResNet50_PContext
--
eval
#
pixAcc
:
0.792
,
mIoU
:
0.510
:
100
%|
████████████████████████
|
1276
/
1276
[
46
:
31
<
00
:
00
,
2.19
s
/
it
]
The
command
for
training
the
model
can
be
found
by
clicking
``
cmd
``
in
the
table
.
..
role
::
raw
-
html
(
raw
)
..
role
::
raw
-
html
(
raw
)
:
format
:
html
:
format
:
html
+----------------------------------+-----------+-----------+----------------------------------------------------------------------------------------------+
|
Model
|
pixAcc
|
mIoU
|
Command
|
..
tabularcolumns
::
|>{\
centering
\
arraybackslash
}\
X
{
4
}{
5
}|>{\
raggedleft
\
arraybackslash
}\
X
{
1
}{
5
}|
+==================================+===========+===========+==============================================================================================+
|
Encnet_ResNet50_PContext
|
79.2
%
|
51.0
%
|
:
raw
-
html
:`<
a
href
=
"javascript:toggleblock('cmd_enc50_pcont')"
class
=
"toggleblock"
>
cmd
</
a
>`
|
==============================================================================
==============
==============
=============================================================================================
+----------------------------------+-----------+-----------+----------------------------------------------------------------------------------------------+
Model
pixAcc
mIoU
Command
|
EncNet_ResNet101_PContext
|
80.7
%
|
54.1
%
|
:
raw
-
html
:`<
a
href
=
"javascript:toggleblock('cmd_enc101_pcont')"
class
=
"toggleblock"
>
cmd
</
a
>`
|
==============================================================================
==============
==============
=============================================================================================
+----------------------------------+-----------+-----------+----------------------------------------------------------------------------------------------+
Encnet_ResNet50_PContext
79.2
%
51.0
%
:
raw
-
html
:`<
a
href
=
"javascript:toggleblock('cmd_enc50_pcont')"
class
=
"toggleblock"
>
cmd
</
a
>`
|
EncNet_ResNet50_ADE
|
80.1
%
|
41.5
%
|
:
raw
-
html
:`<
a
href
=
"javascript:toggleblock('cmd_enc50_ade')"
class
=
"toggleblock"
>
cmd
</
a
>`
|
EncNet_ResNet101_PContext
80.7
%
54.1
%
:
raw
-
html
:`<
a
href
=
"javascript:toggleblock('cmd_enc101_pcont')"
class
=
"toggleblock"
>
cmd
</
a
>`
+----------------------------------+-----------+-----------+----------------------------------------------------------------------------------------------+
EncNet_ResNet50_ADE
80.1
%
41.5
%
:
raw
-
html
:`<
a
href
=
"javascript:toggleblock('cmd_enc50_ade')"
class
=
"toggleblock"
>
cmd
</
a
>`
|
EncNet_ResNet101_ADE
|
81.3
%
|
44.4
%
|
:
raw
-
html
:`<
a
href
=
"javascript:toggleblock('cmd_enc101_ade')"
class
=
"toggleblock"
>
cmd
</
a
>`
|
EncNet_ResNet101_ADE
81.3
%
44.4
%
:
raw
-
html
:`<
a
href
=
"javascript:toggleblock('cmd_enc101_ade')"
class
=
"toggleblock"
>
cmd
</
a
>`
+----------------------------------+-----------+-----------+----------------------------------------------------------------------------------------------+
EncNet_ResNet101_VOC
N
/
A
85.9
%
:
raw
-
html
:`<
a
href
=
"javascript:toggleblock('cmd_enc101_voc')"
class
=
"toggleblock"
>
cmd
</
a
>`
|
EncNet_ResNet101_VOC
|
N
/
A
|
85.9
%
|
:
raw
-
html
:`<
a
href
=
"javascript:toggleblock('cmd_enc101_voc')"
class
=
"toggleblock"
>
cmd
</
a
>`
|
==============================================================================
==============
==============
=============================================================================================
+----------------------------------+-----------+-----------+----------------------------------------------------------------------------------------------+
..
raw
::
html
..
raw
::
html
...
@@ -88,6 +77,19 @@ Test Pre-trained Model
...
@@ -88,6 +77,19 @@ Test Pre-trained Model
CUDA_VISIBLE_DEVICES
=
0
,
1
,
2
,
3
python
train
.
py
--
dataset
Pascal_voc
--
model
encnet
--
aux
--
se
-
loss
--
backbone
resnet101
--
lr
0.0001
--
syncbn
--
ngpus
4
--
checkname
res101
--
resume
runs
/
Pascal_aug
/
encnet
/
res101
/
checkpoint
.
params
--
ft
CUDA_VISIBLE_DEVICES
=
0
,
1
,
2
,
3
python
train
.
py
--
dataset
Pascal_voc
--
model
encnet
--
aux
--
se
-
loss
--
backbone
resnet101
--
lr
0.0001
--
syncbn
--
ngpus
4
--
checkname
res101
--
resume
runs
/
Pascal_aug
/
encnet
/
res101
/
checkpoint
.
params
--
ft
</
code
>
</
code
>
Test
Pretrained
~~~~~~~~~~~~~~~
-
Prepare
the
datasets
by
runing
the
scripts
in
the
``
scripts
/``
folder
,
for
example
preparing
``
PASCAL
Context
``
dataset
::
python
scripts
/
prepare_pcontext
.
py
-
The
test
script
is
in
the
``
experiments
/
segmentation
/``
folder
.
For
evaluating
the
model
(
using
MS
),
for
example
``
Encnet_ResNet50_PContext
``::
python
test
.
py
--
dataset
PContext
--
model
-
zoo
Encnet_ResNet50_PContext
--
eval
#
pixAcc
:
0.792
,
mIoU
:
0.510
:
100
%|
████████████████████████
|
1276
/
1276
[
46
:
31
<
00
:
00
,
2.19
s
/
it
]
Quick
Demo
Quick
Demo
~~~~~~~~~~
~~~~~~~~~~
...
...
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