__init__.py 1.8 KB
Newer Older
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
1
#!/usr/bin/env python
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
2
def scratch_network(inputs, end_point="fc1", reuse=False):
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
3 4 5 6 7 8 9

    import tensorflow as tf
    slim = tf.contrib.slim

    # Creating a random network
    initializer = tf.contrib.layers.xavier_initializer(seed=10)
    end_points = dict()
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
10 11 12 13

    graph = slim.conv2d(inputs, 10, [3, 3], activation_fn=tf.nn.relu, stride=1,
                        scope='conv1', weights_initializer=initializer,
                        reuse=reuse)
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
14
    end_points["conv1"] = graph
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
15

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
16 17
    graph = slim.max_pool2d(graph, [4, 4], scope='pool1')
    end_points["pool1"] = graph
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
18

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
19 20
    graph = slim.flatten(graph, scope='flatten1')
    end_points["flatten1"] = graph
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
21

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
22 23
    graph = slim.fully_connected(graph, 10, activation_fn=None, scope='fc1',
                                 weights_initializer=initializer, reuse=reuse)
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
24
    end_points["fc1"] = graph
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
25 26 27 28 29

    return end_points[end_point]


def get_config():
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
30 31 32 33 34 35 36 37
    """Returns a string containing the configuration information.
    """
    import bob.extension
    return bob.extension.get_config(__name__)


from .Extractor import Extractor
from .FaceNet import FaceNet
38
from .DrGanMSU import  DrGanMSUExtractor
39
from .Vgg16 import VGGFace, vgg_16
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
40 41 42 43


# gets sphinx autodoc done right - don't remove it
def __appropriate__(*args):
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
44 45 46 47 48
    """Says object was actually declared here, and not in the import module.
    Fixing sphinx warnings of not being able to find classes, when path is
    shortened. Parameters:

      *args: An iterable of objects to modify
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
49

Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
50 51 52
    Resolves `Sphinx referencing issues
    <https://github.com/sphinx-doc/sphinx/issues/3048>`
    """
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
53

Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
54 55
    for obj in args:
        obj.__module__ = __name__
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
56 57 58


__appropriate__(
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
59 60
    Extractor,
    FaceNet,
61
    DrGanMSUExtractor,
62
    VGGFace
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
63 64 65 66
)

# gets sphinx autodoc done right - don't remove it
__all__ = [_ for _ in dir() if not _.startswith('_')]