guide.rst 1.8 KB
Newer Older
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
===========
 User guide
===========

Using as a feature extractor
----------------------------

In this example we'll take pretrained network using MNIST and 

In this example we take the output of the layer `fc7` of the VGG face model as
features.

.. doctest:: tensorflowtest

   >>> import numpy
   >>> import bob.ip.tensorflow_extractor
   >>> import bob.db.mnist
   >>> from bob.ip.tensorflow_extractor import scratch_network
   >>> import os
   >>> import pkg_resources
   >>> import tensorflow as tf

   >>> # Loading some samples from mnist
   >>> db = bob.db.mnist.Database()
   >>> images = db.data(groups='train', labels=[0,1,2,3,4,5,6,7,8,9])[0][0:3]
   >>> images = numpy.reshape(images, (3, 28, 28, 1)) * 0.00390625 # Normalizing the data

   >>> # preparing my inputs
   >>> inputs = tf.placeholder(tf.float32, shape=(None, 28, 28, 1))
   >>> graph = scratch_network(inputs)

   >>> # loading my model and projecting
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
33
   >>> filename = os.path.join(pkg_resources.resource_filename("bob.ip.tensorflow_extractor", 'data'), 'model.ckp')
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
   >>> extractor = bob.ip.tensorflow_extractor.Extractor(filename, inputs, graph)
   >>> extractor(images).shape
   (3, 10)


.. note::

   The models will automatically download to the data folder of this package as
   soon as you start using them.

Using as a convolutional filter
-------------------------------

In this example we plot some outputs of the convolutional layer `conv1`.

49

50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
   
Facenet Model
-------------


:ref:`bob.bio.base <bob.bio.base>` wrapper Facenet model.
Check `here for more info <py_api.html#bob.ip.tensorflow_extractor.FaceNet>`_



DRGan from L.Tran @ MSU:
------------------------

:ref:`bob.bio.base <bob.bio.base>` wrapper to the DRGan model trained by L.Tran @ MSU.
Check `here <py_api.html#bob.ip.tensorflow_extractor.DrGanMSUExtractor>`_ for more info