INSTALL_INSTRUCTIONS.md 5.26 KB
Newer Older
Andre Araujo's avatar
Andre Araujo committed
1
2
## DELF installation

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
33
34
35
36
37
### Installation script

We now have a script to do the entire installation in one shot. Navigate to the
directory `models/research/delf/delf/python/training`, then run:

```bash
# From models/research/delf/delf/python/training
bash install_delf.sh
```

If this works, you are done! If not, see below for detailed instructions for
installing this codebase and its dependencies.

*Please note that this installation script only works on 64 bits Linux
architectures due to the `protoc` binary that is automatically downloaded. If
you wish to install the DELF library on other architectures please update the
[`install_delf.sh`](delf/python/training/install_delf.sh) script by referencing
the desired `protoc`
[binary release](https://github.com/protocolbuffers/protobuf/releases).*

In more detail: the `install_delf.sh` script installs both the DELF library and
its dependencies in the following sequence:

*   Install TensorFlow 2.2 and TensorFlow 2.2 for GPU.
*   Install the [TF-Slim](https://github.com/google-research/tf-slim) library
    from source.
*   Download [protoc](https://github.com/protocolbuffers/protobuf) and compile
    the DELF Protocol Buffers.
*   Install the matplotlib, numpy, scikit-image, scipy and python3-tk Python
    libraries.
*   Install the
    [TensorFlow Object Detection API](https://github.com/tensorflow/models/tree/master/research/object_detection)
    from the cloned TensorFlow Model Garden repository.
*   Install the DELF package.

Andre Araujo's avatar
Andre Araujo committed
38
39
### Tensorflow

40
[![TensorFlow 2.2](https://img.shields.io/badge/tensorflow-2.2-brightgreen)](https://github.com/tensorflow/tensorflow/releases/tag/v2.2.0)
41
[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)
42

43
44
45
For detailed steps to install Tensorflow, follow the
[Tensorflow installation instructions](https://www.tensorflow.org/install/). A
typical user can install Tensorflow using one of the following commands:
Andre Araujo's avatar
Andre Araujo committed
46
47
48

```bash
# For CPU:
49
pip3 install 'tensorflow>=2.2.0'
Andre Araujo's avatar
Andre Araujo committed
50
# For GPU:
51
pip3 install 'tensorflow-gpu>=2.2.0'
Andre Araujo's avatar
Andre Araujo committed
52
53
```

54
55
56
57
58
59
60
61
### TF-Slim

Note: currently, we need to install the latest version from source, to avoid
using previous versions which relied on tf.contrib (which is now deprecated).

```bash
git clone git@github.com:google-research/tf-slim.git
cd tf-slim
62
pip3 install .
63
64
65
66
67
68
69
70
```

Note that these commands assume you are cloning using SSH. If you are using
HTTPS instead, use `git clone https://github.com/google-research/tf-slim.git`
instead. See
[this link](https://help.github.com/en/github/using-git/which-remote-url-should-i-use)
for more information.

Andre Araujo's avatar
Andre Araujo committed
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
### Protobuf

The DELF library uses [protobuf](https://github.com/google/protobuf) (the python
version) to configure feature extraction and its format. You will need the
`protoc` compiler, version >= 3.3. The easiest way to get it is to download
directly. For Linux, this can be done as (see
[here](https://github.com/google/protobuf/releases) for other platforms):

```bash
wget https://github.com/google/protobuf/releases/download/v3.3.0/protoc-3.3.0-linux-x86_64.zip
unzip protoc-3.3.0-linux-x86_64.zip
PATH_TO_PROTOC=`pwd`
```

### Python dependencies

Install python library dependencies:

```bash
90
91
pip3 install matplotlib numpy scikit-image scipy
sudo apt-get install python3-tk
Andre Araujo's avatar
Andre Araujo committed
92
93
94
95
96
97
98
99
100
101
```

### `tensorflow/models`

Now, clone `tensorflow/models`, and install required libraries: (note that the
`object_detection` library requires you to add `tensorflow/models/research/` to
your `PYTHONPATH`, as instructed
[here](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md))

```bash
102
git clone git@github.com:tensorflow/models.git
Andre Araujo's avatar
Andre Araujo committed
103

104
# Setup the object_detection module by editing PYTHONPATH.
Andre Araujo's avatar
Andre Araujo committed
105
106
107
108
109
cd ..
# From tensorflow/models/research/
export PYTHONPATH=$PYTHONPATH:`pwd`
```

110
111
112
113
114
115
Note that these commands assume you are cloning using SSH. If you are using
HTTPS instead, use `git clone https://github.com/tensorflow/models.git` instead.
See
[this link](https://help.github.com/en/github/using-git/which-remote-url-should-i-use)
for more information.

Andre Araujo's avatar
Andre Araujo committed
116
117
118
119
120
121
122
123
Then, compile DELF's protobufs. Use `PATH_TO_PROTOC` as the directory where you
downloaded the `protoc` compiler.

```bash
# From tensorflow/models/research/delf/
${PATH_TO_PROTOC?}/bin/protoc delf/protos/*.proto --python_out=.
```

124
125
Finally, install the DELF package. This may also install some other dependencies
under the hood.
Andre Araujo's avatar
Andre Araujo committed
126
127
128

```bash
# From tensorflow/models/research/delf/
129
pip3 install -e . # Install "delf" package.
Andre Araujo's avatar
Andre Araujo committed
130
131
132
133
134
```

At this point, running

```bash
135
python3 -c 'import delf'
Andre Araujo's avatar
Andre Araujo committed
136
137
138
139
```

should just return without complaints. This indicates that the DELF package is
loaded successfully.
140
141
142

### Troubleshooting

143
#### `pip3 install`
144

145
Issues might be observed if using `pip3 install` with `-e` option (editable
146
mode). You may try out to simply remove the `-e` from the commands above. Also,
147
depending on your machine setup, you might need to run the `sudo pip3 install`
148
149
150
151
152
153
154
155
156
157
command, that is with a `sudo` at the beginning.

#### Cloning github repositories

The default commands above assume you are cloning using SSH. If you are using
HTTPS instead, use for example `git clone
https://github.com/tensorflow/models.git` instead of `git clone
git@github.com:tensorflow/models.git`. See
[this link](https://help.github.com/en/github/using-git/which-remote-url-should-i-use)
for more information.