Commit 0cecfbb6 authored by Yuxin Wu's avatar Yuxin Wu

bump version; clean up deprecation

parent e8b1a84a
...@@ -10,7 +10,6 @@ from six.moves import range ...@@ -10,7 +10,6 @@ from six.moves import range
from tensorpack import * from tensorpack import *
from tensorpack.tfutils.gradproc import GlobalNormClip, SummaryGradient from tensorpack.tfutils.gradproc import GlobalNormClip, SummaryGradient
from tensorpack.utils import serialize
from timitdata import TIMITBatch from timitdata import TIMITBatch
......
...@@ -85,7 +85,7 @@ All models are trained with 8 NVIDIA V100s, unless otherwise noted. ...@@ -85,7 +85,7 @@ All models are trained with 8 NVIDIA V100s, unless otherwise noted.
Performance in [Detectron](https://github.com/facebookresearch/Detectron/) can Performance in [Detectron](https://github.com/facebookresearch/Detectron/) can
be approximately reproduced. be approximately reproduced.
| Backbone | mAP<br/>(box;mask) | Detectron mAP <sup>[1](#ft1)</sup><br/> (box;mask) | Time (on 8 V100s) | Configurations <br/> (click to expand) | | Backbone | mAP<br/>(box;mask) | Detectron mAP <sup>[1](#ft1)</sup><br/> (box;mask) | Time <br/>(on 8 V100s) | Configurations <br/> (click to expand) |
| - | - | - | - | - | | - | - | - | - | - |
| R50-C4 | 33.5 | | 17h | <details><summary>super quick</summary>`MODE_MASK=False FRCNN.BATCH_PER_IM=64`<br/>`PREPROC.TRAIN_SHORT_EDGE_SIZE=600 PREPROC.MAX_SIZE=1024`<br/>`TRAIN.LR_SCHEDULE=[150000,230000,280000]` </details> | | R50-C4 | 33.5 | | 17h | <details><summary>super quick</summary>`MODE_MASK=False FRCNN.BATCH_PER_IM=64`<br/>`PREPROC.TRAIN_SHORT_EDGE_SIZE=600 PREPROC.MAX_SIZE=1024`<br/>`TRAIN.LR_SCHEDULE=[150000,230000,280000]` </details> |
| R50-C4 | 36.6 | 36.5 | 44h | <details><summary>standard</summary>`MODE_MASK=False` </details> | | R50-C4 | 36.6 | 36.5 | 44h | <details><summary>standard</summary>`MODE_MASK=False` </details> |
...@@ -98,7 +98,7 @@ be approximately reproduced. ...@@ -98,7 +98,7 @@ be approximately reproduced.
| R101-C4 | 41.4;35.2 [:arrow_down:][R101C42x] | | 60h | <details><summary>standard</summary>`BACKBONE.RESNET_NUM_BLOCKS=[3,4,23,3]` </details> | | R101-C4 | 41.4;35.2 [:arrow_down:][R101C42x] | | 60h | <details><summary>standard</summary>`BACKBONE.RESNET_NUM_BLOCKS=[3,4,23,3]` </details> |
| R101-FPN | 40.4;36.6 [:arrow_down:][R101FPN2x] | 40.9;36.4 | 37h | <details><summary>standard</summary>`MODE_FPN=True`<br/>`BACKBONE.RESNET_NUM_BLOCKS=[3,4,23,3]` </details> | | R101-FPN | 40.4;36.6 [:arrow_down:][R101FPN2x] | 40.9;36.4 | 37h | <details><summary>standard</summary>`MODE_FPN=True`<br/>`BACKBONE.RESNET_NUM_BLOCKS=[3,4,23,3]` </details> |
| R101-FPN | 46.5;40.1 [:arrow_down:][R101FPN3xCasAug] <sup>[3](#ft3)</sup> | | 73h | <details><summary>3x+Cascade+TrainAug</summary>`MODE_FPN=True FPN.CASCADE=True`<br/>`BACKBONE.RESNET_NUM_BLOCKS=[3,4,23,3]`<br/>`TEST.RESULT_SCORE_THRESH=1e-4`<br/>`PREPROC.TRAIN_SHORT_EDGE_SIZE=[640,800]`<br/>`TRAIN.LR_SCHEDULE=[420000,500000,540000]` </details> | | R101-FPN | 46.5;40.1 [:arrow_down:][R101FPN3xCasAug] <sup>[3](#ft3)</sup> | | 73h | <details><summary>3x+Cascade+TrainAug</summary>`MODE_FPN=True FPN.CASCADE=True`<br/>`BACKBONE.RESNET_NUM_BLOCKS=[3,4,23,3]`<br/>`TEST.RESULT_SCORE_THRESH=1e-4`<br/>`PREPROC.TRAIN_SHORT_EDGE_SIZE=[640,800]`<br/>`TRAIN.LR_SCHEDULE=[420000,500000,540000]` </details> |
| R101-FPN<br/>(From Scratch) | 47.5;41.2 [:arrow_down:][R101FPN9xGNCasAugScratch] | 47.4;40.5<sup>[4](#ft4)</sup> | 45h (on 48 V100s) | <details><summary>9x+GN+Cascade+TrainAug</summary>`MODE_FPN=True FPN.CASCADE=True`<br/>`BACKBONE.RESNET_NUM_BLOCKS=[3,4,23,3]`<br/>`FPN.NORM=GN BACKBONE.NORM=GN`<br/>`FPN.FRCNN_HEAD_FUNC=fastrcnn_4conv1fc_gn_head`<br/>`FPN.MRCNN_HEAD_FUNC=maskrcnn_up4conv_gn_head`<br/>`PREPROC.TRAIN_SHORT_EDGE_SIZE=[640,800]`<br/>`TRAIN.LR_SCHEDULE=[1500000,1580000,1620000]`<br/>`BACKBONE.FREEZE_AT=0`</details> | | R101-FPN<br/>(From Scratch) | 47.5;41.2 [:arrow_down:][R101FPN9xGNCasAugScratch] | 47.4;40.5<sup>[4](#ft4)</sup> | 45h <br/>(on 48 V100s) | <details><summary>9x+GN+Cascade+TrainAug</summary>`MODE_FPN=True FPN.CASCADE=True`<br/>`BACKBONE.RESNET_NUM_BLOCKS=[3,4,23,3]`<br/>`FPN.NORM=GN BACKBONE.NORM=GN`<br/>`FPN.FRCNN_HEAD_FUNC=fastrcnn_4conv1fc_gn_head`<br/>`FPN.MRCNN_HEAD_FUNC=maskrcnn_up4conv_gn_head`<br/>`PREPROC.TRAIN_SHORT_EDGE_SIZE=[640,800]`<br/>`TRAIN.LR_SCHEDULE=[1500000,1580000,1620000]`<br/>`BACKBONE.FREEZE_AT=0`</details> |
[R50C42x]: http://models.tensorpack.com/FasterRCNN/COCO-R50C4-MaskRCNN-Standard.npz [R50C42x]: http://models.tensorpack.com/FasterRCNN/COCO-R50C4-MaskRCNN-Standard.npz
[R50FPN2x]: http://models.tensorpack.com/FasterRCNN/COCO-R50FPN-MaskRCNN-Standard.npz [R50FPN2x]: http://models.tensorpack.com/FasterRCNN/COCO-R50FPN-MaskRCNN-Standard.npz
...@@ -119,6 +119,7 @@ For example, our FPN models are sometimes slightly worse in box AP, which is ...@@ -119,6 +119,7 @@ For example, our FPN models are sometimes slightly worse in box AP, which is
<a id="ft4">4</a>: This entry does not use ImageNet pre-training. Detectron numbers are taken from Fig. 5 in [Rethinking ImageNet Pre-training](https://arxiv.org/abs/1811.08883). <a id="ft4">4</a>: This entry does not use ImageNet pre-training. Detectron numbers are taken from Fig. 5 in [Rethinking ImageNet Pre-training](https://arxiv.org/abs/1811.08883).
Note that our training strategy is slightly different: we enable cascade throughout the entire training. Note that our training strategy is slightly different: we enable cascade throughout the entire training.
As far as I know, this model is the __best open source model__ on COCO dataset.
## Notes ## Notes
......
[metadata]
author = TensorPack contributors
author-email = ppwwyyxxc@gmail.com
url = https://github.com/tensorpack/tensorpack
keywords = tensorflow, deep learning, neural network
license = Apache
[options]
zip_safe = False # dataset and __init__ use file
# will call find_packages()
packages = find:
[wheel]
universal = 1
import platform
from os import path from os import path
import setuptools import setuptools
from setuptools import setup from setuptools import setup, find_packages
version = int(setuptools.__version__.split('.')[0]) version = int(setuptools.__version__.split('.')[0])
assert version > 30, "Tensorpack installation requires setuptools > 30" assert version > 30, "Tensorpack installation requires setuptools > 30"
...@@ -38,10 +37,20 @@ add_git_version() ...@@ -38,10 +37,20 @@ add_git_version()
setup( setup(
name='tensorpack', name='tensorpack',
author="TensorPack contributors",
author_email="ppwwyyxxc@gmail.com",
url="https://github.com/tensorpack/tensorpack",
keywords="tensorflow, deep learning, neural network",
license="Apache",
version=__version__, # noqa version=__version__, # noqa
description='Neural Network Toolbox on TensorFlow', description='A Neural Network Training Interface on TensorFlow',
long_description=long_description, long_description=long_description,
long_description_content_type='text/markdown', long_description_content_type='text/markdown',
packages=find_packages(exclude=["examples", "tests"]),
zip_safe=False, # dataset and __init__ use file
install_requires=[ install_requires=[
"numpy>=1.14", "numpy>=1.14",
"six", "six",
...@@ -61,4 +70,7 @@ setup( ...@@ -61,4 +70,7 @@ setup(
'all: "linux" in sys_platform': ['python-prctl'], 'all: "linux" in sys_platform': ['python-prctl'],
'all: python_version < "3.0"': ['tornado'], 'all: python_version < "3.0"': ['tornado'],
}, },
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#universal-wheels
options={'bdist_wheel': {'universal': '1'}},
) )
...@@ -13,7 +13,6 @@ from six.moves import map, range ...@@ -13,7 +13,6 @@ from six.moves import map, range
from termcolor import colored from termcolor import colored
from ..utils import logger from ..utils import logger
from ..utils.develop import log_deprecated
from ..utils.utils import get_rng, get_tqdm, get_tqdm_kwargs from ..utils.utils import get_rng, get_tqdm, get_tqdm_kwargs
from .base import DataFlow, DataFlowReentrantGuard, ProxyDataFlow, RNGDataFlow from .base import DataFlow, DataFlowReentrantGuard, ProxyDataFlow, RNGDataFlow
...@@ -38,14 +37,10 @@ class TestDataSpeed(ProxyDataFlow): ...@@ -38,14 +37,10 @@ class TestDataSpeed(ProxyDataFlow):
def __iter__(self): def __iter__(self):
""" Will run testing at the beginning, then produce data normally. """ """ Will run testing at the beginning, then produce data normally. """
self.start_test() self.start()
for dp in self.ds: for dp in self.ds:
yield dp yield dp
def start_test(self):
log_deprecated("TestDataSpeed.start_test() was renamed to start()", "2019-03-30")
self.start()
def start(self): def start(self):
""" """
Start testing with a progress bar. Start testing with a progress bar.
......
...@@ -9,7 +9,7 @@ from six.moves import range ...@@ -9,7 +9,7 @@ from six.moves import range
from ..utils import logger from ..utils import logger
from ..utils.argtools import log_once from ..utils.argtools import log_once
from ..utils.compatible_serialize import loads from ..utils.serialize import loads
from ..utils.develop import create_dummy_class # noqa from ..utils.develop import create_dummy_class # noqa
from ..utils.loadcaffe import get_caffe_pb from ..utils.loadcaffe import get_caffe_pb
from ..utils.timer import timed_operation from ..utils.timer import timed_operation
......
...@@ -7,7 +7,7 @@ import platform ...@@ -7,7 +7,7 @@ import platform
from collections import defaultdict from collections import defaultdict
from ..utils import logger from ..utils import logger
from ..utils.compatible_serialize import dumps, loads from ..utils.serialize import dumps, loads
from ..utils.develop import create_dummy_class # noqa from ..utils.develop import create_dummy_class # noqa
from ..utils.utils import get_tqdm from ..utils.utils import get_tqdm
from .base import DataFlow from .base import DataFlow
...@@ -150,17 +150,10 @@ class TFRecordSerializer(): ...@@ -150,17 +150,10 @@ class TFRecordSerializer():
df (DataFlow): the DataFlow to serialize. df (DataFlow): the DataFlow to serialize.
path (str): output tfrecord file. path (str): output tfrecord file.
""" """
if os.environ.get('TENSORPACK_COMPATIBLE_SERIALIZE', 'msgpack') == 'msgpack':
def _dumps(dp):
return dumps(dp)
else:
def _dumps(dp):
return dumps(dp).to_pybytes()
size = _reset_df_and_get_size(df) size = _reset_df_and_get_size(df)
with tf.python_io.TFRecordWriter(path) as writer, get_tqdm(total=size) as pbar: with tf.python_io.TFRecordWriter(path) as writer, get_tqdm(total=size) as pbar:
for dp in df: for dp in df:
writer.write(_dumps(dp)) writer.write(dumps(dp))
pbar.update() pbar.update()
@staticmethod @staticmethod
......
...@@ -84,5 +84,5 @@ else: ...@@ -84,5 +84,5 @@ else:
# These lines will be programatically read/write by setup.py # These lines will be programatically read/write by setup.py
# Don't touch them. # Don't touch them.
__version__ = '0.9.4' __version__ = '0.9.5'
__git_version__ = __version__ __git_version__ = __version__
...@@ -53,7 +53,7 @@ def PReLU(x, init=0.001, name=None): ...@@ -53,7 +53,7 @@ def PReLU(x, init=0.001, name=None):
* ``alpha``: learnable slope. * ``alpha``: learnable slope.
""" """
if name is not None: if name is not None:
log_deprecated("PReLU(name=...) is deprecated! The output tensor will be named `output`.") log_deprecated("PReLU(name=...)", "The output tensor will be named `output`.")
init = tfv1.constant_initializer(init) init = tfv1.constant_initializer(init)
alpha = tfv1.get_variable('alpha', [], initializer=init) alpha = tfv1.get_variable('alpha', [], initializer=init)
x = ((1 + alpha) * x + (1 - alpha) * tf.abs(x)) x = ((1 + alpha) * x + (1 - alpha) * tf.abs(x))
...@@ -73,7 +73,7 @@ def BNReLU(x, name=None): ...@@ -73,7 +73,7 @@ def BNReLU(x, name=None):
name: deprecated, don't use. name: deprecated, don't use.
""" """
if name is not None: if name is not None:
log_deprecated("BNReLU(name=...) is deprecated! The output tensor will be named `output`.") log_deprecated("BNReLU(name=...)", "The output tensor will be named `output`.")
x = BatchNorm('bn', x) x = BatchNorm('bn', x)
x = tf.nn.relu(x, name=name) x = tf.nn.relu(x, name=name)
......
...@@ -5,7 +5,6 @@ import numpy as np ...@@ -5,7 +5,6 @@ import numpy as np
from ..compat import tfv1 as tf # this should be avoided first in model code from ..compat import tfv1 as tf # this should be avoided first in model code
from ..utils.argtools import get_data_format, shape2d from ..utils.argtools import get_data_format, shape2d
from ..utils.develop import log_deprecated
from ._test import TestModel from ._test import TestModel
from .common import layer_register from .common import layer_register
from .shape_utils import StaticDynamicShape from .shape_utils import StaticDynamicShape
...@@ -140,61 +139,6 @@ def FixedUnPooling(x, shape, unpool_mat=None, data_format='channels_last'): ...@@ -140,61 +139,6 @@ def FixedUnPooling(x, shape, unpool_mat=None, data_format='channels_last'):
return ret return ret
# Removed (not importable) already; leave it here just for testing purposes.
def BilinearUpSample(x, shape):
"""
Deterministic bilinearly-upsample the input images.
It is implemented by deconvolution with "BilinearFiller" in Caffe.
It is aimed to mimic caffe behavior.
Args:
x (tf.Tensor): a NHWC tensor
shape (int): the upsample factor
Returns:
tf.Tensor: a NHWC tensor.
"""
log_deprecated("BilinearUpsample", "Please implement it in your own code instead!", "2019-03-01")
inp_shape = x.shape.as_list()
ch = inp_shape[3]
assert ch is not None and ch == 1
shape = int(shape)
filter_shape = 2 * shape
def bilinear_conv_filler(s):
"""
s: width, height of the conv filter
https://github.com/BVLC/caffe/blob/99bd99795dcdf0b1d3086a8d67ab1782a8a08383/include/caffe/filler.hpp#L219-L268
"""
f = np.ceil(float(s) / 2)
c = float(2 * f - 1 - f % 2) / (2 * f)
ret = np.zeros((s, s), dtype='float32')
for x in range(s):
for y in range(s):
ret[x, y] = (1 - abs(x / f - c)) * (1 - abs(y / f - c))
return ret
w = bilinear_conv_filler(filter_shape)
w = np.repeat(w, ch * ch).reshape((filter_shape, filter_shape, ch, ch))
weight_var = tf.constant(w, tf.float32,
shape=(filter_shape, filter_shape, ch, ch),
name='bilinear_upsample_filter')
x = tf.pad(x, [[0, 0], [shape - 1, shape - 1], [shape - 1, shape - 1], [0, 0]], mode='SYMMETRIC')
out_shape = tf.shape(x) * tf.constant([1, shape, shape, 1], tf.int32)
deconv = tf.nn.conv2d_transpose(x, weight_var, out_shape,
[1, shape, shape, 1], 'SAME')
edge = shape * (shape - 1)
deconv = deconv[:, edge:-edge, edge:-edge, :]
if inp_shape[1]:
inp_shape[1] *= shape
if inp_shape[2]:
inp_shape[2] *= shape
deconv.set_shape(inp_shape)
return deconv
class TestPool(TestModel): class TestPool(TestModel):
def test_FixedUnPooling(self): def test_FixedUnPooling(self):
h, w = 3, 4 h, w = 3, 4
...@@ -213,23 +157,24 @@ class TestPool(TestModel): ...@@ -213,23 +157,24 @@ class TestPool(TestModel):
res[0, ::scale, ::scale, :] = 0 res[0, ::scale, ::scale, :] = 0
self.assertTrue((res == 0).all()) self.assertTrue((res == 0).all())
def test_BilinearUpSample(self): # Below was originally for the BilinearUpsample layer used in the HED example
h, w = 12, 12 # def test_BilinearUpSample(self):
scale = 2 # h, w = 12, 12
# scale = 2
mat = np.random.rand(h, w).astype('float32') #
inp = self.make_variable(mat) # mat = np.random.rand(h, w).astype('float32')
inp = tf.reshape(inp, [1, h, w, 1]) # inp = self.make_variable(mat)
# inp = tf.reshape(inp, [1, h, w, 1])
output = BilinearUpSample(inp, scale) #
res = self.run_variable(output)[0, :, :, 0] # output = BilinearUpSample(inp, scale)
# res = self.run_variable(output)[0, :, :, 0]
from skimage.transform import rescale #
res2 = rescale(mat, scale, mode='edge') # from skimage.transform import rescale
# res2 = rescale(mat, scale, mode='edge')
diff = np.abs(res2 - res) #
# diff = np.abs(res2 - res)
# if not diff.max() < 1e-4: #
# import IPython # # if not diff.max() < 1e-4:
# IPython.embed(config=IPython.terminal.ipapp.load_default_config()) # # import IPython
self.assertTrue(diff.max() < 1e-4, diff.max()) # # IPython.embed(config=IPython.terminal.ipapp.load_default_config())
# self.assertTrue(diff.max() < 1e-4, diff.max())
...@@ -39,7 +39,7 @@ def rms(x, name=None): ...@@ -39,7 +39,7 @@ def rms(x, name=None):
# don't hurt to leave it here # don't hurt to leave it here
@deprecated("Please implement it by yourself.", "2018-04-28") @deprecated("Please implement it by yourself.", "2018-04-28")
def psnr(prediction, ground_truth, maxp=None, name='psnr'): def psnr(prediction, ground_truth, maxp=None, name='psnr'):
"""`Peek Signal to Noise Ratio <https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio>`_. """`Peak Signal to Noise Ratio <https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio>`_.
.. math:: .. math::
......
import os from .serialize import loads, dumps # noqa
from .serialize import dumps_msgpack, dumps_pyarrow, loads_msgpack, loads_pyarrow # keep this file for BC
"""
Serialization that has compatibility guarantee (therefore is safe to store to disk).
"""
__all__ = ['loads', 'dumps']
# pyarrow has no compatibility guarantee
# use msgpack for persistent serialization, unless explicitly set from envvar
if os.environ.get('TENSORPACK_COMPATIBLE_SERIALIZE', 'msgpack') == 'msgpack':
loads = loads_msgpack
dumps = dumps_msgpack
else:
loads = loads_pyarrow
dumps = dumps_pyarrow
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment