Commit 4d71805b authored by Yuxin Wu's avatar Yuxin Wu

super() in transforms. update docs

parent 8da260de
...@@ -6,9 +6,9 @@ The backward compatibilty will be __preserved for at least several months__, wit ...@@ -6,9 +6,9 @@ The backward compatibilty will be __preserved for at least several months__, wit
so you don't need to look at here very often. so you don't need to look at here very often.
Here are a list of things that were changed, starting from an early version. Here are a list of things that were changed, starting from an early version.
TensorFlow itself also APIs changes and those are not listed here. TensorFlow itself also changes API and those are not listed here.
+ [2018/04/05] msgpack is replaced by pyarrow. If you want compatibility with old serialized data, + [2018/04/05] msgpack is replaced by pyarrow. If you want old behavior,
`export TENSORPACK_SERIALIZE=msgpack`. `export TENSORPACK_SERIALIZE=msgpack`.
+ [2018/03/20] `ModelDesc` starts to use simplified interfaces: + [2018/03/20] `ModelDesc` starts to use simplified interfaces:
+ `_get_inputs()` renamed to `inputs()` and returns `tf.placeholder`s. + `_get_inputs()` renamed to `inputs()` and returns `tf.placeholder`s.
......
...@@ -23,8 +23,8 @@ You can use this predicate to choose a different code path in inference mode. ...@@ -23,8 +23,8 @@ You can use this predicate to choose a different code path in inference mode.
Tensorpack is a training interface -- it doesn't care what happened after training. Tensorpack is a training interface -- it doesn't care what happened after training.
It saves models to standard checkpoint format. It saves models to standard checkpoint format.
You can build the graph for inference, load the checkpoint, and then use whatever deployment methods TensorFlow supports. So you can build the graph for inference, load the checkpoint, and then use whatever deployment methods TensorFlow supports.
But you'll need to read TF docs and do it on your own. But you'll need to read TF docs and __do it on your own__.
### Don't Use Training Metagraph for Inference ### Don't Use Training Metagraph for Inference
...@@ -50,6 +50,11 @@ with TowerContext('', is_training=False): ...@@ -50,6 +50,11 @@ with TowerContext('', is_training=False):
### OfflinePredictor ### OfflinePredictor
The only tool tensorpack has for after-training inference is [OfflinePredictor](../modules/predict.html#tensorpack.predict.OfflinePredictor), The only tool tensorpack has for after-training inference is [OfflinePredictor](../modules/predict.html#tensorpack.predict.OfflinePredictor),
a simple function to build the graph and return a callable for you. a simple function to build the graph and return a callable for you.
It is mainly for quick demo purposes.
It only runs inference on numpy arrays, therefore may not be the most efficient way.
Check out examples and docs for its usage. Check out examples and docs for its usage.
OfflinePredictor is only for quick demo purposes.
It runs inference on numpy arrays, therefore may not be the most efficient way.
It also has very limited functionalities.
If you need anything more complicated, please __do it on your own__ because Tensorpack
doesn't care what happened after training.
...@@ -38,6 +38,7 @@ class CustomResize(transform.TransformAugmentorBase): ...@@ -38,6 +38,7 @@ class CustomResize(transform.TransformAugmentorBase):
size (int): the size to resize the shortest edge to. size (int): the size to resize the shortest edge to.
max_size (int): maximum allowed longest edge. max_size (int): maximum allowed longest edge.
""" """
super(CustomResize, self).__init__()
self._init(locals()) self._init(locals())
def _get_augment_params(self, img): def _get_augment_params(self, img):
......
...@@ -23,29 +23,29 @@ These are all the toy examples in tensorpack. They are supposed to be just demos ...@@ -23,29 +23,29 @@ These are all the toy examples in tensorpack. They are supposed to be just demos
+ [A boilerplate file to start with, for your own tasks](boilerplate.py) + [A boilerplate file to start with, for your own tasks](boilerplate.py)
## Vision: ## Vision:
| Name | Performance | | Name | Performance |
| --- | --- | | --- | --- |
| Train [ResNet](ResNet), [ShuffleNet and other models](ImageNetModels) on ImageNet | reproduce paper | | Train [ResNet](ResNet), [ShuffleNet and other models](ImageNetModels) on ImageNet | reproduce paper |
| [Train Faster-RCNN / Mask-RCNN on COCO](FasterRCNN) | reproduce paper | | [Train Faster-RCNN / Mask-RCNN on COCO](FasterRCNN) | reproduce paper |
| [Generative Adversarial Network(GAN) variants](GAN), including DCGAN, InfoGAN, <br/> Conditional GAN, WGAN, BEGAN, DiscoGAN, Image to Image, CycleGAN | visually reproduce | | [Generative Adversarial Network(GAN) variants](GAN), including DCGAN, InfoGAN, <br/> Conditional GAN, WGAN, BEGAN, DiscoGAN, Image to Image, CycleGAN | visually reproduce |
| [DoReFa-Net: training binary / low-bitwidth CNN on ImageNet](DoReFa-Net) | reproduce paper | | [DoReFa-Net: training binary / low-bitwidth CNN on ImageNet](DoReFa-Net) | reproduce paper |
| [Fully-convolutional Network for Holistically-Nested Edge Detection(HED)](HED) | visually reproduce | | [Fully-convolutional Network for Holistically-Nested Edge Detection(HED)](HED) | visually reproduce |
| [Spatial Transformer Networks on MNIST addition](SpatialTransformer) | reproduce paper | | [Spatial Transformer Networks on MNIST addition](SpatialTransformer) | reproduce paper |
| [Visualize CNN saliency maps](Saliency) | visually reproduce | | [Visualize CNN saliency maps](Saliency) | visually reproduce |
| [Similarity learning on MNIST](SimilarityLearning) | | | [Similarity learning on MNIST](SimilarityLearning) | |
| Single-image super-resolution using [EnhanceNet](SuperResolution) | | | Single-image super-resolution using [EnhanceNet](SuperResolution) | |
| Learn steering filters with [Dynamic Filter Networks](DynamicFilterNetwork) | visually reproduce | | Learn steering filters with [Dynamic Filter Networks](DynamicFilterNetwork) | visually reproduce |
| Load a pre-trained [AlexNet, VGG, or Convolutional Pose Machines](CaffeModels) | | | Load a pre-trained [AlexNet, VGG, or Convolutional Pose Machines](CaffeModels) | |
## Reinforcement Learning: ## Reinforcement Learning:
| Name | Performance | | Name | Performance |
| --- | --- | | --- | --- |
| [Deep Q-Network(DQN) variants on Atari games](DeepQNetwork), including <br/> DQN, DoubleDQN, DuelingDQN. | reproduce paper | | [Deep Q-Network(DQN) variants on Atari games](DeepQNetwork), including <br/> DQN, DoubleDQN, DuelingDQN. | reproduce paper |
| [Asynchronous Advantage Actor-Critic(A3C) on Atari games](A3C-Gym) | reproduce paper | | [Asynchronous Advantage Actor-Critic(A3C) on Atari games](A3C-Gym) | reproduce paper |
## Speech / NLP: ## Speech / NLP:
| Name | Performance | | Name | Performance |
| --- | --- | | --- | --- |
| [LSTM-CTC for speech recognition](CTC-TIMIT) | reproduce paper | | [LSTM-CTC for speech recognition](CTC-TIMIT) | reproduce paper |
| [char-rnn for fun](Char-RNN) | fun | | [char-rnn for fun](Char-RNN) | fun |
| [LSTM language model on PennTreebank](PennTreebank) | reproduce reference code | | [LSTM language model on PennTreebank](PennTreebank) | reproduce reference code |
...@@ -56,6 +56,7 @@ class ImageTransform(object): ...@@ -56,6 +56,7 @@ class ImageTransform(object):
class ResizeTransform(ImageTransform): class ResizeTransform(ImageTransform):
def __init__(self, h, w, newh, neww, interp): def __init__(self, h, w, newh, neww, interp):
super(ResizeTransform, self).__init__()
self._init(locals()) self._init(locals())
def apply_image(self, img): def apply_image(self, img):
...@@ -75,6 +76,7 @@ class ResizeTransform(ImageTransform): ...@@ -75,6 +76,7 @@ class ResizeTransform(ImageTransform):
class CropTransform(ImageTransform): class CropTransform(ImageTransform):
def __init__(self, h0, w0, h, w): def __init__(self, h0, w0, h, w):
super(CropTransform, self).__init__()
self._init(locals()) self._init(locals())
def apply_image(self, img): def apply_image(self, img):
...@@ -89,6 +91,7 @@ class CropTransform(ImageTransform): ...@@ -89,6 +91,7 @@ class CropTransform(ImageTransform):
class WarpAffineTransform(ImageTransform): class WarpAffineTransform(ImageTransform):
def __init__(self, mat, dsize, interp=cv2.INTER_LINEAR, def __init__(self, mat, dsize, interp=cv2.INTER_LINEAR,
borderMode=cv2.BORDER_CONSTANT, borderValue=0): borderMode=cv2.BORDER_CONSTANT, borderValue=0):
super(WarpAffineTransform, self).__init__()
self._init(locals()) self._init(locals())
def apply_image(self, img): def apply_image(self, img):
......
...@@ -10,8 +10,9 @@ __all__ = ['loads', 'dumps'] ...@@ -10,8 +10,9 @@ __all__ = ['loads', 'dumps']
def dumps_msgpack(obj): def dumps_msgpack(obj):
""" """
Serialize an object. Serialize an object.
Returns: Returns:
Implementation-dependent bytes-like object Implementation-dependent bytes-like object.
""" """
return msgpack.dumps(obj, use_bin_type=True) return msgpack.dumps(obj, use_bin_type=True)
...@@ -29,7 +30,8 @@ def dumps_pyarrow(obj): ...@@ -29,7 +30,8 @@ def dumps_pyarrow(obj):
Serialize an object. Serialize an object.
Returns: Returns:
Implementation-dependent bytes-like object Implementation-dependent bytes-like object.
May not be compatible across different versions of pyarrow.
""" """
return pa.serialize(obj).to_buffer() return pa.serialize(obj).to_buffer()
......
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