Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formalizing Featurizer interfaces #238

Merged
merged 36 commits into from Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4a06010
adding ImageFeaturizer, VideoFramesFeaturizer, and VideoFeaturizer in…
brimoor May 31, 2019
a2d2dfa
supporting type validation for FeaturizerConfigs
brimoor May 31, 2019
3dcaa4b
linting Featurizer definition
brimoor May 31, 2019
283b049
updating todos
brimoor May 31, 2019
89bc6e3
documenting return types
brimoor May 31, 2019
5fbd210
adding types for new Featurizer interfaces
brimoor May 31, 2019
2c0d8a3
updating C3DFeaturizer to use new Featurizer interfaces
brimoor May 31, 2019
9bf5b14
updating VGG16Featurizer to use new Featurizer interfaces
brimoor May 31, 2019
0455d7f
Merge branch 'develop' into featurizer-tlc
brimoor Jun 1, 2019
3d8025f
converting VideoFramesFeaturizer to a CachingVideoFeaturizer class
brimoor Jun 3, 2019
38bfa31
updating type entry for CachingVideoFeaturizer
brimoor Jun 3, 2019
ad3c792
putting the simpler ManualBackingManager first
brimoor Jun 3, 2019
6925e88
Merge branch 'install-tweaks' into featurizer-tlc
brimoor Jun 3, 2019
495c987
adding other interfaces that RandFeaturizer implements
brimoor Jun 4, 2019
bac8d2a
adding logging messages to CachingVideoFeaturizer
brimoor Jun 4, 2019
bed90e6
fixing non-existent base directory bug
brimoor Jun 4, 2019
15e867d
fixing IOError vs OSError bug
brimoor Jun 4, 2019
b91b652
removing unnecessary featurizer type
brimoor Jun 4, 2019
b80dc17
supporting tuples in addition to lists
brimoor Jun 4, 2019
e402fa7
using more apt backing_dir for parameter name
brimoor Jun 4, 2019
881d7d4
updating embed_vgg16 module to use best practices
brimoor Jun 4, 2019
fa7e743
regenerating module metadata file
brimoor Jun 4, 2019
b6b2757
updating embedding examples to use new CachingVideoFeaturizer class
brimoor Jun 4, 2019
d390c89
replacing VideoFramesFeaturizer with CachingVideoFeaturizer
brimoor Jun 4, 2019
8ecd1f6
updating embed_vgg16 module config to use new output name
brimoor Jun 4, 2019
653f00d
linting
brimoor Jun 4, 2019
e996feb
Merge branch 'develop' into featurizer-tlc
brimoor Jun 4, 2019
944c9f0
implementing interator interface for CachingVideoFeaturizer
brimoor Jun 6, 2019
463bcae
supporting inclusion of absolute paths when listing files
brimoor Jun 6, 2019
de95fcf
adding support for manually setting the backing directory
brimoor Jun 10, 2019
86bbfd3
fixing typo
brimoor Jun 10, 2019
35b372d
supporting optional specification of the frames to featurize in the c…
brimoor Jun 10, 2019
97ef5e9
adding a method to convert VideoFrameLabels to ImageLabels
brimoor Jun 11, 2019
cc28b33
fixing docstring typos
brimoor Jun 12, 2019
66dd783
fixing pickle vs npz bug in docstring
brimoor Jun 12, 2019
a14ea7f
adding filter to only match .npz files
brimoor Jun 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/python_style_guide.md
Expand Up @@ -69,8 +69,8 @@ import eta.core.video as etav
Long imports should be implemented with hanging indentation:

```python
from eta.core.features import VideoFramesFeaturizer, \
VideoFramesFeaturizerConfig
from eta.core.features import CachingVideoFeaturizer, \
CachingVideoFeaturizerConfig
```

- Names should follow the conventions
Expand Down
31 changes: 21 additions & 10 deletions eta/core/c3d.py
Expand Up @@ -11,8 +11,8 @@
Copyright 2017-2019, Voxel51, Inc.
voxel51.com

Yixin Jin, yixin@voxel51.com
Brian Moore, brian@voxel51.com
Yixin Jin, yixin@voxel51.com
'''
# pragma pylint: disable=redefined-builtin
# pragma pylint: disable=unused-wildcard-import
Expand All @@ -30,16 +30,21 @@
import tensorflow as tf

from eta.core.config import Config
from eta.core.features import Featurizer
from eta.core.features import VideoFramesFeaturizer, VideoFeaturizer
import eta.core.tfutils as etat
import eta.core.video as etav


class C3DConfig(Config):
'''Configuration settings for the C3D network.'''
'''Configuration settings for the C3D network.

Attributes:
model_name: the name of the C3D UCF101 model to load
'''

def __init__(self, d):
self.model = self.parse_string(d, "model", default="c3d-ucf101")
self.model_name = self.parse_string(
d, "model_name", default="c3d-ucf101")


class C3D(object):
Expand All @@ -51,7 +56,7 @@ class C3D(object):
'''

def __init__(self, config=None, sess=None, clips=None):
'''Builds a new C3D network
'''Creates a C3D instance.

Args:
config: an optional C3DConfig instance. If omitted, the default
Expand All @@ -74,7 +79,7 @@ def __init__(self, config=None, sess=None, clips=None):
self._build_fc_layers()
self._build_output_layer()

self._load_model(self.config.model)
self._load_model(self.config.model_name)

def __enter__(self):
return self
Expand Down Expand Up @@ -210,10 +215,10 @@ def _build_fc_layers(self):
def _build_output_layer(self):
self.probs = tf.nn.softmax(self.fc3l)

def _load_model(self, model):
def _load_model(self, model_name):
init = tf.global_variables_initializer()
self.sess.run(init)
etat.TFModelCheckpoint(model, self.sess).load()
etat.TFModelCheckpoint(model_name, self.sess).load()


def _tf_variable_with_weight_decay(name, shape, stddev, decay):
Expand Down Expand Up @@ -242,7 +247,7 @@ class C3DFeaturizerConfig(C3DConfig):
'''Configuration settings for a C3DFeaturizer.

Attributes:
model: the C3D UCF101 model to use
model_name: the name of the C3D UCF101 model to load
sample_method: the frame sampling method to use. The possible values
are "first", "uniform", and "sliding_window"
stride: the stride to use. When the sampling method is
Expand All @@ -258,10 +263,16 @@ def __init__(self, d):
self.stride = self.parse_number(d, "stride", default=8)


class C3DFeaturizer(Featurizer):
class C3DFeaturizer(VideoFramesFeaturizer, VideoFeaturizer):
'''Featurizer that embeds videos into the C3D feature space.'''

def __init__(self, config=None):
'''Creates a C3DFeaturizer instance.

Args:
config: an optional C3DFeaturizerConfig instance. If omitted, the
default C3DFeaturizerConfig is used
'''
super(C3DFeaturizer, self).__init__()
self.config = config or C3DFeaturizerConfig.default()
self.validate(self.config)
Expand Down