Skip to content

Commit 1c940c4

Browse files
committed
Minor fixes and updates
1 parent 6e4e15b commit 1c940c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2950
-1122
lines changed

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.pythonPath": "C:\\Users\\sglvladi\\Anaconda3\\envs\\sphinx\\python.exe"
3+
}

docs/build/doctrees/camera.doctree

30 Bytes
Binary file not shown.
416 Bytes
Binary file not shown.

docs/build/doctrees/index.doctree

30 Bytes
Binary file not shown.

docs/build/doctrees/install.doctree

3.95 KB
Binary file not shown.

docs/build/doctrees/issues.doctree

30 Bytes
Binary file not shown.

docs/build/doctrees/training.doctree

1.25 KB
Binary file not shown.

docs/build/html/_sources/install.rst.txt

+26-11
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ Once you have activated your virtual environment, the name of the environment sh
5757
5858
Install TensorFlow CPU for Python
5959
*********************************
60-
- Open a new `Anaconda/Command Prompt` window and activate the `tensorflow_gpu` environment (if you have not done so already)
60+
- Open a new `Anaconda/Command Prompt` window and activate the `tensorflow_cpu` environment (if you have not done so already)
6161
- Once open, type the following on the command line:
6262

6363
.. code-block:: posh
6464
65-
pip install --ignore-installed --upgrade tensorflow
65+
pip install --ignore-installed --upgrade tensorflow==1.7.0
6666
6767
- Wait for the installation to finish
6868

@@ -81,7 +81,7 @@ Test your Installation
8181
8282
>>> import tensorflow as tf
8383
84-
- If the above code shows an error, then check to make sure you have activated the `tensorflow_gpu` environment and that tensorflow_gpu was successfully installed within it in the previous step.
84+
- If the above code shows an error, then check to make sure you have activated the `tensorflow_cpu` environment and that tensorflow_cpu was successfully installed within it in the previous step.
8585
- Then run the following:
8686

8787
.. code-block:: python
@@ -123,6 +123,8 @@ Before proceeding to install TesnsorFlow GPU, you need to make sure that your sy
123123
| Anaconda with Python 3.6 (Optional) |
124124
+-------------------------------------+
125125

126+
.. _cuda_install:
127+
126128
Install CUDA Toolkit
127129
***********************
128130
Follow this `link <https://developer.nvidia.com/cuda-90-download-archive?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exenetwork>`_ to download and install CUDA Toolkit v9.0.
@@ -145,15 +147,17 @@ Set Your Environment Variables
145147
- Go to `Start` and Search "environment variables"
146148
- Click the Environment Variables button
147149
- Click on the ``Path`` system variable and select edit
148-
- Add the following paths
150+
- Add the following paths:
149151

150152
- ``<INSTALL_PATH>\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin``
151153
- ``<INSTALL_PATH>\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp``
152154
- ``<INSTALL_PATH>\NVIDIA GPU Computing Toolkit\CUDA\v9.0\extras\CUPTI\libx64``
153155
- ``<INSTALL_PATH>\NVIDIA GPU Computing Toolkit\CUDA\v9.0\cuda\bin``
154156

155-
Update your GPU drivers
156-
***********************
157+
Update your GPU drivers (Optional)
158+
**********************************
159+
If during the installation of the CUDA Toolkit (see :ref:`cuda_install`) you selected the `Express Installation` option, then your GPU drivers will have been overwritten by those that come bundled with the CUDA toolkit. These drivers are typically NOT the latest drivers and, thus, you may wish to updte your drivers.
160+
157161
- Go to `<http://www.nvidia.com/Download/index.aspx>`_
158162
- Select your GPU version to download
159163
- Install the driver
@@ -187,7 +191,7 @@ Install TensorFlow GPU for Python
187191

188192
.. code-block:: posh
189193
190-
pip install --ignore-installed --upgrade tensorflow-gpu
194+
pip install --ignore-installed --upgrade tensorflow-gpu==1.7.0
191195
192196
- Wait for the installation to finish
193197

@@ -236,7 +240,7 @@ Test your Installation
236240
TensorFlow Models Installation
237241
------------------------------
238242

239-
Now that you have installed TensorFlow, it is time to install the models used b TesnorFlow to do it's magic.
243+
Now that you have installed TensorFlow, it is time to install the models used by TensorFlow to do its magic.
240244

241245
Install Prerequisites
242246
~~~~~~~~~~~~~~~~~~~~~
@@ -254,7 +258,7 @@ Building on the assumption that you have just created your new virtual environme
254258
+--------------+------------------------------+
255259
| jupyter | 1.0.0-py36_4 |
256260
+--------------+------------------------------+
257-
| matlplotlib | 2.2.2-py36h153e9ff_0 |
261+
| matplotlib | 2.2.2-py36h153e9ff_0 |
258262
+--------------+------------------------------+
259263
| opencv | 3.3.1-py36h20b85fd_1 |
260264
+--------------+------------------------------+
@@ -273,6 +277,7 @@ Alternatively, if you don't want to use Anaconda you can install the packages us
273277
274278
pip install <package_name>(=<version>)
275279
280+
but you will need to install ``opencv-python`` instead of ``opencv``.
276281

277282
Downloading the TensorFlow Models
278283
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -349,6 +354,13 @@ This should be done as follows:
349354
# From TensorFlow/models/research/
350355
protoc object_detection/protos/*.proto --python_out=.
351356
357+
If you are on Windows and using version 3.5 or later, the wildcard will not work and you have to run this in the command prompt:
358+
359+
.. code-block:: python
360+
361+
# From TensorFlow/models/research/
362+
for /f %i in ('dir /b object_detection\protos\*.proto') do protoc object_detection\protos\%i --python_out=.
363+
352364
.. [#] NOTE: You MUST open a new `Anaconda/Command Prompt` for the changes in the environment variables to take effect.
353365
354366
.. _test_tf_models:
@@ -379,6 +391,9 @@ Test your Installation
379391
LabelImg Installation
380392
---------------------
381393

394+
For Windows and Linux you can download the precompiled binary at http://tzutalin.github.io/labelImg/.
395+
The steps for installing from source follow below.
396+
382397
Create a new Conda virtual environment
383398
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
384399

@@ -398,7 +413,7 @@ To deal with the fact that ``labelImg`` (on Windows) requires the use of ``pyqt4
398413
399414
activate labelImg
400415
401-
Once you have activated your virtual environment, the name of the environment should be displayed within brackets at the beggining of your cmd path specifier, e.g.:
416+
Once you have activated your virtual environment, the name of the environment should be displayed within brackets at the beginning of your cmd path specifier, e.g.:
402417

403418
.. code-block:: ps1con
404419
@@ -407,7 +422,7 @@ Once you have activated your virtual environment, the name of the environment sh
407422
Downloading labelImg
408423
~~~~~~~~~~~~~~~~~~~~
409424

410-
- Inside you ``TesnorFlow`` folder, create a new directory, name it ``addons`` and then ``cd`` into it.
425+
- Inside you ``TensorFlow`` folder, create a new directory, name it ``addons`` and then ``cd`` into it.
411426
- To download the package you can either use `Git <https://git-scm.com/downloads>`_ to clone the `labelImg repo <https://github.com/tzutalin/labelImg>`_ inside the ``TensorFlow\addons`` folder, or you can simply download it as a `ZIP <https://github.com/tzutalin/labelImg/archive/master.zip>`_ and extract it's contents inside the ``TensorFlow\addons`` folder. To keep things consistent, in the latter case you will have to rename the extracted folder ``labelImg-master`` to ``labelImg``. [#]_
412427
- You should now have a single folder named ``addons\labelImg`` under your ``TensorFlow`` folder, which contains another 4 folders as such:
413428

docs/build/html/_sources/training.rst.txt

+24-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Now that we have done all the above, we can start doing some cool stuff. Here we
1919
Preparing workspace
2020
~~~~~~~~~~~~~~~~~~~
2121

22-
If you have followed the tutorial, you shhould by now have a folder ``Tensorflow``, placed under ``<PATH_TO_TF>`` (e.g. ``C:\Users\sglvladi\Documents``), with the following directory tree:
22+
If you have followed the tutorial, you should by now have a folder ``Tensorflow``, placed under ``<PATH_TO_TF>`` (e.g. ``C:\Users\sglvladi\Documents``), with the following directory tree:
2323

2424
| TensorFlow
2525
| ├─ addons
@@ -66,7 +66,7 @@ Here's an explanation for each of the folders/filer shown in the above tree:
6666
- ``images``: This folder contains a copy of all the images in our dataset, as well as the respective ``*.xml`` files produced for each one, once ``labelImg`` is used to annotate objects.
6767

6868
* ``images\train``: This folder contains a copy of all images, and the respective ``*.xml`` files, which will be used to train our model.
69-
* ``images\test``: This folder contains a copy of all images, and the respective ``*.xml`` files, which will be used to train our model.
69+
* ``images\test``: This folder contains a copy of all images, and the respective ``*.xml`` files, which will be used to test our model.
7070

7171
- ``pre-trained-model``: This folder will contain the pre-trained model of our choice, which shall be used as a starting checkpoint for our training job.
7272
- ``training``: This folder will contain the training pipeline configuration file ``*.config``, as well as a ``*.pbtxt`` label map file and all files generated during the training of our model.
@@ -296,7 +296,9 @@ Now that we have obtained our ``*.csv`` annotation files, we will need to conver
296296
import io
297297
import pandas as pd
298298
import tensorflow as tf
299-
299+
import sys
300+
sys.path.append("../../models/research")
301+
300302
from PIL import Image
301303
from object_detection.utils import dataset_util
302304
from collections import namedtuple, OrderedDict
@@ -305,13 +307,24 @@ Now that we have obtained our ``*.csv`` annotation files, we will need to conver
305307
flags.DEFINE_string('csv_input', '', 'Path to the CSV input')
306308
flags.DEFINE_string('output_path', '', 'Path to output TFRecord')
307309
flags.DEFINE_string('label', '', 'Name of class label')
310+
# if your image has more labels input them as
311+
# flags.DEFINE_string('label0', '', 'Name of class[0] label')
312+
# flags.DEFINE_string('label1', '', 'Name of class[1] label')
313+
# and so on.
314+
flags.DEFINE_string('img_path', '', 'Path to images')
308315
FLAGS = flags.FLAGS
309316
310317
311318
# TO-DO replace this with label map
319+
# for multiple labels add more else if statements
312320
def class_text_to_int(row_label):
313321
if row_label == FLAGS.label: # 'ship':
314322
return 1
323+
# comment upper if statement and uncomment these statements for multiple labelling
324+
# if row_label == FLAGS.label0:
325+
# return 1
326+
# elif row_label == FLAGS.label1:
327+
# return 0
315328
else:
316329
None
317330
@@ -331,6 +344,7 @@ Now that we have obtained our ``*.csv`` annotation files, we will need to conver
331344
332345
filename = group.filename.encode('utf8')
333346
image_format = b'jpg'
347+
# check if the image format is matching with your images.
334348
xmins = []
335349
xmaxs = []
336350
ymins = []
@@ -365,7 +379,7 @@ Now that we have obtained our ``*.csv`` annotation files, we will need to conver
365379
366380
def main(_):
367381
writer = tf.python_io.TFRecordWriter(FLAGS.output_path)
368-
path = os.path.join(os.getcwd(), 'images')
382+
path = os.path.join(os.getcwd(), FLAGS.img_path)
369383
examples = pd.read_csv(FLAGS.csv_input)
370384
grouped = split(examples, 'filename')
371385
for group in grouped:
@@ -387,11 +401,11 @@ Now that we have obtained our ``*.csv`` annotation files, we will need to conver
387401
388402
# Create train data:
389403
python generate_tfrecord.py --label=<LABEL> --csv_input=<PATH_TO_ANNOTATIONS_FOLDER>/train_labels.csv
390-
--img_path=<PATH_TO_IMAGES_FOLDER> --output_path=<PATH_TO_ANNOTATIONS_FOLDER>/train.record
404+
--img_path=<PATH_TO_IMAGES_FOLDER>/train --output_path=<PATH_TO_ANNOTATIONS_FOLDER>/train.record
391405
392406
# Create test data:
393407
python generate_tfrecord.py --label=<LABEL> --csv_input=<PATH_TO_ANNOTATIONS_FOLDER>/test_labels.csv
394-
--img_path=<PATH_TO_IMAGES_FOLDER>
408+
--img_path=<PATH_TO_IMAGES_FOLDER>/test
395409
--output_path=<PATH_TO_ANNOTATIONS_FOLDER>/test.record
396410
397411
# For example
@@ -612,7 +626,7 @@ Once the above changes have been applied to our config file, go ahead and save i
612626
Training the Model
613627
~~~~~~~~~~~~~~~~~~
614628

615-
Before we begin training our model, let's go and copy the ``TensorFlow/models/research/object_detection/train.py`` script and paste it straight into our ``training_demo`` folder. We will need this script in order to train our model.
629+
Before we begin training our model, let's go and copy the ``TensorFlow/models/research/object_detection/legacy/train.py`` script and paste it straight into our ``training_demo`` folder. We will need this script in order to train our model.
616630

617631
Now, to initiate a new training job, ``cd`` inside the ``training_demo`` folder and type the following:
618632

@@ -715,12 +729,12 @@ Once your training job is complete, you need to extract the newly trained infere
715729
716730
activate tensorflow_gpu
717731
718-
- Copy the ``TensorFlow/models/research/object_detection/extract_inference_graph.py`` script and paste it straight into your ``training_demo`` folder.
732+
- Copy the ``TensorFlow/models/research/object_detection/export_inference_graph.py`` script and paste it straight into your ``training_demo`` folder.
719733
- Check inside your ``training_demo/training`` folder for the ``model.ckpt-*`` checkpoint file with the highest number following the name of the dash e.g. ``model.ckpt-34350``). This number represents the training step index at which the file was created.
720734
- Alternatively, simply sort all the files inside ``training_demo/training`` by descending time and pick the ``model.ckpt-*`` file that comes first in the list.
721-
- Make a note of the file's name, as it will be passed as an argument when we call the ``extract_inference_graph.py`` script.
735+
- Make a note of the file's name, as it will be passed as an argument when we call the ``export_inference_graph.py`` script.
722736
- Now, ``cd`` inside your ``training_demo`` folder, and run the following command:
723737

724738
.. code-block:: posh
725739
726-
python export_inference_graph.py --input_type image_tensor --pipeline_config_path training/ssd_inception_v2_coco.config --trained_checkpoint_prefix training/model.ckpt-13302 --output_directory trained-inference-graphs/output_inference_graph_v1.pb
740+
python export_inference_graph.py --input_type image_tensor --pipeline_config_path training/ssd_inception_v2_coco.config --trained_checkpoint_prefix training/model.ckpt-13302 --output_directory trained-inference-graphs/output_inference_graph_v1.pb

0 commit comments

Comments
 (0)