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

[DO NOT MERGE] Make object_detection pip installable #4889

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 20 additions & 0 deletions research/object_detection/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Create with `conda env create -f environment.yml`
name: object_detection

channels:
- conda-forge

dependencies:
- python=3.6
- python
- pillow
- matplotlib
- cython
- protobuf
- jupyter
- jupyterlab
- pip:
- pycocotools
- tensorflow-gpu
# or
# - tensorflow
111 changes: 10 additions & 101 deletions research/object_detection/g3doc/installation.md
Original file line number Diff line number Diff line change
@@ -1,112 +1,21 @@
# Installation

## Dependencies

Tensorflow Object Detection API depends on the following libraries:

* Protobuf 3.0.0
* Python-tk
* Pillow 1.0
* lxml
* tf Slim (which is included in the "tensorflow/models/research/" checkout)
* Jupyter notebook
* Matplotlib
* Tensorflow
* Cython
* contextlib2
* cocoapi

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:

``` bash
# For CPU
pip install tensorflow
# For GPU
pip install tensorflow-gpu
```

The remaining libraries can be installed on Ubuntu 16.04 using via apt-get:
It is recommended to use the [Anaconda Python distribution](https://www.anaconda.com/downloa) to install and use the `object_detection` API. Then you can setup a new Conda environment with all the necessary dependencies:

``` bash
sudo apt-get install protobuf-compiler python-pil python-lxml python-tk
pip install --user Cython
pip install --user contextlib2
pip install --user jupyter
pip install --user matplotlib
```
wget https://raw.githubusercontent.com/hadim/models/master/research/object_detection/environment.yml
conda env create -f environment.yml

Alternatively, users can install dependencies using pip:
source activate object_detection
pip install object_detection

``` bash
pip install --user Cython
pip install --user contextlib2
pip install --user pillow
pip install --user lxml
pip install --user jupyter
pip install --user matplotlib
```

Note that sometimes "sudo apt-get install protobuf-compiler" will install
Protobuf 3+ versions for you and some users have issues when using 3.5.
If that is your case, you're suggested to download and install Protobuf 3.0.0
(available [here](https://github.com/google/protobuf/releases/tag/v3.0.0)).

## COCO API installation

Download the
<a href="https://github.com/cocodataset/cocoapi" target=_blank>cocoapi</a> and
copy the pycocotools subfolder to the tensorflow/models/research directory if
you are interested in using COCO evaluation metrics. The default metrics are
based on those used in Pascal VOC evaluation. To use the COCO object detection
metrics add `metrics_set: "coco_detection_metrics"` to the `eval_config` message
in the config file. To use the COCO instance segmentation metrics add
`metrics_set: "coco_mask_metrics"` to the `eval_config` message in the config
file.

```bash
git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
make
cp -r pycocotools <path_to_tensorflow>/models/research/
# or to install from a local directory
# pip install -e .
```

## Protobuf Compilation

The Tensorflow Object Detection API uses Protobufs to configure model and
training parameters. Before the framework can be used, the Protobuf libraries
must be compiled. This should be done by running the following command from
the tensorflow/models/research/ directory:


``` bash
# From tensorflow/models/research/
protoc object_detection/protos/*.proto --python_out=.
```

## Add Libraries to PYTHONPATH

When running locally, the tensorflow/models/research/ and slim directories
should be appended to PYTHONPATH. This can be done by running the following from
tensorflow/models/research/:


``` bash
# From tensorflow/models/research/
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
```

Note: This command needs to run from every new terminal you start. If you wish
to avoid running this manually, you can add it as a new line to the end of your
~/.bashrc file, replacing \`pwd\` with the absolute path of
tensorflow/models/research on your system.

# Testing the Installation

You can test that you have correctly installed the Tensorflow Object Detection\
API by running the following command:
Check the installation is correct by running tests:

```bash
python object_detection/builders/model_builder_test.py
source activate object_detection
model_builder_test
```
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from object_detection.models import feature_map_generators
from object_detection.utils import context_manager
from object_detection.utils import ops
from nets import mobilenet_v1
from slim.nets import mobilenet_v1

slim = tf.contrib.slim

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import tensorflow as tf

from object_detection.meta_architectures import faster_rcnn_meta_arch
from nets import inception_resnet_v2
from slim.nets import inception_resnet_v2

slim = tf.contrib.slim

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import tensorflow as tf

from object_detection.meta_architectures import faster_rcnn_meta_arch
from nets import inception_v2
from slim.nets import inception_v2

slim = tf.contrib.slim

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from object_detection.meta_architectures import faster_rcnn_meta_arch
from object_detection.utils import shape_utils
from nets import mobilenet_v1
from slim.nets import mobilenet_v1

slim = tf.contrib.slim

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import tensorflow as tf

from object_detection.meta_architectures import faster_rcnn_meta_arch
from nets.nasnet import nasnet
from nets.nasnet import nasnet_utils
from slim.nets.nasnet import nasnet
from slim.nets.nasnet import nasnet_utils

arg_scope = tf.contrib.framework.arg_scope
slim = tf.contrib.slim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import tensorflow as tf

from object_detection.meta_architectures import faster_rcnn_meta_arch
from nets.nasnet import nasnet_utils
from nets.nasnet import pnasnet
from slim.nets.nasnet import nasnet_utils
from slim.nets.nasnet import pnasnet

arg_scope = tf.contrib.framework.arg_scope
slim = tf.contrib.slim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import tensorflow as tf

from object_detection.meta_architectures import faster_rcnn_meta_arch
from nets import resnet_utils
from nets import resnet_v1
from slim.nets import resnet_utils
from slim.nets import resnet_v1

slim = tf.contrib.slim

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from object_detection.models import feature_map_generators
from object_detection.utils import ops
from object_detection.utils import shape_utils
from nets import inception_v2
from slim.nets import inception_v2

slim = tf.contrib.slim

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from object_detection.models import feature_map_generators
from object_detection.utils import ops
from object_detection.utils import shape_utils
from nets import inception_v3
from slim.nets import inception_v3

slim = tf.contrib.slim

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from object_detection.utils import context_manager
from object_detection.utils import ops
from object_detection.utils import shape_utils
from nets import mobilenet_v1
from slim.nets import mobilenet_v1

slim = tf.contrib.slim

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from object_detection.utils import context_manager
from object_detection.utils import ops
from object_detection.utils import shape_utils
from nets import mobilenet_v1
from slim.nets import mobilenet_v1

slim = tf.contrib.slim

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from object_detection.utils import context_manager
from object_detection.utils import ops
from object_detection.utils import shape_utils
from nets import mobilenet_v1
from slim.nets import mobilenet_v1

slim = tf.contrib.slim

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
from object_detection.utils import context_manager
from object_detection.utils import ops
from object_detection.utils import shape_utils
from nets.mobilenet import mobilenet
from nets.mobilenet import mobilenet_v2
from slim.nets.mobilenet import mobilenet
from slim.nets.mobilenet import mobilenet_v2

slim = tf.contrib.slim

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from object_detection.utils import context_manager
from object_detection.utils import ops
from object_detection.utils import shape_utils
from nets import resnet_v1
from slim.nets import resnet_v1

slim = tf.contrib.slim

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from object_detection.utils import context_manager
from object_detection.utils import ops
from object_detection.utils import shape_utils
from nets import resnet_v1
from slim.nets import resnet_v1

slim = tf.contrib.slim

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading