diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..261eeb9e
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/Object_detection_image.py b/Object_detection_image.py
index 0068d3bc..577b8c6b 100644
--- a/Object_detection_image.py
+++ b/Object_detection_image.py
@@ -3,9 +3,9 @@
# Author: Evan Juras
# Date: 1/15/18
# Description:
-# This program uses a TensorFlow-trained classifier to perform object detection.
-# It loads the classifier uses it to perform object detection on an image.
-# It draws boxes and scores around the objects of interest in the image.
+# This program uses a TensorFlow-trained neural network to perform object detection.
+# It loads the classifier and uses it to perform object detection on an image.
+# It draws boxes, scores, and labels around the objects of interest in the image.
## Some of the code is copied from Google's example at
## https://github.com/tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb
@@ -90,7 +90,8 @@
# expand image dimensions to have shape: [1, None, None, 3]
# i.e. a single-column array, where each item in the column has the pixel RGB value
image = cv2.imread(PATH_TO_IMAGE)
-image_expanded = np.expand_dims(image, axis=0)
+image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
+image_expanded = np.expand_dims(image_rgb, axis=0)
# Perform the actual detection by running the model with the image as input
(boxes, scores, classes, num) = sess.run(
@@ -107,7 +108,7 @@
category_index,
use_normalized_coordinates=True,
line_thickness=8,
- min_score_thresh=0.80)
+ min_score_thresh=0.60)
# All the results have been drawn on image. Now display the image.
cv2.imshow('Object detector', image)
diff --git a/Object_detection_video.py b/Object_detection_video.py
index 60800fda..a6ca6d5d 100644
--- a/Object_detection_video.py
+++ b/Object_detection_video.py
@@ -4,9 +4,9 @@
# Date: 1/16/18
# Description:
# This program uses a TensorFlow-trained classifier to perform object detection.
-# It loads the classifier uses it to perform object detection on a video.
-# It draws boxes and scores around the objects of interest in each frame
-# of the video.
+# It loads the classifier and uses it to perform object detection on a video.
+# It draws boxes, scores, and labels around the objects of interest in each
+# frame of the video.
## Some of the code is copied from Google's example at
## https://github.com/tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb
@@ -95,7 +95,8 @@
# Acquire frame and expand frame dimensions to have shape: [1, None, None, 3]
# i.e. a single-column array, where each item in the column has the pixel RGB value
ret, frame = video.read()
- frame_expanded = np.expand_dims(frame, axis=0)
+ frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
+ frame_expanded = np.expand_dims(frame_rgb, axis=0)
# Perform the actual detection by running the model with the image as input
(boxes, scores, classes, num) = sess.run(
@@ -111,7 +112,7 @@
category_index,
use_normalized_coordinates=True,
line_thickness=8,
- min_score_thresh=0.80)
+ min_score_thresh=0.60)
# All the results have been drawn on the frame, so it's time to display it.
cv2.imshow('Object detector', frame)
diff --git a/Object_detection_webcam.py b/Object_detection_webcam.py
index 1f98d26c..ffbe767d 100644
--- a/Object_detection_webcam.py
+++ b/Object_detection_webcam.py
@@ -4,9 +4,9 @@
# Date: 1/20/18
# Description:
# This program uses a TensorFlow-trained classifier to perform object detection.
-# It loads the classifier uses it to perform object detection on a webcam feed.
-# It draws boxes and scores around the objects of interest in each frame from
-# the webcam.
+# It loads the classifier and uses it to perform object detection on a webcam feed.
+# It draws boxes, scores, and labels around the objects of interest in each frame
+# from the webcam.
## Some of the code is copied from Google's example at
## https://github.com/tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb
@@ -95,7 +95,8 @@
# Acquire frame and expand frame dimensions to have shape: [1, None, None, 3]
# i.e. a single-column array, where each item in the column has the pixel RGB value
ret, frame = video.read()
- frame_expanded = np.expand_dims(frame, axis=0)
+ frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
+ frame_expanded = np.expand_dims(frame_rgb, axis=0)
# Perform the actual detection by running the model with the image as input
(boxes, scores, classes, num) = sess.run(
diff --git a/README.md b/README.md
index 17585083..ec98b75c 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,15 @@
# How To Train an Object Detection Classifier for Multiple Objects Using TensorFlow (GPU) on Windows 10
## Brief Summary
-*Last updated: 9/26/2018 with TensorFlow v1.10*
-
-*Changes: Added note that the train.py file is now located in the /object_detection/legacy folder and must be moved into the main folder before issuing the training command.*
+*Last updated: 6/22/2019 with TensorFlow v1.13.1*
This repository is a tutorial for how to use TensorFlow's Object Detection API to train an object detection classifier for multiple objects on Windows 10, 8, or 7. (It will also work on Linux-based OSes with some minor changes.) It was originally written using TensorFlow version 1.5, but will also work for newer versions of TensorFlow.
+Translated versions of this guide are listed below. If you would like to contribute a translation in another language, please feel free! You can add it as a pull request and I will merge it when I get the chance.
+* [Korean translation](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10/blob/master/translate/README_Korean.md) (thanks @cocopambag!)
+* [Chinese translation](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10/blob/master/translate/README_Chinese.md) (thanks @Marco-Ray!)
+* [Vietnamese translation](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10/blob/master/translate/README_Vietnamese.md) (thanks @winter2897!)
+
I also made a YouTube video that walks through this tutorial. Any discrepancies between the video and this written tutorial are due to updates required for using newer versions of TensorFlow.
**If there are differences between this written tutorial and the video, follow the written tutorial!**
@@ -14,7 +17,7 @@ I also made a YouTube video that walks through this tutorial. Any discrepancies
[](https://www.youtube.com/watch?v=Rgpfk6eYxJA)
This readme describes every step required to get going with your own object detection classifier:
-1. [Installing TensorFlow-GPU](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#1-install-tensorflow-gpu-15-skip-this-step-if-tensorflow-gpu-15-is-already-installed)
+1. [Installing Anaconda, CUDA, and cuDNN](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#1-install-anaconda-cuda-and-cudnn)
2. [Setting up the Object Detection directory structure and Anaconda Virtual Environment](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#2-set-up-tensorflow-directory-and-anaconda-virtual-environment)
3. [Gathering and labeling pictures](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#3-gather-and-label-pictures)
4. [Generating training data](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#4-generate-training-data)
@@ -36,20 +39,17 @@ The purpose of this tutorial is to explain how to train your own convolutional n
There are several good tutorials available for how to use TensorFlow’s Object Detection API to train a classifier for a single object. However, these usually assume you are using a Linux operating system. If you’re like me, you might be a little hesitant to install Linux on your high-powered gaming PC that has the sweet graphics card you’re using to train a classifier. The Object Detection API seems to have been developed on a Linux-based OS. To set up TensorFlow to train a model on Windows, there are several workarounds that need to be used in place of commands that would work fine on Linux. Also, this tutorial provides instructions for training a classifier that can detect multiple objects, not just one.
-The tutorial is written for Windows 10, and it will also work for Windows 7 and 8. The general procedure can also be used for Linux operating systems, but file paths and package installation commands will need to change accordingly.
-
-TensorFlow-GPU allows your PC to use the video card to provide extra processing power while training, so it will be used for this tutorial. In my experience, using TensorFlow-GPU instead of regular TensorFlow reduces training time by a factor of about 8 (3 hours to train instead of 24 hours). Regular TensorFlow can also be used for this tutorial, but it will take longer. If you use regular TensorFlow, you do not need to install CUDA and cuDNN in Step 1. I used TensorFlow-GPU v1.5 while writing this tutorial, but it will likely work for future versions of TensorFlow.
+The tutorial is written for Windows 10, and it will also work for Windows 7 and 8. The general procedure can also be used for Linux operating systems, but file paths and package installation commands will need to change accordingly. I used TensorFlow-GPU v1.5 while writing the initial version of this tutorial, but it will likely work for future versions of TensorFlow.
+TensorFlow-GPU allows your PC to use the video card to provide extra processing power while training, so it will be used for this tutorial. In my experience, using TensorFlow-GPU instead of regular TensorFlow reduces training time by a factor of about 8 (3 hours to train instead of 24 hours). The CPU-only version of TensorFlow can also be used for this tutorial, but it will take longer. If you use CPU-only TensorFlow, you do not need to install CUDA and cuDNN in Step 1.
## Steps
-### 1. Install TensorFlow-GPU 1.5 (skip this step if TensorFlow-GPU 1.5 is already installed)
-Install TensorFlow-GPU by following the instructions in [this YouTube Video by Mark Jay](https://www.youtube.com/watch?v=RplXYjxgZbw).
-
-The video is made for TensorFlow-GPU v1.4, but the “pip install --upgrade tensorflow-gpu” command will automatically download version 1.5. Download and install CUDA v9.0 and cuDNN v7.0 (rather than CUDA v8.0 and cuDNN v6.0 as instructed in the video), because they are supported by TensorFlow-GPU v1.5. As future versions of TensorFlow are released, you will likely need to continue updating the CUDA and cuDNN versions to the latest supported version.
+### 1. Install Anaconda, CUDA, and cuDNN
+Anaconda is a software toolkit that creates virtual Python environments so you can install and use Python libraries without worrying about creating version conflicts with existing installations. Anaconda works well on Windows, and enables you to use many Python libraries that normally would only work on a Linux system. It provides a simple method for installing TensorFlow (which we'll do in Step 2d). It also automatically installs the CUDA and cuDNN versions you need for using TensorFlow on a GPU.
-Be sure to install Anaconda with Python 3.6 as instructed in the video, as the Anaconda virtual environment will be used for the rest of this tutorial.
+Download Anaconda for Windows from [their webpage](https://www.anaconda.com/products/individual) (you have to scroll down a ways to get to the download links). Once it's downloaded, execute the installer file and work through the installation steps.
-Visit [TensorFlow's website](https://www.tensorflow.org/install/install_windows) for further installation details, including how to install it on other operating systems (like Linux). The [object detection repository](https://github.com/tensorflow/models/tree/master/research/object_detection) itself also has [installation instructions](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md).
+If you are using a version of TensorFlow older than TF v1.13, make sure you use the CUDA and cuDNN versions that are compatible with the TensorFlow version you are using. [Here](https://www.tensorflow.org/install/source#tested_build_configurations) is a table showing which version of TensorFlow requires which versions of CUDA and cuDNN. Anaconda will automatically install the correct version of CUDA and cuDNN for the version of TensorFlow you are using, so you shouldn't have to worry about this.
### 2. Set up TensorFlow Directory and Anaconda Virtual Environment
The TensorFlow Object Detection API requires using the specific directory structure provided in its GitHub repository. It also requires several additional Python packages, specific additions to the PATH and PYTHONPATH variables, and a few extra setup commands to get everything set up to run or train an object detection model.
@@ -60,10 +60,26 @@ This portion of the tutorial goes over the full set up required. It is fairly me
Create a folder directly in C: and name it “tensorflow1”. This working directory will contain the full TensorFlow object detection framework, as well as your training images, training data, trained classifier, configuration files, and everything else needed for the object detection classifier.
Download the full TensorFlow object detection repository located at https://github.com/tensorflow/models by clicking the “Clone or Download” button and downloading the zip file. Open the downloaded zip file and extract the “models-master” folder directly into the C:\tensorflow1 directory you just created. Rename “models-master” to just “models”.
-(Note, this tutorial was done using this [GitHub commit](https://github.com/tensorflow/models/tree/079d67d9a0b3407e8d074a200780f3835413ef99) of the TensorFlow Object Detection API. If portions of this tutorial do not work, it may be necessary to download and use this exact commit rather than the most up-to-date version.)
-#### 2b. Download the Faster-RCNN-Inception-V2-COCO model from TensorFlow's model zoo
-TensorFlow provides several object detection models (pre-trained classifiers with specific neural network architectures) in its [model zoo](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md). Some models (such as the SSD-MobileNet model) have an architecture that allows for faster detection but with less accuracy, while some models (such as the Faster-RCNN model) give slower detection but with more accuracy. I initially started with the SSD-MobileNet-V1 model, but it didn’t do a very good job identifying the cards in my images. I re-trained my detector on the Faster-RCNN-Inception-V2 model, and the detection worked considerably better, but with a noticeably slower speed.
+**Note: The TensorFlow models repository's code (which contains the object detection API) is continuously updated by the developers. Sometimes they make changes that break functionality with old versions of TensorFlow. It is always best to use the latest version of TensorFlow and download the latest models repository. If you are not using the latest version, clone or download the commit for the version you are using as listed in the table below.**
+
+ If you are using an older version of TensorFlow, here is a table showing which GitHub commit of the repository you should use. I generated this by going to the release branches for the models repository and getting the commit before the last commit for the branch. (They remove the research folder as the last commit before they create the official version release.)
+
+| TensorFlow version | GitHub Models Repository Commit |
+|--------------------|---------------------------------|
+|TF v1.7 |https://github.com/tensorflow/models/tree/adfd5a3aca41638aa9fb297c5095f33d64446d8f |
+|TF v1.8 |https://github.com/tensorflow/models/tree/abd504235f3c2eed891571d62f0a424e54a2dabc |
+|TF v1.9 |https://github.com/tensorflow/models/tree/d530ac540b0103caa194b4824af353f1b073553b |
+|TF v1.10 |https://github.com/tensorflow/models/tree/b07b494e3514553633b132178b4c448f994d59df |
+|TF v1.11 |https://github.com/tensorflow/models/tree/23b5b4227dfa1b23d7c21f0dfaf0951b16671f43 |
+|TF v1.12 |https://github.com/tensorflow/models/tree/r1.12.0 |
+|TF v1.13 |https://github.com/tensorflow/models/tree/r1.13.0 |
+|Latest version |https://github.com/tensorflow/models |
+
+This tutorial was originally done using TensorFlow v1.5 and this [GitHub commit](https://github.com/tensorflow/models/tree/079d67d9a0b3407e8d074a200780f3835413ef99) of the TensorFlow Object Detection API. If portions of this tutorial do not work, it may be necessary to install TensorFlow v1.5 and use this exact commit rather than the most up-to-date version.
+
+#### 2b. Download the Faster-RCNN-Inception-V2-COCO model from TensorFlow's model
+TensorFlow provides several object detection models (pre-trained classifiers with specific neural network architectures) in its [model zoo](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf1_detection_zoo.md). Some models (such as the SSD-MobileNet model) have an architecture that allows for faster detection but with less accuracy, while some models (such as the Faster-RCNN model) give slower detection but with more accuracy. I initially started with the SSD-MobileNet-V1 model, but it didn’t do a very good job identifying the cards in my images. I re-trained my detector on the Faster-RCNN-Inception-V2 model, and the detection worked considerably better, but with a noticeably slower speed.
@@ -103,20 +119,28 @@ In the command terminal that pops up, create a new virtual environment called
```
C:\> conda create -n tensorflow1 pip python=3.5
```
-Then, activate the environment by issuing:
+Then, activate the environment and update pip by issuing:
```
C:\> activate tensorflow1
+
+(tensorflow1) C:\>python -m pip install --upgrade pip
```
Install tensorflow-gpu in this environment by issuing:
```
(tensorflow1) C:\> pip install --ignore-installed --upgrade tensorflow-gpu
```
+
+Since we're using Anaconda, installing tensorflow-gpu will also automatically download and install the correct versions of CUDA and cuDNN.
+
+(Note: You can also use the CPU-only version of TensorFow, but it will run much slower. If you want to use the CPU-only version, just use "tensorflow" instead of "tensorflow-gpu" in the previous command.)
+
Install the other necessary packages by issuing the following commands:
```
(tensorflow1) C:\> conda install -c anaconda protobuf
(tensorflow1) C:\> pip install pillow
(tensorflow1) C:\> pip install lxml
(tensorflow1) C:\> pip install Cython
+(tensorflow1) C:\> pip install contextlib2
(tensorflow1) C:\> pip install jupyter
(tensorflow1) C:\> pip install matplotlib
(tensorflow1) C:\> pip install pandas
@@ -129,14 +153,19 @@ A PYTHONPATH variable must be created that points to the \models, \models\resear
```
(tensorflow1) C:\> set PYTHONPATH=C:\tensorflow1\models;C:\tensorflow1\models\research;C:\tensorflow1\models\research\slim
```
-(Note: Every time the "tensorflow1" virtual environment is exited, the PYTHONPATH variable is reset and needs to be set up again.)
+(Note: Every time the "tensorflow1" virtual environment is exited, the PYTHONPATH variable is reset and needs to be set up again. You can use "echo %PYTHONPATH% to see if it has been set or not.)
#### 2f. Compile Protobufs and run setup.py
Next, compile the Protobuf files, which are used by TensorFlow to configure model and training parameters. Unfortunately, the short protoc compilation command posted on TensorFlow’s Object Detection API [installation page](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md) does not work on Windows. Every .proto file in the \object_detection\protos directory must be called out individually by the command.
-In the Anaconda Command Prompt, change directories to the \models\research directory and copy and paste the following command into the command line and press Enter:
+In the Anaconda Command Prompt, change directories to the \models\research directory:
+```
+(tensorflow1) C:\> cd C:\tensorflow1\models\research
+```
+
+Then copy and paste the following command into the command line and press Enter:
```
-protoc --python_out=. .\object_detection\protos\anchor_generator.proto .\object_detection\protos\argmax_matcher.proto .\object_detection\protos\bipartite_matcher.proto .\object_detection\protos\box_coder.proto .\object_detection\protos\box_predictor.proto .\object_detection\protos\eval.proto .\object_detection\protos\faster_rcnn.proto .\object_detection\protos\faster_rcnn_box_coder.proto .\object_detection\protos\grid_anchor_generator.proto .\object_detection\protos\hyperparams.proto .\object_detection\protos\image_resizer.proto .\object_detection\protos\input_reader.proto .\object_detection\protos\losses.proto .\object_detection\protos\matcher.proto .\object_detection\protos\mean_stddev_box_coder.proto .\object_detection\protos\model.proto .\object_detection\protos\optimizer.proto .\object_detection\protos\pipeline.proto .\object_detection\protos\post_processing.proto .\object_detection\protos\preprocessor.proto .\object_detection\protos\region_similarity_calculator.proto .\object_detection\protos\square_box_coder.proto .\object_detection\protos\ssd.proto .\object_detection\protos\ssd_anchor_generator.proto .\object_detection\protos\string_int_label_map.proto .\object_detection\protos\train.proto .\object_detection\protos\keypoint_box_coder.proto .\object_detection\protos\multiscale_anchor_generator.proto .\object_detection\protos\graph_rewriter.proto
+protoc --python_out=. .\object_detection\protos\anchor_generator.proto .\object_detection\protos\argmax_matcher.proto .\object_detection\protos\bipartite_matcher.proto .\object_detection\protos\box_coder.proto .\object_detection\protos\box_predictor.proto .\object_detection\protos\eval.proto .\object_detection\protos\faster_rcnn.proto .\object_detection\protos\faster_rcnn_box_coder.proto .\object_detection\protos\grid_anchor_generator.proto .\object_detection\protos\hyperparams.proto .\object_detection\protos\image_resizer.proto .\object_detection\protos\input_reader.proto .\object_detection\protos\losses.proto .\object_detection\protos\matcher.proto .\object_detection\protos\mean_stddev_box_coder.proto .\object_detection\protos\model.proto .\object_detection\protos\optimizer.proto .\object_detection\protos\pipeline.proto .\object_detection\protos\post_processing.proto .\object_detection\protos\preprocessor.proto .\object_detection\protos\region_similarity_calculator.proto .\object_detection\protos\square_box_coder.proto .\object_detection\protos\ssd.proto .\object_detection\protos\ssd_anchor_generator.proto .\object_detection\protos\string_int_label_map.proto .\object_detection\protos\train.proto .\object_detection\protos\keypoint_box_coder.proto .\object_detection\protos\multiscale_anchor_generator.proto .\object_detection\protos\graph_rewriter.proto .\object_detection\protos\calibration.proto .\object_detection\protos\flexible_grid_anchor_generator.proto
```
This creates a name_pb2.py file from every name.proto file in the \object_detection\protos folder.
@@ -159,6 +188,8 @@ This opens the script in your default web browser and allows you to step through
Once you have stepped all the way through the script, you should see two labeled images at the bottom section the page. If you see this, then everything is working properly! If not, the bottom section will report any errors encountered. See the [Appendix](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#appendix-common-errors) for a list of errors I encountered while setting this up.
+**Note: If you run the full Jupyter Notebook without getting any errors, but the labeled pictures still don't appear, try this: go in to object_detection/utils/visualization_utils.py and comment out the import statements around lines 29 and 30 that include matplotlib. Then, try re-running the Jupyter notebook.**
+
@@ -196,12 +227,6 @@ Download and install LabelImg, point it to your \images\train directory, and the
LabelImg saves a .xml file containing the label data for each image. These .xml files will be used to generate TFRecords, which are one of the inputs to the TensorFlow trainer. Once you have labeled and saved each image, there will be one .xml file for each image in the \test and \train directories.
-Also, you can check if the size of each bounding box is correct by running sizeChecker.py
-
-```
-(tensorflow1) C:\tensorflow1\models\research\object_detection> python sizeChecker.py --move
-```
-
### 4. Generate Training Data
With the images labeled, it’s time to generate the TFRecords that serve as input data to the TensorFlow training model. This tutorial uses the xml_to_csv.py and generate_tfrecord.py scripts from [Dat Tran’s Raccoon Detector dataset](https://github.com/datitran/raccoon_dataset), with some slight modifications to work with our directory structure.
@@ -230,7 +255,7 @@ def class_text_to_int(row_label):
elif row_label == 'ace':
return 6
else:
- return None
+ None
```
With this:
```
@@ -243,7 +268,7 @@ def class_text_to_int(row_label):
elif row_label == 'shoe':
return 3
else:
- return None
+ None
```
Then, generate the TFRecord files by issuing these commands from the \object_detection folder:
```
@@ -314,16 +339,16 @@ Navigate to C:\tensorflow1\models\research\object_detection\samples\configs and
Make the following changes to the faster_rcnn_inception_v2_pets.config file. Note: The paths must be entered with single forward slashes (NOT backslashes), or TensorFlow will give a file path error when trying to train the model! Also, the paths must be in double quotation marks ( " ), not single quotation marks ( ' ).
- Line 9. Change num_classes to the number of different objects you want the classifier to detect. For the above basketball, shirt, and shoe detector, it would be num_classes : 3 .
-- Line 110. Change fine_tune_checkpoint to:
+- Line 106. Change fine_tune_checkpoint to:
- fine_tune_checkpoint : "C:/tensorflow1/models/research/object_detection/faster_rcnn_inception_v2_coco_2018_01_28/model.ckpt"
-- Lines 126 and 128. In the train_input_reader section, change input_path and label_map_path to:
+- Lines 123 and 125. In the train_input_reader section, change input_path and label_map_path to:
- input_path : "C:/tensorflow1/models/research/object_detection/train.record"
- label_map_path: "C:/tensorflow1/models/research/object_detection/training/labelmap.pbtxt"
-- Line 132. Change num_examples to the number of images you have in the \images\test directory.
+- Line 130. Change num_examples to the number of images you have in the \images\test directory.
-- Lines 140 and 142. In the eval_input_reader section, change input_path and label_map_path to:
+- Lines 135 and 137. In the eval_input_reader section, change input_path and label_map_path to:
- input_path : "C:/tensorflow1/models/research/object_detection/test.record"
- label_map_path: "C:/tensorflow1/models/research/object_detection/training/labelmap.pbtxt"
@@ -384,7 +409,7 @@ If you encounter errors, please check out the Appendix: it has a list of errors
## Appendix: Common Errors
It appears that the TensorFlow Object Detection API was developed on a Linux-based operating system, and most of the directions given by the documentation are for a Linux OS. Trying to get a Linux-developed software library to work on Windows can be challenging. There are many little snags that I ran in to while trying to set up tensorflow-gpu to train an object detection classifier on Windows 10. This Appendix is a list of errors I ran in to, and their resolutions.
-#### 1. ModuleNotFoundError: No module named 'deployment'
+#### 1. ModuleNotFoundError: No module named 'deployment' or No module named 'nets'
This error occurs when you try to run object_detection_tutorial.ipynb or train.py and you don’t have the PATH and PYTHONPATH environment variables set up correctly. Exit the virtual environment by closing and re-opening the Anaconda Prompt window. Then, issue “activate tensorflow1” to re-enter the environment, and then issue the commands given in Step 2e.
@@ -435,4 +460,18 @@ rate_index = tf.reduce_max(tf.where(tf.greater_equal(global_step, boundaries),
[0] * num_boundaries))
```
-[Ref: Tensorflow Issue#3705](https://github.com/tensorflow/models/issues/3705#issuecomment-375563179)
\ No newline at end of file
+[Ref: Tensorflow Issue#3705](https://github.com/tensorflow/models/issues/3705#issuecomment-375563179)
+
+#### 6. ImportError: DLL load failed: The specified procedure could not be found. (or other DLL-related errors)
+This error occurs because the CUDA and cuDNN versions you have installed are not compatible with the version of TensorFlow you are using. The easiest way to resolve this error is to use Anaconda's cudatoolkit package rather than manually installing CUDA and cuDNN. If you ran into these errors, try creating a new Anaconda virtual environment:
+```
+conda create -n tensorflow2 pip python=3.5
+```
+Then, once inside the environment, install TensorFlow using CONDA rather than PIP:
+```
+conda install tensorflow-gpu
+```
+Then restart this guide from Step 2 (but you can skip the part where you install TensorFlow in Step 2d).
+
+#### 7. In Step 2g, the Jupyter Notebook runs all the way through with no errors, but no pictures are displayed at the end.
+If you run the full Jupyter Notebook without getting any errors, but the labeled pictures still don't appear, try this: go in to object_detection/utils/visualization_utils.py and comment out the import statements around lines 29 and 30 that include matplotlib. Then, try re-running the Jupyter notebook. (The visualization_utils.py script changes quite a bit, so it might not be exactly line 29 and 30.)
diff --git a/doc/object_detection_directory.jpg b/doc/object_detection_directory.jpg
index b17a2c65..7385476d 100644
Binary files a/doc/object_detection_directory.jpg and b/doc/object_detection_directory.jpg differ
diff --git a/generate_tfrecord.py b/generate_tfrecord.py
index c318ff7b..36c97ed5 100644
--- a/generate_tfrecord.py
+++ b/generate_tfrecord.py
@@ -14,7 +14,12 @@
import os
import io
import pandas as pd
-import tensorflow as tf
+
+from tensorflow.python.framework.versions import VERSION
+if VERSION >= "2.0.0a0":
+ import tensorflow.compat.v1 as tf
+else:
+ import tensorflow as tf
from PIL import Image
from object_detection.utils import dataset_util
diff --git a/resizer.py b/resizer.py
index 108c4b01..3a2383cf 100644
--- a/resizer.py
+++ b/resizer.py
@@ -17,5 +17,5 @@
# If the images are not .JPG images, change the line below to match the image type.
if filename.endswith(".JPG"):
image = cv2.imread(filename)
- resized = cv2.resize(image,None,fx=0.125, fy=0.125, interpolation=cv2.INTER_AREA)
+ resized = cv2.resize(image,None,fx=0.25, fy=0.25, interpolation=cv2.INTER_AREA)
cv2.imwrite(filename,resized)
diff --git a/training/faster_rcnn_inception_v2_pets.config b/training/faster_rcnn_inception_v2_pets.config
index 40095e39..0f7b0f76 100644
--- a/training/faster_rcnn_inception_v2_pets.config
+++ b/training/faster_rcnn_inception_v2_pets.config
@@ -89,7 +89,7 @@ train_config: {
manual_step_learning_rate {
initial_learning_rate: 0.0002
schedule {
- step: 0
+ step: 1
learning_rate: .0002
}
schedule {
diff --git a/translate/README_Chinese.md b/translate/README_Chinese.md
new file mode 100644
index 00000000..ea5a7f6c
--- /dev/null
+++ b/translate/README_Chinese.md
@@ -0,0 +1,452 @@
+# 如何在Windows10上使用TensorFlow(GPU)进行多物体目标识别分类器的训练
+---
+## 简要总结
+---
+这个仓库是一个如何使用TensorFlow的物体识别API在Windows10,8,7上进行物体识别分类器训练的教程。(它同样能在基于Linux的系统,只需要一些微小的改变。)它最初使用TensorFlow的1.5版本,但同样适用于更新版本的TensorFlow。
+
+我同样制作了一个Youtube视频一步一步讲解本教程。视频和本教程之间存在的任何差异是由更新新版本的TensorFlow导致的。
+
+__如果视频和本教程有任何不同,请以本教程为准。__
+
+
+
+这个readme描述了你部署自己的物体识别分类器所要求的每一个步骤:
+1. [安装Anaconda,CUDA和cuDNN](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#1-install-anaconda-cuda-and-cudnn)
+2. [设置物体识别目录结构和Anaconda虚拟环境](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#2-set-up-tensorflow-directory-and-anaconda-virtual-environment)
+3. [收集和标注图片](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#3-gather-and-label-pictures)
+4. [生成训练数据](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#4-generate-training-data)
+5. [生成一个标注映射并配置训练](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#5-create-label-map-and-configure-training)
+6. [训练](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#6-run-the-training)
+7. [导出结论图](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#7-export-inference-graph)
+8. [测试和使用你的新训练好的物体识别分类器](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#8-use-your-newly-trained-object-detection-classifier)
+
+[附录:常见错误](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#appendix-common-errors)
+
+本仓库提供了训练“Pinochle Deck”扑克牌识别器所需要的所有文件,该识别器可以准确识别9,10,jack,queen,king和ace。本教程描述了如何用自己的文件替换这些文件,来训练一个你想要的识别分类器。它同样有Python脚本来测试你的分类器在图像、视频、网络摄像头上的效果。
+
+
+
+## 介绍
+---
+本教程的目的是解释如何从头开始训练你自己的多目标卷积神经网络物体识别分类器。在本教程的最后,会有一个对图片、视频和网络摄像头上识别并绘框的程序。
+
+目前已经有一些很好的教程教你如何使用TensorFlow的物体识别API去训练单目标的分类器。然而,它们通常假设你使用Linux操作系统。如果你和我一样,你会犹豫是否在自己拥有用于训练分类器的美妙显卡的高性能游戏PC上安装Linux。TensorFlow的物体识别API似乎是在Linux系统上发展起来的。为了在Windows上设置TensorFlow以训练模型,需要用几种代替方法来代替在Linux上可以正常使用的命令。此外,本教程提供了训练多目标识别的分类器的指导,而不是单目标。
+
+本教程基于Windows10,但也适用于Windows7和8。本文介绍的过程同样适用于Linux操作系统,但文件路径和包的安装命令需要相应改变。我在写本教程的最初版本时是用了TensorFlow GPU v1.5版本,但它仍适用于未来版本的TensorFlow。
+
+TensorFlow-GPU版能在训练时让你的PC使用显卡来提供额外的处理能力,所以它会在本教程中被使用。在我的经验中,使用TensorFlow-GPU而不是TensorFlow的常规版本,可以缩短大约8倍的训练时间(从24小时缩短至3小时)。CPU-only版本的TensorFlow也适用于本教程,但会训练更长时间。如果你使用CPU-only版本的TensorFlow,在step1中你就无需安装CUDA和cuDNN。
+
+## Steps
+---
+### 1. 安装Anaconda,CUDA和cuDNN
+跟随[这个Mark Jay的Youtube教程](https://www.youtube.com/watch?v=RplXYjxgZbw),它展示了Anaconda,CUDA和cuDNN的安装步骤。你不需要如视频中那样安装TensorFlow,因为我们会在后续的Step2中安装。这个视频是基于TensorFlow-GPU v1.4,所以请下载和安装和TensorFlow对应的最新版本的CUDA和cuDNN,而不是如同视频里指导的CUDA v8.0和cuDNN v6.0。
+
+如果你正在使用旧版本的TensorFlow,请确保你使用的CUDA和cuDNN版本和你使用的TensorFlow版本是兼容的。[这里](https://www.tensorflow.org/install/source#tested_build_configurations)展示了TensorFlow和CUDA、cuDNN的对应关系表。
+
+请确保如同视频中指导的那样安装[Anaconda](https://www.anaconda.com/distribution/#download-section),因为后续步骤中需要使用到Anaconda的虚拟环境。(Note:目前版本的Anaconda使用Python 3.7,TensorFlow不支持此版本。然而在Step 2d中创建Anaconda虚拟环境时我们会使用Python 3.5。)
+
+访问[TensorFlow官网](https://www.tensorflow.org/install)以了解更多安装细节,包括如何在其他操作系统(如Linux)上安装。 [物体识别仓库](https://github.com/tensorflow/models/tree/master/research/object_detection)同样有[安装指导](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md)
+
+### 2. 设置物体识别目录结构和Anaconda虚拟环境
+TensorFlow物体识别API要求使用其提供在Github仓库内的特定的目录结构。它还要求一些额外的Python库,特定的PATH和PYTHONPATH变量的添加,和一些额外的设置命令以使一切运作或训练一个物体识别模型。
+
+教程的本部分覆盖了所需的完整设置步骤。它非常精细,但请务必紧跟本教程,因为错误的设置会导致后续步骤中难以预料的错误。
+
+#### 2a. 从GitHub下载TensorFlow物体识别API库
+在C盘根目录下创建一个文件夹,并命名为"tensorflow1"。这个工作目录会包含整个TensorFlow物体识别框架,也包括你的训练图片,训练数据,训练好了的分类器,配置文件和其他所有物体识别分类器所需的文件。
+
+从[https://github.com/tensorflow/models](https://github.com/tensorflow/models)下载整个TensorFlow物体识别库,点击“Clone and Download”按钮并下载zip文件。打开下载好的zip文件并解压“models-master”文件夹至你刚创建好的C:\tensorflow1目录下。重命名“models-master”为“models”。
+
+__Note:TensorFlow模型库的代码(包含物体识别API)在持续不断地更新。有时他们做的改变会破快旧版本的功能。因此使用最新版本的TensorFlow和下载最新版本的模型库总是最好的选择。如果你并没有使用最新版本,克隆或下载下表中列出的对应版本。__
+
+如果你正使用旧版的TensorFlow,下表展示了你应该使用哪个版本的GitHub仓库。我通过前往模型库的发布分支并获取该分支最新版本之前的版本。(在发布正式版本前,他们在最新非正式版中去除了research文件夹)
+
+|TensorFlow version|GitHub Models Repository Commit|
+|---|---|
+|TF v1.7|https://github.com/tensorflow/models/tree/adfd5a3aca41638aa9fb297c5095f33d64446d8f|
+|TF v1.8|https://github.com/tensorflow/models/tree/abd504235f3c2eed891571d62f0a424e54a2dabc|
+|TF v1.9|https://github.com/tensorflow/models/tree/d530ac540b0103caa194b4824af353f1b073553b|
+|TF v1.10|https://github.com/tensorflow/models/tree/b07b494e3514553633b132178b4c448f994d59df|
+|TF v1.11|https://github.com/tensorflow/models/tree/23b5b4227dfa1b23d7c21f0dfaf0951b16671f43|
+|TF v1.12|https://github.com/tensorflow/models/tree/r1.12.0|
+|TF v1.13|https://github.com/tensorflow/models/tree/r1.13.0|
+|Latest version|https://github.com/tensorflow/models|
+本教程最初基于TensorFlow v1.5和TensorFlow物体识别API的这个[GitHub commit](https://github.com/tensorflow/models/tree/079d67d9a0b3407e8d074a200780f3835413ef99)完成。如果教程本部分失败,你也许需要安装TensorFlow v1.5并使用和我一样的commit而不是最新版本。
+
+#### 2b. 从TensorFlow模型中下载Faster-RCNN-Inception-V2-COCO模型
+TensorFlow在[model zoo](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf1_detection_zoo.md)里提供了一些物体识别模型(基于特定神经网络架构的预训练分类器)。一些模型(比如SSD-MobileNet模型)有着更快速识别但是更低正确率的架构,而另一些模型(如Faster-RCNN模型)识别更慢但是准确率更高。我最初使用SSD-MobileNet-V1模型,但对我的图片并没能取得很好的识别效果。我用Faster-RCNN-Incep-V2模型重新训练了我的识别器,它的识别效果明显更好,只是速度显著变慢了。
+
+
+
+你可以选择使用哪个模型来训练你的物体识别分类器。如果你计划在低算力的设备上使用物体识别(如手机或树莓派),请使用SSD-MobileNet。如果你将在性能优异的笔记本或台式PC上运行,请使用RCNN模型中的一种。
+
+本教程将使用Faster-RCNN-Inception-V2模型。[在此下载模型](http://download.tensorflow.org/models/object_detection/faster_rcnn_inception_v2_coco_2018_01_28.tar.gz)。用文件解压器如WinZip或7-Zip打开下载的faster_rcnn_inception_v2_coco_2018_01_28.tar.gz文件并解压faster_rcnn_inception_v2_coco_2018_01_28文件夹至C:\tensorflow1\models\research\object_detection文件夹(Note:模型日期和版本可能会在未来改变,但应该仍适用于本教程。)
+
+#### 2c. 从GitHub下载本教程仓库
+下载位于本页面的整个仓库(滚动到顶部并点击克隆或下载)并解压所有内容到C:\tensorflow1\models\research\object_detection directory。(你可以覆写已经存在的“README.md”文件)这会建立一个后续使用所需的特定的目录结构。
+
+至此,你的object_detection文件夹下应该如图所示:
+
+
+
+本仓库包含训练“Pinochle Deck”扑克牌识别器所需的图片,注释数据,csv文件,和TFRecords。你可以使用这些图片和数据来试着制作你自己的扑克牌识别器。它还包含用于产生训练数据的Python脚本。也包含用于测试物体识别分类器在图片、视频和网络摄像头上的效果的脚本。你可以忽略doc文件夹和里面的文件,它们只是保存了readme中的图片。
+
+如果你想要训练自己的“Pinochle Deck”卡片识别器,你可以保留所有文件。你可以根据本教程了解每一个文件是如何产生的,然后开始训练。像Step 4中描述的那样,你仍然会需要产生TFRecord文件(train.record和test.record)。
+
+你也可以从这个[链接](https://www.dropbox.com/s/va9ob6wcucusse1/inference_graph.zip?dl=0)下载我训练好的卡牌识别器的冻结了的结论图,并解压到\object_detection\inference_graph。这个结论图能在架构外独立工作,你可以在设置完所有Step 2a - 2f后通过运行Object_detection_image.py(或video或wecam)脚本来测试它。
+
+如果你想要训练你自己的物体识别器,删除以下文件(不要删除文件夹):
+* \object_detection\images\train和 \object_detection\images\test中的所有文件
+* \object_detection\images中的test_labels.csv和train_labels.csv文件
+* \object_detection\training中所有文件
+* \object_detection\inference_graph中所有文件
+
+现在,你已经准备好从头开始训练你自己的物体识别器了。本教程会假设上述列举的文件全部被删除,并阐述如何生成这些文件用于你自己的训练数据。
+
+#### 2d. 设置新的Anaconda虚拟环境
+接下来,我们将在Anaconda中为tensorflow-gpu设置一个新的虚拟环境。从Windows的开始菜单中,寻找Anaconda Prompt,右击它,选择以管理员身份运行。如果Windows要求你是否允许允许它对你的电脑做出改变,请点击确定。
+
+在弹出的命令终端里,通过下列命令创建一个新的名为“tensorflow1”的虚拟环境:
+```
+C:\> conda create -n tensorflow1 pip python=3.5
+```
+然后激活这个环境并升级pip:
+```
+C:\> activate tensorflow1
+
+(tensorflow1) C:\>python -m pip install --upgrade pip
+```
+在环境下安装tensorflow-gpu
+```
+(tensorflow1) C:\> pip install --ignore-installed --upgrade tensorflow-gpu
+```
+(Note:你也可以使用CPU-only版本,但它会跑的更慢。如果你想使用CPU-only版本,请在之前的命令中使用“tensorflow”而非“tensorflow-gpu”。)
+
+安装其他必需的包:
+```
+(tensorflow1) C:\> conda install -c anaconda protobuf
+(tensorflow1) C:\> pip install pillow
+(tensorflow1) C:\> pip install lxml
+(tensorflow1) C:\> pip install Cython
+(tensorflow1) C:\> pip install contextlib2
+(tensorflow1) C:\> pip install jupyter
+(tensorflow1) C:\> pip install matplotlib
+(tensorflow1) C:\> pip install pandas
+(tensorflow1) C:\> pip install opencv-python
+```
+(Note:tensorflow并不需要“pandas”和“opencv-python”包,但在python脚本中它们被用来生成TFRecords和处理图片、视频以及网络摄像头。)
+
+#### 2e. 配置PYTHONPATH环境变量
+必须创建一个PYTHONPATH变量指向\models,\models\research,和\models\research\slim目录。通过以下命令实现(可以从任意目录下):
+```
+(tensorflow1) C:\> set PYTHONPATH=C:\tensorflow1\models;C:\tensorflow1\models\research;C:\tensorflow1\models\research\slim
+```
+(Note: 每次退出“tensorflow1”虚拟环境后,PYTHONPATH变量会被重置,下次进入环境需要重新设置。你可以使用“echo %PYTHONPATH%”查看它是否被设置。)
+
+#### 2f. 编译静态库并运行setup.py
+
+接下来,编译静态库文件,它被Tensorflow用于配置模型和训练参数。不幸的是,Tensorflow的物体识别API[安装页面](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md)s上便捷的protoc编译命令无法在Windows上使用。 在\object_detection\protos路径下的每一个.proto文件都必须被调用。
+
+在Anaconda Command Promt下,更换路径到\models\research:
+```
+(tensorflow1) C:\> cd C:\tensorflow1\models\research
+```
+然后拷贝并黏贴以下命令然后按回车运行:
+```
+protoc --python_out=. .\object_detection\protos\anchor_generator.proto .\object_detection\protos\argmax_matcher.proto .\object_detection\protos\bipartite_matcher.proto .\object_detection\protos\box_coder.proto .\object_detection\protos\box_predictor.proto .\object_detection\protos\eval.proto .\object_detection\protos\faster_rcnn.proto .\object_detection\protos\faster_rcnn_box_coder.proto .\object_detection\protos\grid_anchor_generator.proto .\object_detection\protos\hyperparams.proto .\object_detection\protos\image_resizer.proto .\object_detection\protos\input_reader.proto .\object_detection\protos\losses.proto .\object_detection\protos\matcher.proto .\object_detection\protos\mean_stddev_box_coder.proto .\object_detection\protos\model.proto .\object_detection\protos\optimizer.proto .\object_detection\protos\pipeline.proto .\object_detection\protos\post_processing.proto .\object_detection\protos\preprocessor.proto .\object_detection\protos\region_similarity_calculator.proto .\object_detection\protos\square_box_coder.proto .\object_detection\protos\ssd.proto .\object_detection\protos\ssd_anchor_generator.proto .\object_detection\protos\string_int_label_map.proto .\object_detection\protos\train.proto .\object_detection\protos\keypoint_box_coder.proto .\object_detection\protos\multiscale_anchor_generator.proto .\object_detection\protos\graph_rewriter.proto .\object_detection\protos\calibration.proto .\object_detection\protos\flexible_grid_anchor_generator.proto
+```
+这会为\object_detection\protos路径下的每一个name.proto文件创建一个name_pb2.py文件。
+
+__(Note:TensorFlow时不时在\protos文件夹下添加新的.proto文件。如果你得到如下错误:ImportError: cannot import name 'something_something_pb2',你可能需要将新的.proto文件添加到protoc命令)__
+
+最终,在C:\tensorflow1\models\research路径下运行如下命令:
+```
+(tensorflow1) C:\tensorflow1\models\research> python setup.py build
+(tensorflow1) C:\tensorflow1\models\research> python setup.py install
+```
+
+#### 2g. 测试TensorFlow设置,以核实安装成功
+TensorFlow物体识别API现在已经能使用预训练模型用于物体识别或训练一个新模型。你可以通过jupyter运行object_detection_tutorial.ipynb脚本测试并检验你的安装成功了。在\object_detection路径下,运行以下命令:
+```
+(tensorflow1) C:\tensorflow1\models\research\object_detection> jupyter notebook object_detection_tutorial.ipynb
+```
+这会在你的默认浏览器中打开脚本,并允许你一次运行一节代码。你可以点击上方工具栏的“Run”按钮依次运行每一节。当该节旁的"In[*]"文本中填充了数字(如"In[1]")时,该节运行完毕。
+
+(Note:脚本中部分代码会从GitHub上下载ssd_mobilenet_v1模型,大约74MB。这意味着它将运行一段时间,请耐心等待。)
+
+一旦你已经运行了所有脚本,你应该在页面上节的底部看到两张标注了的图片。如果你观察到了,那么一切都运行正常!如果不,节的底部将会报错。参考[附录](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#appendix-common-errors)中列出的我在安装过程遇到的错误。
+
+__Note:如果你运行个整个Jupyter Notebook而没有报错,但仍然未显示标注了的图片,尝试在object_detection/utils/visualization_utils.py里注释掉大约第29和30行对matplotlib的import。然后再次尝试运行Jupyter Notebook。__
+
+
+
+### 3. 收集并标注图片
+现在TensorFlow物体识别API已经一切就绪,我们需要为它提供用于训练新分类器的图片。
+
+#### 3a. 收集图片
+TensorFlow需要一个目标的上百张图片以训练一个优秀的识别分类器。为了训练一个强大的分类器,训练图片中除了所需的目标应该还要有其他随机物体,并需要有丰富的背景和光照条件。有些图片中的目标物体需要被其他事物部分遮挡、重叠或只露出一半。
+
+对于我的Pinochle Card识别分类器,我有六种不同的检测目标(卡片9、10、jack、queen、king和ace,我不准备识别花色,只识别大小。)我用我的iPhone为每一种卡牌拍摄了大约40张照片,其中包含大量其他非目标物体。然后我拍摄了大约100张多卡牌照片。我知道我想要能够识别重叠的卡牌,所以我确保在很多照片中有被重叠的卡牌。
+
+
+
+你可以使用你的手机拍摄物体的照片或者从Google图片中下载。我建议至少有200张以上的图片集。我使用了311张图片来训练我的卡牌识别器。
+
+务必确保所有照片不会太大。它们都需要小于200KB,并且分辨率不应该大于720x1280。图片越大,训练所需时间越长。你可以使用本仓库中的resizer.py脚本来减少图片的尺寸。
+
+当你有了所需的图片,将20%移动到\object_detection\images\test目录下,将剩余80%移动到\object_detection\images\train目录下。确保\test和\train目录下都有足够图片。
+
+#### 3b. 标注图片
+有趣的部分来了!当收集了所有图片后,是时候在每个图片中标注目标物体了。LabelImg是一个标注图片的强大工具,并且它的GitHub网页上游非常清晰的安装和使用教程。
+
+[LabelImg GitHub link](https://github.com/tzutalin/labelImg)
+
+[LabelImg download link](https://www.dropbox.com/s/tq7zfrcwl44vxan/windows_v1.6.0.zip?dl=1)
+
+下载并安装LabelImg,打开后移动到你的\images\train路径,然后在每张照片的每个目标物体上画框。为\images\test路径下的所有图片重复此步骤。这会耗费一些时间!
+
+
+
+LabelImg为每一张图片保存一个包含标注信息的.xml文件。这些.xml文件会用于生成TFRecords,它是TensorFlow训练器的输入之一。一旦你标注并保存完了所有图片,在\test和\train目录下每张图片将会对应一个.xml文件。
+
+### 4. 生成训练数据
+当标注完图片后,是时候生成输入给TensorFlow训练模块的TFRecords了。本教程使用[Dat Tran's Raccoon Detector dataset](https://github.com/datitran/raccoon_dataset)中的xml_to_csv.py和generate_tfrecords.py脚本,稍作调整以适用于我们自己的目录结构。
+
+首先,image.xml数据将会被用于创建包含所有test和train图片信息的.csv文件。在 \object_detection路径下,在Anaconda Command Prompt运行以下命令:
+```
+(tensorflow1) C:\tensorflow1\models\research\object_detection> python xml_to_csv.py
+```
+这会在\object_detection\images文件夹下生成一个train_labels.csv和test_labels.csv文件。
+
+接着,用文本编辑器打开generate_tfrecord.py。用自己的标注映射图替换从31行开始的标注映射图,每一个目标物体被分配一个ID号码。在Step 5b中,相同的号码分配会被用于配置labelmap.pbtxt文件。
+
+比如,假设你要训练一个分类器以识别篮球、衬衫和鞋子。你将替换generate_tfrecord.py中下列代码:
+```
+# TO-DO replace this with label map
+def class_text_to_int(row_label):
+ if row_label == 'nine':
+ return 1
+ elif row_label == 'ten':
+ return 2
+ elif row_label == 'jack':
+ return 3
+ elif row_label == 'queen':
+ return 4
+ elif row_label == 'king':
+ return 5
+ elif row_label == 'ace':
+ return 6
+ else:
+ None
+```
+变成:
+```
+# TO-DO replace this with label map
+def class_text_to_int(row_label):
+ if row_label == 'basketball':
+ return 1
+ elif row_label == 'shirt':
+ return 2
+ elif row_label == 'shoe':
+ return 3
+ else:
+ None
+```
+然后,在\object_detection路径下运行下列命令生成TFRecord文件:
+```
+python generate_tfrecord.py --csv_input=images\train_labels.csv --image_dir=images\train --output_path=train.record
+python generate_tfrecord.py --csv_input=images\test_labels.csv --image_dir=images\test --output_path=test.record
+```
+这会在\object_detection路径下生成train.record和test.record文件。它们将用于训练物体识别分类器。
+
+### 5. 生成标注映射图和配置训练
+开始训练前的最后一步是创建一个标注映射并编辑训练配置文件。
+
+#### 5a. 标注映射图
+标注映射图通过定义一个类名到类ID的映射来告诉训练器每一个物体是什么。在 C:\tensorflow1\models\research\object_detection\training文件夹下使用任意文本编辑器来新建一个文件并保存为labelmap.pbtxt。(确保文件的后缀是.pbtxt而不是.txt!)在文本编辑器中,复制或输入以下格式的标注映射。(以下示例为我的Pinochle Deck卡牌识别器所用的标注映射图。):
+```
+item {
+ id: 1
+ name: 'nine'
+}
+
+item {
+ id: 2
+ name: 'ten'
+}
+
+item {
+ id: 3
+ name: 'jack'
+}
+
+item {
+ id: 4
+ name: 'queen'
+}
+
+item {
+ id: 5
+ name: 'king'
+}
+
+item {
+ id: 6
+ name: 'ace'
+}
+```
+标注映射图中的ID号需要和generate_tfrecord.py中定义的一致。对于Step 4中提到的篮球、衬衫和鞋子的识别器例子,其labelmap.pbtxt文件应如下所示:
+```
+item {
+ id: 1
+ name: 'basketball'
+}
+
+item {
+ id: 2
+ name: 'shirt'
+}
+
+item {
+ id: 3
+ name: 'shoe'
+}
+```
+
+#### 5b. 配置训练
+最后,必须配置物体识别训练管道。它定义了哪些模型和参数将被用于训练。这是开始训练前的最后一步!
+
+导航至C:\tensorflow1\models\research\object_detection\samples\configs并拷贝faster_rcnn_inception_v2_pets.config文件到\object_detection\training路径下。然后用文本编辑器打开文件。需要对其做几处修改,主要修改类别和样本的数目,并添加文件路径到训练数据。
+
+在faster_rcnn_inception_v2_pets.config文件中做如下几处修改。Note:路径必须使用单个正斜杠(/),而不是反斜杠(\\),否则在尝试训练模型时,TensorFlow会给出路径错误。同样,路径必须使用双引号(")而非单引号(')。
+* Line 9. 修改num_classes为你想要识别的物体的类别数目。对于先前的篮球、衬衫和鞋子识别器,num_classes将会是3。
+* Line 106. 修改 fine_tune_checkpoint为:
+ * fine_tune_checkpoint : "C:/tensorflow1/models/research/object_detection/faster_rcnn_inception_v2_coco_2018_01_28/model.ckpt"
+* Lines 123 and 125. 在train_input_reader模块中,修改input_path和label_map_path为:
+ * input_path : "C:/tensorflow1/models/research/object_detection/train.record"
+ * label_map_path: "C:/tensorflow1/models/research/object_detection/training/labelmap.pbtxt"
+* Lines 130. 修改num_examples为你在\images\test路径下有的图片数目。
+* Lines 135和137. 在eval_input_reader模块,修改input_path和label_map_path为:
+ * input_path : "C:/tensorflow1/models/research/object_detection/test.record"
+ * label_map_path: "C:/tensorflow1/models/research/object_detection/training/labelmap.pbtxt"
+
+修改完毕后保存文件。That's it!一切已经配置完毕!
+
+### 6. 开始训练
+__UPDATE 9/26/18:__ 在1.9版本中,TensorFlow移除了“train.py”文件并用“model_main.py”文件替换了它。我目前还没能用model_mian.py成功运行(我得到与pycocotools有关的错误)。幸运的是,train.py文件仍在/object_detection/legacy文件夹下能找到。只要将train.py从/object_detection/legacy文件夹下移动到/object_detection文件夹下然后继续下列步骤。
+
+Here we go!在\object_detection路径下,运行下列命令开始训练:
+```
+python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
+```
+如果一切设置正确,TensorFlow将会初始化训练。在正式开始训练前,初始化会占用30秒。当训练开始,看起来将会是这样子:
+
+
+
+每一步训练会报告损失值。它会随着训练过程由高变得越来越低。对与我对Faster-RCNN-Inception-V2 model的训练,损失值由约3.0快速下降到0.8以下。我建议允许你的模型训练直到损失值保持在0.05以下,这大概需要40,000步,或2小时(取决于你的CPU和GPU算力有多强)。Note:如果使用不同的模型,损失值的数值会不同。MobileNet—SSD的损失值起始于大约20,并应该训练至保持在2以下。
+
+你可以通过TensorBoard观察训练过程。打开一个新的Anaconda Prompt窗口,激活tensorflow1环境,修改路径至C:\tensorflow1\models\research\object_detection,并运行以下命令:
+```
+(tensorflow1) C:\tensorflow1\models\research\object_detection>tensorboard --logdir=training
+```
+这将在本地创建一个端口为6006的网页,可在浏览器上浏览。TensorBoard网页提供展示训练如何进行的信息和图表。一个重要的图标是损失图表,它展示分类器随时间变化的全局损失值。
+
+
+
+训练过程每过大约五分钟会周期性保存检查点。你可以在Command Prompt窗口通过Ctrl+C终止训练。我一般等到一个检查点被保存后才终止训练。你可以终止训练并在之后重启它,它会从最后保存的检查点开始继续训练。最高编号的检查点将会用于生成冻结结论图。
+
+### 7. 导出结论图
+现在,训练已经结束了,最后一步是生成冻结结论图(.pb文件)。在\object_detection路径下,运行下列命令,其中"model.ckpt-XXXX"中的"XXXX"需要被替换成training文件夹下最高编号的.ckpt文件:
+```
+python export_inference_graph.py --input_type image_tensor --pipeline_config_path training/faster_rcnn_inception_v2_pets.config --trained_checkpoint_prefix training/model.ckpt-XXXX --output_directory inference_graph
+```
+这会在\object_detection\inference_graph文件夹下生成一个frozen_inference_graph.pb文件。这个.pb文件包含物体识别分类器。
+
+### 8. 使用你新训练的物体识别分类器!
+这个物体识别分类器已经准备就绪!我已经写好了Python脚本以测试它在图片、视频和网络摄像头上的表现。
+
+在运行Python脚本前,你需要在脚本中修改NUM_CLASSES变量为你想检测的种类数目。(对于我的Pinochle卡牌识别器,我想检测六种卡牌,因此NUM_CLASSES = 6。)
+
+为了测试你的物体识别器,将一张单物体或多物体的照片移动到\object_detection文件夹下,并修改Object_detection_image.py中的IMAGE_NAME变量为图片文件名称。另外,你也可以使用物体的视频(使用Object_detection_video.py),或连接一个USB摄像头并对准物体(使用Object_detection_webcam.py)。
+
+为了运行上述任一脚本,在Anaconda Command Prompt(“tensorflow1”环境激活条件下)中输入“idle”并按回车。这将打开IDLE,在此你可以打开任何Python脚本并运行它们。
+
+如果一切运行正确,物体识别器会初始化10秒然后显示一个展示了任何它在图片中检测到的物体的窗口!
+
+
+
+如果你遇到错误,请检查附录:它包含了一系列我设置我的物体识别分类器时遇到的错误。你也可以尝试google一下错误。通常在Stack Exchange或GitHub上的TensorFlow's Issues中有有用的信息。
+
+## 附录:常见错误
+---
+TensorFlow对象检测API似乎是在基于Linux的操作系统上开发的,文档中给出的大多数指导都是针对Linux OS的。试图让Linux开发的软件库在Windows上运行会具有挑战性。在尝试设置tensorflow-gpu以在Windows 10上训练对象检测分类器时,我遇到了很多麻烦。本附录列出了我遇到的错误及其解决方案。
+
+1. ModuleNotFoundError: No module named 'deployment' or No module named 'nets'
+
+这个错误会出现在你尝试运行object_detection_tutorial.ipynb或train.py但你没将PATH和PYTHONPATH环境变量设置正确时。关闭Anaconda Command Prompt窗口退出虚拟环境并重新打开。然后输入“activate tensorflow1”重新激活环境,并输入Step 2e中给出的命令。
+
+你可以使用“echo %PATH%”和“echo %PYTHONPATH%”来确认环境变量是否设置正确。
+
+同样,确保你在\models\research路径下运行下列命令:
+```
+setup.py build
+setup.py install
+```
+
+2. ImportError: cannot import name 'preprocessor_pb2'
+
+ImportError: cannot import name 'string_int_label_map_pb2'
+(或和pb2文件相关的相似错误)
+
+这个错误出现在protobuf文件(在此例中,preprocessor.proto)未被编译。重新运行Step 2f中给出的protoc命令。检查\object_detection\protos文件夹,确保所有name_pb2.py文件都对应有一个name.proto文件。
+
+3. object_detection/protos/.proto: No such file or directory
+这个错误出现在你尝试运行TensorFlow物体识别API安装页面的
+```
+“protoc object_detection/protos/*.proto --python_out=.”
+```
+命令时。抱歉,它无法在Windows上运行!复制和黏贴Step 2f中给出的完整命令。这应该有更优雅的方式来实现它,但我不知道如何实现。
+
+4. Unsuccessful TensorSliceReader constructor: Failed to get "file path" … The filename, directory name, or volume label syntax is incorrect.
+
+这个错误出现在当训练配置文件(faster_rcnn_inception_v2_pets.config或其他)的文件路径没有使用但正斜杠而用了反斜杠时。打开.config文件并确保所有文件路径为如下格式:
+```
+“C:/path/to/model.file”
+```
+
+5. ValueError: Tried to convert 't' to a tensor and failed. Error: Argument must be a dense tensor: range(0, 3) - got shape [3], but wanted [].
+
+这个问题源自models/research/object_detection/utils/learning_schedules.py
+目前它是
+```
+rate_index = tf.reduce_max(tf.where(tf.greater_equal(global_step, boundaries),
+ range(num_boundaries),
+ [0] * num_boundaries))s
+```
+用list()将range()像这样包起来:
+```
+rate_index = tf.reduce_max(tf.where(tf.greater_equal(global_step, boundaries),
+ list(range(num_boundaries)),
+ [0] * num_boundaries))
+```
+[Ref: Tensorflow Issue#3705](https://github.com/tensorflow/models/issues/3705#issuecomment-375563179)
+
+6. ImportError: DLL load failed: The specified procedure could not be found. (or other DLL-related errors)
+
+这个错误出现是因为你安装的CUDA和cuDNN版本和你使用的TensorFlow版本不兼容。最简单的解决这个错误的方式是使用Anaconda的cudatoolkit包而不是手动安装CUDA和cuDNN。如果你得到了这个错误,尝试新建一个Anaconda虚拟环境:
+```
+conda create -n tensorflow2 pip python=3.5
+```
+然后,当进入这个环境后,使用CONDA而非PIP安装TensorFlow:
+```
+conda install tensorflow-gpu
+```
+然后从Step 2重新开始后续步骤(但你可以跳过Step 2d中安装TensorFlow的部分)。
+
+7. 在Step 2g中,Jupyter Notebook运行未出错,但最终没有图片显示
+
+如果你运行整个Jupyter Notebook而未得到任何报错,但标注了的图片还是没有显示,尝试:
+进入object_detection/utils/visualization_utils.py并注释掉大约第29和30行对matplotlib的import。然后再次尝试运行Jupyter Notebook。(visualization_utils.py脚本经常被修改,因此可能并不是在line 29和30。)
+
+## 译者注:
+目前TensorFlow已经移除了v1.5版本,译者使用v1.15版本成功完成本教程的所有步骤,但未能用v2.0以上版本成功实现。
diff --git a/translate/README_Korean.md b/translate/README_Korean.md
new file mode 100644
index 00000000..d63ad062
--- /dev/null
+++ b/translate/README_Korean.md
@@ -0,0 +1,501 @@
+
+# Windows 10(GPU) 에서 TensorFlow를 사용하여 다중 사물 인식 학습을 하는 방법
+
+## 간단한 요약
+*마지막 업데이트: 9/26/2018 TensorFlow v1.10 사용*
+
+*변환된 점: train.py 파일이 현재 /object_detection/legacy 폴더에 있으며 학습 전에는 반드시 메인 폴더로 옮겨야 합니다.*
+
+이 Repository 는 Windows 10, 8 또는 7 에서 TensorFlow의 Object Detection API를 사용하여 많은 물체가 있는 환경에서 사물 인식 분류를 학습하기 위한 것입니다.( 조금만 바꾼다면 Linux기반의 운영체제에서도 돌아갑니다.)
+기본적으로 TensorFlow 1.5 버전에서 작성되었으며, 더 높은 버전에서도 잘 작동 될 것입니다.(아마도?)
+
+이 튜토리얼을 따라 Yotube 비디오를 만들었습니다. 튜토리얼과 비디오 사이의 다른 점은 TensorFlow 버전이 업데이트 되면서 발생한 것이다.
+(잘 보면서 따라 하면 됩니다.)
+
+**비디오랑 메뉴얼이랑 다르면 메뉴얼을 따라서 해주시면 되겠습니다!**
+
+[](https://www.youtube.com/watch?v=Rgpfk6eYxJA)
+
+이 readme는 커스텀 사물 인식 분류를 하기위해서 차례대로 따라 할 수 있게 표시 했습니다.:
+1. [TensorFlow-GPU 설치방법](https://github.com/cocopambag/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#1-tensorflow-gpu-15--설치하기)
+2. [Anaconda 가상 환경과 사물 인식 경로 설정](https://github.com/cocopambag/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#2-tensorflow-폴더와-anaconda-가상-환경-설정)
+3. [사진(사물) 수집 및 라벨링](https://github.com/cocopambag/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#3-사진-수집-및-라벨링)
+4. [학습 데이터 실행방법](https://github.com/cocopambag/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#4-학습-데이터-생성)
+5. [label map 생성 및 학습 구성](https://github.com/cocopambag/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#5-label-map-생성-및-학습-준비)
+6. [학습](https://github.com/cocopambag/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#6-학습-실행)
+7. [학습된 그래프 추출](https://github.com/cocopambag/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#7-inference-graph-추출하기)
+8. [학습된 사물 인식 그래프를 사용하고 테스트해보기](https://github.com/cocopambag/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#8-새로-학습된-사물-인식-분류기-사용하기!)
+
+[부록: 에러 발생시](https://github.com/cocopambag/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#appendix--공통적인-에러)
+
+이 repository는 9,10,잭,퀸,킹 그리고 에이스를 정확하게 구별할 수 있는 "Pinochle Deck" 카드 분류 학습에 필요한 모든 파일을 제공합니다. 본 튜터리얼은 사용자가 자신의 파일로 학습을 진행하고 싶을때 어떻게 파일들을 정리해야하는지 알려 줍니다. 사진, 비디오 또는 웹캠으로 학습이 잘 됐는지 파이썬 코드로 실행할 수 있습니다.
+
+
+
+
+
+## 소개
+이 튜토리얼의 목적은 프로젝트를 시작하기전에 많은 사물에서 자신의 CNN 사물 인식 분류를 학습시키는지에 대해 설명하기 위함이다. 튜터리얼이 끝났을때, 사진,비디오 또는 웹캠으로 특정한 물체를 인식하고 boxing(박스를 그리는 것)을 하는 프로그램을 만들 수 있다.
+
+TensorFlow의 사물 인식 API를 사용하여 하나의 물체를 구별하는 훈련법에 대한 좋고 많은 튜터리얼들이 있다. 그러나, 보통 Linux OS 환경을 사용해야 할 것이다. 학습을 위해 좋은 그래픽 카드를 설치한 성능 좋은 컴퓨터에 Linux 설치하는게 고민되면 이거 따라하시죵. 사물 인식 API가 Linux 기반 OS에서 개발되어야 하는 것 처럼 보일 꺼에요. WIndows 기반에서 TensorFlow를 학습 환경 설정을 위해서, Linux에서 작동하는 명령어 대신에 사용할 방법들이 있다. 또, 튜토리얼은 단 한 가지가 아니라 여러 사물을 인식하는 분류 학습에 대한 방법을 제공합니다.
+
+튜토리얼은 windows 10 기반이지만 7이나 8에서도 잘 작동할 것입니다. Linux OS에서도 잘 작동할텐데, 대신에 명령어를 실행할 환경병수를 정확하게 바꾸면 됩니다.
+( 추후에 Linux에서 실행하는 것도 올리겠습니다. - 번역자)
+
+TensorFlow-GPU는 학습을 진행하는 동안 PC의 그래픽 카드가 제공하는 자원을 사용할 수 있게 합니다. 경험에 따르면, 일반적인 TensorFlow 대신에 TensorFlow-GPU를 사용하는 것이 학습 시간이 8분의 1로 줄어듭니다.(24시간이 3시간으로 변하는 마법이~). 일반적인 TensorFlow를 사용할 수 있지만 시간이 오래 걸릴 것입니다. 일반적인 TensorFlow를 사용하고 싶다면, 1단계에 있는 CUDA 와 cuDNN를 설치할 필요가 없습니다. 튜토리얼을 진행하면서 TensorFlow-GPU v1.5를 사용했으며, 더 높은 버전을 사용해도 잘 될 것입니다.
+
+
+## 단계들
+### 1. TensorFlow-GPU 1.5 설치하기
+
+(TensorFlow-GPU 1.5가 설치되어 있으면 통과해 주세요~)
+Mark jay의 Youtube 영상의 지시들을 따라서 TensorFlow-GPU를 설치해 주세요 [Mark jay의 유튜브](https://www.youtube.com/watch?v=RplXYjxgZbw).
+
+이 영상은 TensorFlow-GPU 1.4를 위해 만들어졌습니다. 따라서 "pip install --upgrade tensorflow-gpu" 명령어는 1.5 버전을 자동적으로 다운로드할 것입니다.(물론, 지금은 더 높은 버전이겠죵) CUDA 9.0과 cuDNN 7.0을 설치해주세요.(영상에서 CUDA 8.0과 cuDNN v7.0 설치하는 것을 따라하지 마세용), 왜냐하면 TensorFlow-GPU 1.5버전을 위한 버전이라서요. TensorFlow 버전이 높아지면 거기에 따라서 CUDA랑 cuDNN도 최신 버전으로 다운로드하세요
+
+이 영상에서 설치하라는 Anaconda Python 3.6버전을 설치하세요, Anaconda 가상 환경을 사용하기 때문입니다. (저도 이때 처음 써봤어요!!)
+
+Linux 같으 다른 OS에서 설치하는 법같이 자세한 사항은 옆의 TensorFlow's website [TensorFlow's website](https://www.tensorflow.org/install/install_windows)에 접속해주세요 옆의 사물 인식 repositoy [object detection repository](https://github.com/tensorflow/models/tree/master/research/object_detection) 또한 설치 방법 [installation instructions](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md)을 포함하고 있습니다
+
+### 2. TensorFlow 폴더와 Anaconda 가상 환경 설정
+TensorFlow 사물 인식 API는 GitHub에서 제공하는데, 특정한 디렉토리(경로) 구조를 사용합니다. 또한, 사물 인식 모델을 학습하고 설정하기 위해 추가적인 Python 패키지, 특정한 PATH와 PYTHONPATH 변수 추가 그리고 몇가지 설치 명령어가 필요합니다.
+
+튜토리얼에서 이부분은 요구되는 모든 것을 설치합니다. 설치를 잘못하면 오류가 많이 발생하기 때문에 매우 신중하게 해야하고 지시사항이랑 거의 똑같게 해야합니다. (정말입니다.. 여기서 실수한번해서 처음부터 다시 했습니다^^)
+
+#### 2a. TensorFlow Object Detection API GitHub에서 repository 다운로드하기
+C: 에서 "tensorflow1"이라는 폴더를 생성하세요. TensorFlow 물체 인식 프레임워크 뿐만 아니라 학습 이미지, 학습데이터, 학습 분류기, 구성 파일, 그리고 사물 인식 분류에 필요한 모든 것이 포함 될 것입니다.
+
+"Clone or Download" 버튼 과 zip 파일을 다운로드를 클릭해서 https://github.com/tensorflow/models 에 있는 TensorFlow 사물 인식 repository 전체를 다운로드하세요. zip 파일을 열고 "models-master" 폴더를 C:\tensorflow1 폴더로 이동시키고 "models" 라는 폴더명으로 바꾸세요.
+(Note : 튜토리얼은 [GitHub commit](https://github.com/tensorflow/models/tree/079d67d9a0b3407e8d074a200780f3835413ef99)을 사용했습니다. 만약 어느 부분이 안된다면, 최신 버전을 다운 받아서 그럴 것입니다.)
+
+#### 2b. TensorFlow의 model zoo 에 있는 Faster-RCNN-Inception-V2-COCO 모델 다운로드 하기
+TensorFlow는 [model zoo](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md) 라는 것에서 몇개의 사물 인식 모델을 제공합니다. ( 특정한 신경망 구족로 미리 학습된 분류기 입니다.) 어떤 모델(SSD-MobileNet 같은 모델) 은 정확도는 낮지만 빠른 탐색기능을 가지고 있으며, 반면에 어떤 모델( Faster-RCNN 같은 모델) 은 정확도는 높지만 느린 탐색 기능을 가지고 있습니다. 처음에는 SSD-MobileNet-V1 모델을 사용했지만, 카드들을 인식 시키는데에 적합하지 않았습니다. Faster-RCNN-Inception-V2로 재학습 했으며 눈에 보일정도로 느렸지만, 제법 잘 작동했습니다.
+(밑에는 예제 사진 입니다.)
+
+
+
+
+
+학습을 하는데 적합한 모델을 찾아서 적용하세요. 연산능력이 낮은 기기(스마트 폰이나 라즈베리 파이같은) 에서 사물 인식을 한다면, SDD-MobileNet 모델을 사용하세요. 만약 노트북이나 데스크탑을 사용한다면 RCNN 모델을 사용하세요.
+(저는 이걸 안읽고 라즈베리에 적용시키려다가 망했습니다 ㅠㅠ...)
+
+이 튜토리얼은 Faster-RCNN-Inception-V2 모델을 사용할 것입니다. [여기서 다운로드 받으세요](http://download.tensorflow.org/models/object_detection/faster_rcnn_inception_v2_coco_2018_01_28.tar.gz)
+faster_rcnn_inception_v2_coco_2018_01_28.tar.gz을 다운로드 받고 zip을 해제하고 faster_rcnn_inception_v2_coco_2018_01_28 를 C:\tensorflow1\models\research\object_detection 폴더로 옮기세요.
+(Note: 모델 날짜와 버전이 바뀔 수 있지만, 튜토리얼에서 잘 작동할 것입니다.)
+
+#### 2c. GitHub에서 튜토리얼의 repository를 다운로드 하세요
+이 페이지에 있는 전체 repository(위에 보시면 Clone 또는 Download가 있습니다.) 를 다운로드하고 해제한 뒤에 C:\tensorflow1\models\research\object_detection 폴더로 옮기세요.
+("README.md"파일을 수정할 수 있습니다.
+이 폴더에서 튜토리얼 대부분을 사용할 것입니다.
+
+여기서, object_detectio 폴더는 밑에와 같이 보여야 합니다.
+
+
+
+
+
+이 repository는 "pinochle Deck" 카드 분류기 학습에 필요한 이미지, 분류 데이터, csv파일들, 그리고 TFRecord들이 포함되어 있습니다.이 이미지들과 데이터들을 사용하여 자신만의 Pinochle 카드 분류기 만들기를 연습할 수 있습니다. 또한, 학습 데이터를 작동시키는 Python 코드도 포함 되어 있습니다. 이미지들, 영상들 또는 웹캠으로 사물 인식을 테스트 할 수 잇는 코드를 포합하고 있습니다. 이 파일에서 doc 폴더와 안의 내용을 무시해도 됩니다.그것들은 readme에서 사용된 이미지들을 포함하고 있습니다.
+
+만약 나만의 "Pinochle Deck" 카드 분류기 학습을 연습하고 싶다면, 모든 파일들을 그대로 두면 된다. 각 파일들이 작동되는 법과 학습하는 것을 보고 싶다면 튜토리얼을 따라하면 된다. Step4에 표시된 것 처럼 TFRecord 파일들(train.record 와 test.record)을 작동하는 것이다.
+
+Pinochle Deck 카드 분류기를 위한 frozen inference graph를 [Dropbox](https://www.dropbox.com/s/va9ob6wcucusse1/inference_graph.zip?dl=0)에서 다운로드 해야하고 object_detection\inference_graph를 풀어야한다. 이 inference graph는 boxing으로 동작할 것이다. 2a에서 2f까지 모든 지시 사항은 Object_detection_image.py(또는 영상 또는 웹캠) 이 동작하면 제대로 한 것이다.
+
+만약 커스텀 사물 인식 분류기를 학습하고 싶다면 , 밑의 파일들을 삭제해야 합니다.(폴더 삭제xxxx) :
+- \object_detection\images\train 과 \object_detection\images\test 에 있는 모든 파일들
+- \object_detection\images 안에 있는 "test_labels.csv" 과 "train_labels.csv" 파일들
+- \object_detection\training의 모든 파일들
+- \object_detection\inference_graph의 모든 파일들
+
+Now, you are ready to start from scratch in training your own object detector. This tutorial will assume that all the files listed above were deleted, and will go on to explain how to generate the files for your own training dataset.
+
+#### 2d. 새로운 Anaconda 가상 환경 설정
+다음으로, tensorflow-gpu를 위해 anaconda 가상 환경을 설정해야 합니다. Windows의 시작 메뉴에서 Anaconda Prompt utility를 찾고 마우스 오른쪽 버튼을 클릭하고, "관리자로 실행"을 클릭하세요. Windows에서 정말로 실행할 것인지 물어본다면, "네"를 누르세용 ( 큰일 안납니다)
+
+명령창을 키고, 밑의 명령어를 따라서 "tensorflow1"라는 새로운 가상환경을 생성하세요 (cmd 창 아닙니다. anaconda의 명령창입니다. ) :
+
+```
+C:\> conda create -n tensorflow1 pip python=3.5
+```
+
+그런 다음, 환경을 활성화 합니다:
+
+```
+C:\> activate tensorflow1
+```
+
+이 환경에서 tensorflow-gpu를 설치합니다::
+
+```
+(tensorflow1) C:\> pip install --ignore-installed --upgrade tensorflow-gpu
+```
+
+밑의 명령어들로 필수적인 패키지들을 설치합니다 :
+
+```
+(tensorflow1) C:\> conda install -c anaconda protobuf
+(tensorflow1) C:\> pip install pillow
+(tensorflow1) C:\> pip install lxml
+(tensorflow1) C:\> pip install Cython
+(tensorflow1) C:\> pip install jupyter
+(tensorflow1) C:\> pip install matplotlib
+(tensorflow1) C:\> pip install pandas
+(tensorflow1) C:\> pip install opencv-python
+```
+
+(Note: "pandas" 와 "opencv-python" 패키지들은 TensorFlow에 필요한 것은 아니지만, 나중에 TFRecord들과 이미지, 영상, 웹캠을 작동하는 파이선 코드에 사용됩니다.)
+
+#### 2e.PYTHONPATH 환경 변수 설정
+PYTHONPATH 변수에 \models, \models\research, 그리고 \models\research\slim 경로를 반드시 설정해야 합니다. 밑에 있는 명령어를 실행하세요 (어떤 폴더에서든 상관 없습니다.) :
+
+```
+(tensorflow1) C:\> set PYTHONPATH=C:\tensorflow1\models;C:\tensorflow1\models\research;C:\tensorflow1\models\research\slim
+```
+
+(Note: PYTHONPATH는 Anaconda 실행창을 다시 킬 때마다 설정해줘야 합니다.)
+
+#### 2f. Protobuf을 컴파일 및 setup.py을 실행하기
+다음으로, 모델과 학습에 필요한 파라미터 설정에 사용하기 위해서 Protobuf 파일들을 컴파일 합니다. Windows에서는 짧은 명령어로 작동하지 않습니다... [installation page](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md). \object_detection\protos에 있는모든 .proto 파일을 명령어로 각각 실행해야 합니다.
+
+Anaconda 명령창에서, \models\research로 옮기고 밑의 명령어를 복사 붙혀넣기하고 실행하세요
+
+```
+protoc --python_out=. .\object_detection\protos\anchor_generator.proto .\object_detection\protos\argmax_matcher.proto .\object_detection\protos\bipartite_matcher.proto .\object_detection\protos\box_coder.proto .\object_detection\protos\box_predictor.proto .\object_detection\protos\eval.proto .\object_detection\protos\faster_rcnn.proto .\object_detection\protos\faster_rcnn_box_coder.proto .\object_detection\protos\grid_anchor_generator.proto .\object_detection\protos\hyperparams.proto .\object_detection\protos\image_resizer.proto .\object_detection\protos\input_reader.proto .\object_detection\protos\losses.proto .\object_detection\protos\matcher.proto .\object_detection\protos\mean_stddev_box_coder.proto .\object_detection\protos\model.proto .\object_detection\protos\optimizer.proto .\object_detection\protos\pipeline.proto .\object_detection\protos\post_processing.proto .\object_detection\protos\preprocessor.proto .\object_detection\protos\region_similarity_calculator.proto .\object_detection\protos\square_box_coder.proto .\object_detection\protos\ssd.proto .\object_detection\protos\ssd_anchor_generator.proto .\object_detection\protos\string_int_label_map.proto .\object_detection\protos\train.proto .\object_detection\protos\keypoint_box_coder.proto .\object_detection\protos\multiscale_anchor_generator.proto .\object_detection\protos\graph_rewriter.proto
+```
+
+ \object_detection\protos 폴더에 모든 "name.proto"에 해당하는 "name_pb2.py" 파일이 생성 될 것입니다.
+
+**(Note: 가끔씩 TensorFlow에서 새로운 .proto 파일을 \protos 폴더에 추가할 것입니다. 만약에 ImportError: cannot import name 'somethin_something_pb2' 에러가 발생한다면, protoc 명령창에 새로운 .proto 파일들을 입력해줘야 합니다.)**
+
+마지막으로, C:\tensorflow1\models\research 에서 밑의 명령어를 실행해 주세요 :
+
+```
+(tensorflow1) C:\tensorflow1\models\research> python setup.py build
+(tensorflow1) C:\tensorflow1\models\research> python setup.py install
+```
+
+#### 2g. TensorFlow 설치가 잘 되었는지 테스트 하기
+TensorFlow Obkect Detection API는 미리 학습된 모델을 사용하거나 새로 학습을 시킬 수 있다. 모델을 테스트 할 수 있는데 Jupyter를 통해서 object_detection_tutorial.ipynb 코드를 실행해서 볼 수 있다. Object_detection 폴더로 가서 밑의 명령어를 실행하면 된다 :
+
+
+```
+(tensorflow1) C:\tensorflow1\models\research\object_detection> jupyter notebook object_detection_tutorial.ipynb
+```
+
+다르 웹 브라우저를 열고 차례대로 실행 시킬 수 있는 화면이 나올 것 입니다. 위쪽에 있는 툴바에서 "Run" 버튼을 클릭해서 각 구역을 차례로 실행할 수 있습니다. “In [ * ]”는 그 구역이 완료되었고 다음 구역으로 갈 수 있는 표시이다.(e.g. “In [1]” )
+
+(Note: ssd_mobilenet_v1 모델은 약 74MB가 필요합니다. 이 모델은 시간이걸리니 조금 기다려 봅니다.)
+
+모든 코드를 차례대로 실행하면, 한 페이지에서 두 개의 라벨링된 이미지를 볼 수 있습니다. 이미지가 잘 나온다면 완벽하게 실행한 것입니다! 그렇지 않다면, 어떤 에러가 뜰 것입니다. 오류가 발생한다면 [부가설명](https://github.com/cocopambag/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#Appendix:--공통적인-에러) 을 읽어 주세요.
+
+
+
+
+
+
+### 3. 사진 수집 및 라벨링
+TensorFlow Object Detection API 설치가 완료 되었고 사용할 준비가 되었습니다. 새로운 분류기를 학습하기 위해서 이미지 파일이 필요합니다.
+
+
+#### 3a. 사진 수집
+TensorFlow는 좋은 분류기를 학습하기 위해서는 백여장의 사진이 필요합니다. 좋은 분류기를 학습하기 위해서, 원하는 사물이 포함된 사진에 여러가지 물체가 있어야 하며, 다양한 배경과 조명에서 수집 해야합니다. 어떤 사진은 원하는 사물이 반쯤 가려져 있거나 다른 사물과 겹쳐져 있어야 합니다.
+
+PinochleCard 분류기를 위해서, 6개의 다른 모양을 사용했습니다( 9, 10, 잭, 퀸, 킹, 그리고 에이스 카드). 저는 iPhone으롤 각 모양의 사진 약 40장을 사용했으며, 다양한 물체들과 같이 있는 사진을 사용했습니다. 그런 후에, 약 100장의 섞여 있는 카드 사진을 사용했습니다. 다른 카드나 사물이랑 섞여 있을 때도 인식하고 싶어서, 겹쳐져있거나 섞인 사진을 사용했습니다.
+
+
+
+
+
+
+직접 사진을 찍거나 구글 이미지 검색에서 다운로드하여 사용할 수 도 있습니다. 최소한 200장의 사진을 사용하는 것을 추천합니다. 저는 311장의 사진을 사용했습니다.
+
+사진이 너무 크면 안됩니다. 200KB보다 적어야 하며, 720x1280 크기보다는 작아야 합니다. 이미지가 너 무크면 학습 시간이 길어집니다. repository에 있는 resizer.py를 사용하면 크기를 재조정할 수 있습니다.
+
+사진을 다 모은 뒤에, 20%를 \object_detection\images\test 폴더로, 80%를 \object_detection\images\train 폴더로 옮깁니다. test 그리고\train 폴더에 다양한 사진을 넣어야 합니다.
+
+#### 3b. 사진 라벨링( 라벨 어노테이션 )
+자 제일 재밌는 부분입니다! ( 전.. 제일 노가다라고 생각합니다. ) 모든 사진들을 모은 뒤에, 사진들에 라벨을 달아주는 부분입니다. LabelImg 는 사진을 라벨링하는 좋은 툴이며, GitHub 페이지에 설치와 사용법이 자세히 설명되어 있습니다.
+
+[LabelImg GitHub link](https://github.com/tzutalin/labelImg)
+
+[LabelImg download link](https://www.dropbox.com/s/tq7zfrcwl44vxan/windows_v1.6.0.zip?dl=1)
+
+LabeImg를 서칠한 뒤, \images\train 폴더로 경로를 설정하고, 각 사진에서 원하는 사물에 박스를 그리면 됩니다. ( 노가다 입니다 노가다...) \images\test에 있는 사진들도 반복해서 진행합니다. 끝나면 밑의 사진처럼 되있을 것입니다 !
+
+
+
+
+
+LabelImg 는 각 사진에서 분류 데이터를 포함한 xml 파일로 저장합니다. 이 xml 파일들은 TensorFlow 학습 입력들 중 하나 인 TFRecords에서 사용될 것입니다. 각 이미지를 분류하고 저장한 후에, 각 \test 와 \train 경로에 각 이미지마다 하나의 xml 파일이 있을 것입니다.
+
+또한, sizeChecker.py를 실행해서 박스를친 부분이 학습에 사용될 데이터로 적절한지 체크합니다.
+밑의 명령어를 실행 하세요.
+
+```
+(tensorflow1) C:\tensorflow1\models\research\object_detection> python sizeChecker.py --move
+```
+
+### 4. 학습 데이터 생성
+사진들이 라벨링이 끝난 후, TensorFlow 학습 모델의 입력 데이터로 사용될 TFRecords를 생성하는 부분 입니다. 이 튜토리얼에서는 [Dat Tran’s Raccoon Detector dataset](https://github.com/datitran/raccoon_dataset)의 xml_to_csv.py 그리고 generate_tfrecord.py 코드를 사용하며, 파일 경로를 조금 수정할 것입니다.
+
+먼저, 모든 train과 test 폴더에 있는 이미지들이 포함된 xml 데이터를 csv 파일로 바꿀 것입니다. \object_detection 폴더에서, anaconda 명령창에서 밑의 명령어를 실행하세요 :
+
+```
+(tensorflow1) C:\tensorflow1\models\research\object_detection> python xml_to_csv.py
+```
+ \object_detection\images 폴더에 train_labels.csv 과 test_labels.csv 가 생성될 것입니다.
+
+그 후에, generate_tfrecord.py를 텍스트 편집기로 열어봅니다. 31번째 줄에 각 사물에 맞는 ID 번호가 적혀진 라벨 맵을 바꿔야 합니다. 단계 5b에 있는 labelmap.pbtxt 파일과 같은 갯수여야 합니다.
+
+예를들어, 9, 10, 잭, 퀸, 킹, 에이스에 대한 분류기를 학습하는 예제는 밑에 generate_tfrecord.py로 바꿔야 합니다:
+
+
+
+# TO-DO labelmap 수정
+```
+def class_text_to_int(row_label):
+ if row_label == 'nine':
+ return 1
+ elif row_label == 'ten':
+ return 2
+ elif row_label == 'jack':
+ return 3
+ elif row_label == 'queen':
+ return 4
+ elif row_label == 'king':
+ return 5
+ elif row_label == 'ace':
+ return 6
+ else:
+ return None
+```
+밑은 농구공, 셔츠, 신발에 관한 것:
+
+
+# TO-DO replace this with label map
+
+```
+def class_text_to_int(row_label):
+ if row_label == 'basketball':
+ return 1
+ elif row_label == 'shirt':
+ return 2
+ elif row_label == 'shoe':
+ return 3
+ else:
+ return None
+```
+그 후에, \object_detection 폴더에서 TFRecord 파일을 생성하기 위해 밑의 명령어를 실행하세용:
+
+```
+python generate_tfrecord.py --csv_input=images\train_labels.csv --image_dir=images\train --output_path=train.record
+python generate_tfrecord.py --csv_input=images\test_labels.csv --image_dir=images\test --output_path=test.record
+```
+
+이 코드는 \object_detection폴더에서 train.record 과 test.record 파일을 생성합니다. 새로운 사물 인식 분류기를 학습하는데 사용될 것입니다.
+
+
+### 5. Label Map 생성 및 학습 준비
+학습을 진행하기 마지막에 label map을 생성하고 학습 준비 파일을 수정합니다.
+
+#### 5a. Label map
+label map은 각 사물과 클래스 숫자를 맵핑시킨 것 입니다. C:\tensorflow1\models\research\object_detection\training 폴더에서 텍스트 편집기를 사용하여 새로운 파일을 만들고 labelmap.pbtxt 이름으로 저장하세요. (.txt 가아니라 .pbtxt 입니다!!) 텍스트 편집기를 켜고, 밑의 형식으로 복사 붙혀넣기 하세요. (밑의 예제는 Pinochle Deck Card Detector에 관한 것입니다.) :
+
+```
+item {
+ id: 1
+ name: 'nine'
+}
+
+item {
+ id: 2
+ name: 'ten'
+}
+
+item {
+ id: 3
+ name: 'jack'
+}
+
+item {
+ id: 4
+ name: 'queen'
+}
+
+item {
+ id: 5
+ name: 'king'
+}
+
+item {
+ id: 6
+ name: 'ace'
+}
+
+```
+
+label map ID 숫자들은 generate_tfrecord.py 파일에서 정의한 것과 같아야 합니다. 단계 4에서 본 농구공, 셔츠 그리고 신발 분류기에 대한 예제는 밑의 labelmap.pbtxt와 같습니다:
+
+```
+item {
+ id: 1
+ name: 'basketball'
+}
+
+item {
+ id: 2
+ name: 'shirt'
+}
+
+item {
+ id: 3
+ name: 'shoe'
+}
+```
+
+#### 5b. 학습 구성하기
+마침내, 사물 인식 학습 경로를 구성해야 합니다. 학습에 사용될 모델과 파라미터를 정의하는 것입니다. 학습을 시작하기 전의 마지막 단계 입니다!!
+
+C:\tensorflow1\models\research\object_detection\samples\configs 으로 이동하고 faster_rcnn_inception_v2_pets.config 파일을 복사해서 \object_detection\training 폴더로 옮기세요. 그 후에, 테스트 에디터로 파일을 엽니다. 클래스와 예제의 수, 그리고 학습데이터에 파일 경로를 더하는 수정을 합니다.
+
+faster_rcnn_inception_v2_pets.config 파일을 밑에 처럼 변경하세요.
+(Note: 경로 설정시 백슬레쉬(\)가 아니라 포어워슬레쉬(/)를 하세요. 또, TensorFlow 학습시 에러가 발생하면 경로 설정에서 작은 따움표(')가 아니라 큰 따움표(")로 해야합니다.)
+
+- Line 9. 사물 인식을 할 때 인식할 사물 갯수로 num_classes 변수를 바꿔주세요.
+- Line 110. fine_tune_checkpoint 변경:
+ - fine_tune_checkpoint : "C:/tensorflow1/models/research/object_detection/faster_rcnn_inception_v2_coco_2018_01_28/model.ckpt"
+
+- Lines 126 and 128. train_input_reader 부분에서 input_path 와 label_map_path 변경 :
+ - input_path : "C:/tensorflow1/models/research/object_detection/train.record"
+ - label_map_path: "C:/tensorflow1/models/research/object_detection/training/labelmap.pbtxt"
+
+- Line 132. num_examples 변수를 \images\test 에 있는 이미지 갯수로 설정해주세요.
+
+- Lines 140 and 142. eval_input_reader 부분에서 input_path와 label_bap_path 변경 :
+ - input_path : "C:/tensorflow1/models/research/object_detection/test.record"
+ - label_map_path: "C:/tensorflow1/models/research/object_detection/training/labelmap.pbtxt"
+
+다 끝낸 뒤 저장을 합니다. 이제 학습할 준비가 다 되었습니다!
+
+### 6. 학습 실행
+**UPDATE 9/26/18:**
+*As of version 1.9, TensorFlow has deprecated the "train.py" file and replaced it with "model_main.py" file. I haven't been able to get model_main.py to work correctly yet (I run in to errors related to pycocotools). Fortunately, the train.py file is still available in the /object_detection/legacy folder. Simply move train.py from /object_detection/legacy into the /object_detection folder and then continue following the steps below.*
+
+\object_detection 폴더 에서 학습을 시작하는 밑의 명령어를 입력하세요 :
+```
+python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
+```
+만약 모든 설정과 준비가 잘되었다면 TensorFlow가 학습 초기화를 진행할 것 입니다. 실질적인 학습을 진행하기 전에 30초 정도 초기화 단계가 필요합니다. 학습 시작 전에 밑의 사진 처럼 보일 것입니다. :
+
+
+
+
+
+각 학습 단계는 loss 를 보여줍니다. 학습 진행 시작시에는 높지만 계속해서 낮아 질 것입니다. Faster-RCNN-Inception-V2 모델에서는, 3.0에서 시작하여 빠르게 0.8밑으로 내려갔습니다. loss가 연속적으로 0.05 밑으로 유지될때나, 4만번 이상 학습을 했을때 또는 2시간 이상 진행 했을 때 까지 진행하는 것을 추천합니다.(물론 CPU 와 GPU가 좋을 경우 입니다.
+(Note: 모델 마다 loss 숫자들이 다릅니다. MobileNet-SSD의 경우 약 20에서 시작하며, 2보다 아래일 경우 적절한 학습 입니다.)
+
+TensorBoard를 사용하여 학습 진행 상태를 볼 수 있습니다. 이것을 하기위해서 새로운 Anaconda 명령창을 키고, tensorflow1 가상환경을 활성화 하고 C:\tensorflow1\models\research\object_detection directory 폴더에서 밑의 명령어를 입력하세요 :
+
+```
+(tensorflow1) C:\tensorflow1\models\research\object_detection>tensorboard --logdir=training
+```
+
+가상 머신에서 pc이름:6006 이라는 웹사이트를 생성할 것입니다. tensorBoard 페이지는 학습이 진행되는 그래프와 정보를 볼 수 있습니다. 제일 중요한 그래프는 Loss 그래프이며, 전체적인 loss를 보여줍니다.
+
+
+
+
+
+
+학습 루틴은 주기적으로 5분마다 체크포인트를 저장합니다. 명령창에서 Ctrl+C를 눌러 학습을 끝낼 수 있습니다. 학습이 끝나고 체크포인트가 저장될 때 까지 기다립니다. 학습을 끝내고 다시 시작할 수 있으며, 마지막 체크 포인트에서 부터 시작합니다. 가장 높은 단계의 체크포인트가 frozen inference graph에 사용 될 것입니다.
+
+### 7. Inference Graph 추출하기
+학습이 다 된후에, 마지막 단계가 frozen inference graph(.pb 파일)로 생성됩니다. \object_detection 폴더에서, 밑의 명령어를 입력해 주세요. "model.ckpt-XXXX"에서 "XXXX"는 학습 폴더에서 가장 높은 .ckpt 파일로 변경해 주세요 :
+
+```
+python export_inference_graph.py --input_type image_tensor --pipeline_config_path training/faster_rcnn_inception_v2_pets.config --trained_checkpoint_prefix training/model.ckpt-XXXX --output_directory inference_graph
+```
+
+\object_detection\inference_graph 폴더에 frozen_inference_graph.pb 파일을 생성합니다. .pb파일이 사물 인식 분류기를 포함하고 있습니다.
+
+### 8. 새로 학습된 사물 인식 분류기 사용하기!
+사물 인식 분류기가 모든 준비가 완료 되었습니다! 사진, 영상, 도는 웹캠으로 테스트를 진행할 수 있게 Python 코드를 작성했습니다.
+
+Python코드를 진행하기 전에, 코드 안에 있는 NUM_CLASSES 변수를 수정해야 합니다.
+
+(Pinochle Card Detector의 경우, 6개의 카드여서 NUM_CLASSES = 6으로 설정했습니다.)
+
+사물 인식기를 학습하기 위해서, 학습에 사용한 사진을 사용하거나 새로운 사진을 사용합니다. 이때, Object_detection_image.py에 있는 IMAGE_NAME 변수를 수정해야합니다. Obejct_detection_video.py 와 Object_detection_webcam.py 를 사용할 때도 마찬가지 입니다. ( webcam의 경우 USB webcam 입니다.)
+
+반드시 Anaconda 가상환경에서 실행해야 하며 명령창에 idle을 입력하여 python IDLE을 열고 코드를 실행해야 합니다.
+
+모든 것일 잘 준비되었다면, 10초정도 초기화단계를 거쳐 이미지(영상 or 웹캠)에 사물 인식이 된 것이 나타날 것입니다!
+
+
+
+
+
+에러가 발생하면, Appendix를 참고하세요. Appendix는 튜토리얼을 진행하면서 발생한 에러 리스트를 정리한 것입니다. 구글링을 통해 에러를 해결 할 수 도있습니다. Stack Exchange 도는 TensorFlow의 깃헙 이슈에서도 에러를 해결 할 수 있을 것입니다.
+
+## Appendix: 공통적인 에러
+TensorFlow Object Detection API는 Linux 기반의 OS에서 개발되었습니다. Linux Os의 라이브러리를 Windows 라이브러리로 바꾸는 작업이 필요합니다. 따라서 tensorflow-gpu를 windows 10에서 실행할 경우 뜻하지 않은 오류가 발생할 수 도 있습니다. 밑의 에러 리스트는 알맞은 해결법들이 있습니다.
+
+#### 1. ModuleNotFoundError: No module named 'deployment'
+
+objedt_detection_tutorial.ipynb도는 train.py 에서 PATH 그리고 PYTHONPATH 환경을 제대로 설정하지 않아서 발생 하는 것입니다. 가상 환경을 닫고 다시 실행하여 tensorflow1 환경으로 들어가고 2e 단계에 있는 명령어를 입력하세요.
+
+"echo %PATH%” and “echo %PYTHONPATH%" 명령어를 입력해서 가상환경 변수를 확인하고 설정할 수 있습니다.
+
+또한, \models\research 포덜에서 밑의 명령어를 실행하세요:
+```
+setup.py build
+setup.py install
+```
+
+#### 2. ImportError: cannot import name 'preprocessor_pb2'
+
+#### ImportError: cannot import name 'string_int_label_map_pb2'
+
+#### (or similar errors with other pb2 files)
+
+protobuf 파일이 컴파일되지 않았을때 발생합니다. 단계 2f의 명령어를 다시 실행해 주세요. \object_detection\protos 폴더에 모든 name_pb2.py 파일이 있는지 확인하세요.
+
+#### 3. object_detection/protos/.proto: No such file or directory
+
+밑의 명령어를 실행할 때 발생합니다.
+```
+“protoc object_detection/protos/*.proto --python_out=.”
+```
+TensorFlow Object Detection API 설치 페이지에 설명되어있습니다. Windows에서 작동하지 않을때 단계 2f 대신에 위의 명령어를 입력해 주세요. 더 간단한 방법이 있을텐데... 잘 모르겠다고 합니다.
+
+#### 4. Unsuccessful TensorSliceReader constructor: Failed to get "file path" … The filename, directory name, or volume label syntax is incorrect.
+
+학습 설정 파일(faster_rcnn_inception_v2_pets.config 또는 비슷한 것들에서)에서 경로를 설정할 때 슬래쉬 대신에 백슬래쉬가 들어갈 경우 발생합니다. 모든 파일에 경로가 밑에 처럼 보이게 수정해 주세요:
+```
+“C:/path/to/model.file”
+```
+
+#### 5. ValueError: Tried to convert 't' to a tensor and failed. Error: Argument must be a dense tensor: range(0, 3) - got shape [3], but wanted [].
+
+models/research/object_detection/utils/learning_schedules.py 에서 발생하는 문제입니다.
+
+```
+rate_index = tf.reduce_max(tf.where(tf.greater_equal(global_step, boundaries),
+ range(num_boundaries),
+ [0] * num_boundaries))
+```
+밑에 처럼 list(range())로 설정해 주세요:
+
+```
+rate_index = tf.reduce_max(tf.where(tf.greater_equal(global_step, boundaries),
+ list(range(num_boundaries)),
+ [0] * num_boundaries))
+```
+
+[Ref: Tensorflow Issue#3705](https://github.com/tensorflow/models/issues/3705#issuecomment-375563179)
+```
+
+```
+
+```
+
+```
diff --git a/translate/README_Vietnamese.md b/translate/README_Vietnamese.md
new file mode 100644
index 00000000..dbbda771
--- /dev/null
+++ b/translate/README_Vietnamese.md
@@ -0,0 +1,477 @@
+# Cách đào tạo một Object Detection Classifier cho Multiple Objects sử dụng TensorFlow (GPU) trên Window 10
+
+## Tóm lược
+*Lần cập nhật gần nhất: 6/22/2019 với TensorFlow phiên bản 1.13.1*
+
+*Một phiên bản tiếng Hàn và tiếng Việt của hướng dẫn này đã có ở thư mục [translate folder](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10/blob/master/translate/README.md) (thanks @cocopambag and @[winter2897](https://github.com/winter2897)). Nếu bạn muốn đóng góp một bản dịch bằng một ngôn ngữ khác, bạn có thể thêm nó như là một pull request và tôi sẽ merge nó khi có thể.*
+
+Repository này là một hướng dẫn về cách sử dụng TensorFlow's Object Detection API để đào tạo một object detection classsifier cho multiple objects trên Window 10, 8, hoặc 7. (Với vài thay đổi nhỏ, nó cũng hoạt động được trên các hệ điều hành khác dựa trên nhân Linux). Bản gốc được viết dựa trên Tensorflow phiên bản 1.5, tuy nhiên nó vẫn hoạt động trên các phiên bản mới nhất của TensorFlow.
+
+Tôi đã làm một YouTube video tóm tắt về hướng dẫn này. Bất kỳ sự khác biệt nào giữa video và bản hướng này này do các bản cập nhật bắt buộc lên các phiên bản mới hơn của TensorFlow.
+
+**If there are differences between this written tutorial and the video, follow the written tutorial!**
+
+[](https://www.youtube.com/watch?v=Rgpfk6eYxJA)
+
+File readme mô tả tất cả các bước cần thiết để bắt đầu đào tạo một Object detection classifier của riêng bạn:
+1. [Cài đặt Anaconda, CUDA, và cuDNN](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#1-install-anaconda-cuda-and-cudnn)
+2. [Thiết lập Thư mục TensorFlow và Anaconda Virtual Environment](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#2-set-up-tensorflow-directory-and-anaconda-virtual-environment)
+3. [Thu thập và gán nhãn hình ảnh](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#3-gather-and-label-pictures)
+4. [Tạo dữ liệu đào tạo](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#4-generate-training-data)
+5. [Tạo một label map và thiết lập trước khi đào tạo](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#5-create-label-map-and-configure-training)
+6. [Đào tạo](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#6-run-the-training)
+7. [Xuất ra file inference graph](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#7-export-inference-graph)
+8. [Sử dụng bộ object detection classifier của bạn vừa huấn luyện để kiểm thử](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#8-use-your-newly-trained-object-detection-classifier)
+
+[Phụ lục: Những lỗi thường gặp](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#appendix-common-errors)
+
+Repository này chứa tất cả những file cần thiết để đào tạo một trình phát hiện các quân bài chín, mười, Ri, Q, K trong bộ bài Tây "Pinochle Deck". Hướng dẫn này mô tả cách thay thế các file này bằng các file của bạn để đào tạo một detection classifier cho bất kỳ mục đích nào bạn muốn. Nó cũng chứa các Python scripts để kiểm thử bộ phân loại của bạn cho từng ảnh, video hay từ webcam.
+
+
+
+
+
+## Giới thiệu
+Mục đích của hướng dẫn này là giải thích chi tiết cách đào tạo một mạng nơ-ron tích chập (CNN) của riêng bạn để nhận dạng và phân loại cho nhiều vật thể. Vào cuối hướng dẫn này, bạn sẽ có một chương trình có thể nhận dạng và vẽ khoanh vùng các đối tượng cụ thể trong ảnh, videos, hoặc với đầu vào của webcam.
+
+Đã có một số hướng dẫn chi tiết về cách sử dụng TensorFlow's Object Detection API để huấn luyện một bộ phân loại cho một đối tượng. Tuy nhiên, hầu hết đều sử dụng hệ điều hành Linux. Nếu bạn giống như tôi, chắc bạn cũng đắn đo một chút khi cài đặt Linux trên PC - gaming với card đồ họa mạnh mẽ mà bạn dùng để đào tạo bộ phân loại. Object Detection API dường như đã được phát triển trên hệ điều hành Linux. Để thiết lập TensorFlow đào tạo một model trên Window, có một số cách giải quyết và cần được sử dụng để thay thế các lệnh đã hoạt động tốt trên Linux. Ngoài ra, hướng dẫn này sẽ giúp bạn đào tạo một bộ phân loại mà có thể nhận diện được nhiều vật thể, chứ không chỉ một.
+
+Hướng dẫn này dành riêng cho Windows 10, và nó cũng hoạt động trên Windows 7 và 8. Quy trình các bước trong hướng dẫn có thể sử dụng trên Linux, tuy nhiên đường dẫn tệp và lệnh cài đặt các gói sẽ phải thay đổi cho phù hợp. Tôi sử dụng TensorFlow-GPU phiên bản 1.5 trong lúc viết phiên bản đầu tiên của hướng dẫn này, nhưng nó vẫn sẽ hoạt động với các bản cập nhật mới nhất của TensorFlow.
+
+TensorFlow-GPU cho phép PC của bạn sử dụng card đồ họa để tăng sức mạnh xử lý trong quá trình đào tạo, vì vậy nó sẽ được sử dụng trong hướng dẫn này. Với kinh nghiệm của tôi, sử dụng TensorFlow-GPU thay vì TensorFlow thông thường sẽ giảm thời gian đào tạo xuống 8 lần (24 giờ xuống còn 3 giờ). Nếu sử dụng TensorFlow thông thường với CPU cũng có thể làm theo các bước trong hướng dẫn này, nhưng thời gian đào tạo sẽ lâu hơn. Nếu bạn sử dụng TensorFlow chỉ dành cho CPU thì bạn không cần phải cài đặt CUDA và cuDNN trong Bước 1.
+
+## Các bước thực hiện
+### 1. Cài đặt Anaconda, CUDA, và cuDNN
+Theo dõi [YouTube video này thực hiện bởi Mark Jay](https://www.youtube.com/watch?v=RplXYjxgZbw), video hướng dẫn cách cài đặt Anaconda, CUDA, và cuDNN. Bạn không cần thực sự cần phải cài đặt TensorFlow như trong video hướng dẫn, vì chúng ta sẽ làm nó sau ở Bước 2. Video trên được làm với TensorFlow-GPU v1.4, vì vậy bạn hãy tải và cài đặt CUDA và cuDNN phiên bản phù hợp với TensorFlow bản mới nhất, thay vì CUDA v8.0 và cuDNN v6.0 như video đề cập. Hãy truy cập [TensorFlow website](https://www.tensorflow.org/install/gpu) để kiểm tra phiên bản nào của CUDA và cuDNN là phù hợp với phiên bản TensorFlow mới nhất.
+
+Nếu bạn sử dụng một phiên bản cũ hơn của TensorFlow, hãy chắc chắn rằng bạn sử dụng phiên bản của CUDA và cuDNN tương thích với bản TensorFlow bạn đang dùng. [Đây](https://www.tensorflow.org/install/source#tested_build_configurations) là bảo chỉ ra phiên bản của TensorFlow thì phù hợp với phiên bản CUDA và cuDNN tương ứng.
+
+Hãy đảm bảo [Anaconda](https://www.anaconda.com/distribution/#download-section) được cài đặt theo chỉ dẫn của video, bởi vì Anaconda Virtual Environment sẽ được sử dụng trong suốt hướng dẫn này. (Lưu ý: Phiên bản gần nhất của Anaconda sử dụng Python 3.7, phiên bản này không được hỗ trợ chính thức bởi TensorFlow. Tuy nhiên, khi tạo một Anaconda Virtual Environment trong Bước 2d của hướng dẫn này, chúng ta sẽ hướng nó sử dụng Python 3.5).
+
+Truy cập [TensorFlow's website](https://www.tensorflow.org/install) để biết thêm về chi tiết cài đặt, bao gồm cả cách cài đặt nó trên các hệ điều hành khác (như Linux). Với [object detection repository](https://github.com/tensorflow/models/tree/master/research/object_detection) bản thân nó cũng có [các hướng dẫn cài đặt](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md).
+
+### 2. Thiết lập Thư mục TensorFlow và Anaconda Virtual Environment
+TensorFlow Object Detection API yêu cầu sử dụng cấu trúc thư mục riêng được cung cấp tại GitHub repository. Nó cũng yêu cầu một số Python pakages bổ sung, thêm các biến PATH và PYTHONPATH riêng, và một vài lệnh thiết lập để có thể chạy hoặc đào tạo một Object Detection Model.
+
+Mục này của hướng dẫn toàn bộ thiết lập cần thiết. Nó khá tỉ mỉ, nhưng hãy làm theo các hướng dẫn một cách chặt chẽ và cẩn thận, bởi vì việc thiết lập sai có thể gây ra các lỗi khó khắc phục.
+
+#### 2a. Tải TensorFlow Object Detection API repository từ GitHub
+Đầu tiên, tạo một thư mục trong ổ C: và đặt tên nó là "tensorflow1". Thư mục này sẽ bao gồm tất cả TensorFlow Object Detection Framework, cũng như các hình ảnh đào tạo, dữ liệu đào tạo, bộ phân loại đã huấn luyện, các tệp cấu hình và tất cả những thứ khác cần thiết cho Object Detection Classifier.
+
+Tải bản đầy đủ nhất của TensorFlow object detection repository tại https://github.com/tensorflow/models bằng cách nhấn vào nút "Clone or Download" để tải về file zip. Mở file zip vừa tải xuống và giải nén với thư mục "models-master" tới địa chỉ thư mục C:\tensorflow1 mà bạn vừa tạo ở trên. Đổi tên “models-master” thành “models”.
+
+**Note: Code của TensorFlow models repository (nơi chứa object detection API) được các nhà phát triển cập nhật liên tục. Đôi khi họ thực hiện các thay đổi khiến các phiên bản cũ TensorFlow không còn sử dụng được. Do đó tốt nhất nên sử dụng phiên bản mới nhất của TensorFlow và tải về repository mới nhất. Nếu bạn không sử dụng phiên bản mới nhất, Clone or Download repository thích hợp với phiên bản bạn sử dụng đã được liệt kê như bảng dưới đây.**
+
+ Nếu bạn sử dụng một phiên bản cũ hơn của TensorFlow, đây là bảng cho biết Gihub commit của repository bạn nên sử dụng. Tôi đã tạo nó bằng cách đi đến các branches cho cái model repository và lấy commit trước commit cuối cho branch. (Họ xóa các thư mục nghiên cứu như là commit cuối trước khi phát hành phiên bản mới nhất.)
+
+| Phiên bản TensorFlow | GitHub Models Repository Commit |
+|--------------------|---------------------------------|
+|TF v1.7 |https://github.com/tensorflow/models/tree/adfd5a3aca41638aa9fb297c5095f33d64446d8f |
+|TF v1.8 |https://github.com/tensorflow/models/tree/abd504235f3c2eed891571d62f0a424e54a2dabc |
+|TF v1.9 |https://github.com/tensorflow/models/tree/d530ac540b0103caa194b4824af353f1b073553b |
+|TF v1.10 |https://github.com/tensorflow/models/tree/b07b494e3514553633b132178b4c448f994d59df |
+|TF v1.11 |https://github.com/tensorflow/models/tree/23b5b4227dfa1b23d7c21f0dfaf0951b16671f43 |
+|TF v1.12 |https://github.com/tensorflow/models/tree/r1.12.0 |
+|TF v1.13 |https://github.com/tensorflow/models/tree/r1.13.0 |
+|Latest version |https://github.com/tensorflow/models |
+
+Hướng dẫn này ban đầu được hoàn thành sử dụng TensorFlow v1.5 và [GitHub commit](https://github.com/tensorflow/models/tree/079d67d9a0b3407e8d074a200780f3835413ef99) của TensorFlow Object Detection API. Nếu các phần của hướng dẫn này không hoạt động , có thể bạn sẽ cần phải cài đặt TensorFlow v1.5 và tải về chính xác GitHub commit này thay vì phiên bản mới nhất.)
+
+#### 2b. Tải về Faster-RCNN-Inception-V2-COCO model từ TensorFlow's model zoo
+TensorFlow cung cấp một số object detection model (pre-trained classifiers cùng kiến trúc mạng nơ-ron tương ứng) tại đây [model zoo](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md). Một số model (như SSD-MobileNet model) có kiến trúc cho phép nhận diện nhanh hơn nhưng đánh đổi bằng việc độ chính xác thấp, trong khi một số model (như Faster-RCNN model) nhận diện chậm hơn nhưng độ chính xác tốt hơn. Tôi khởi đầu bằng SSD-MobileNet-V1 model, nhưng nó nhận diện không tốt lắm các thẻ bài có trong ảnh. Tôi huấn luyện lại model với Faster-RCNN-Inception-V2, và nó nhận diện tốt hơn đáng kể, nhưng với tốc độ chậm hơn.
+
+
+
+
+
+Bạn có thể chọn model phù hợp để đào tạo objection detection classifier của bạn. Nếu bạn muốn sử dụng object detector trên các thiết bị có cấu hình phần cứng hạn chế (như smart phone hay Raspberry Pi), hãy sử dụng SDD-MobileNet model. Nếu bạn chạy model trên các laptop hay PC có cấu hình mạnh, sử dụng RCNN models.
+
+Hướng dẫn này sẽ sử dụng Faster-RCNN-Inception-V2 model. [Tải về model tại đây](http://download.tensorflow.org/models/object_detection/faster_rcnn_inception_v2_coco_2018_01_28.tar.gz) Mở file faster_rcnn_inception_v2_coco_2018_01_28.tar.gz đã tải về và sử dụng WinZip hoặc 7-Zip sau đó giải nén thư mục faster_rcnn_inception_v2_coco_2018_01_28 đến thư mục C:\tensorflow1\models\research\object_detection. (Lưu ý: Phiên bản của model có thể sẽ thay đổi trong tương lai, nhưng nó vẫn sẽ hoạt động theo hướng dẫn này.)
+
+#### 2c. Tải xuống repository của hướng dẫn này từ Github
+Tải xuống toàn bộ repository tại trang này (cuộn lên đầu trang và click vào Clone or Download) và giải nén tất cả các file vào thư mục có đường dẫn C:\tensorflow1\models\research\object_detection. (Bạn có thể ghi đè lên file "README.md" hiện có.) Vậy là chúng ta đã hoàn thành việc thiết lập thư mục để sử dụng trong suốt hướng dẫn này.
+
+Tại đây, cấu trúc các file trong thư mục \object_detection sẽ trông như thế này:
+
+
+
+
+
+Repository bao gồm images, annotation data, .csv files và TFRecords cần thiết để đào tạo một trình nhận diện quân bài "Pinochle Deck". Bạn có thể sử dụng hình ảnh và dữ diệu này để luyện tập và tạo ra một trình nhận diện quân bài của riêng bạn. Nó bao gồm Python scripts thứ sẽ được sử dụng để tạo ra training data. Nó cũng có các scripts để kiểm thử object detection classifier trên hình ảnh, video hoặc đầu vào từ webcam. Bạn có thể bỏ qua thư mục \doc và các file bên trong, vì đây chỉ là nơi giữ các hình ảnh cho file readme này.
+
+Nếu bạn muốn luyện tập đào tạo một trình nhận diện quân bài "Pinochle Deck" của bạn, hãy giữ nguyên các file hiện có. Bạn có thể theo tiếp hướng dẫn này để biết làm cách nào mà các file được tạo ra, cách để bắt đầu đào tạo. Bạn sẽ cần tạo ra các file TFRecord (train.record và test.record) như mô tả ở Bước 4.
+
+Bạn có thể tải về các inference graph về nhận diện quân bài Pinochle Deck đã được huấn luyện sẵn của tôi [from this Dropbox link](https://www.dropbox.com/s/va9ob6wcucusse1/inference_graph.zip?dl=0) và giải nén các file bên trong đến \object_detection\inference_graph. Đây là inference graph đã hoạt động tốt. Bạn có thể test no sau khi đã hoàn thành các thiết lập tại Bước 2a - 2f và chạy file Object_detection_image.py (hoặc video hoặc webcam).
+
+Nếu bạn muốn tự đào tạo một object detector, hãy tiến hành xóa các file được liệt kê dưới đây (không xóa thư mục):
+- Tất cả các file trong \object_detection\images\train and \object_detection\images\test
+- File “test_labels.csv” và “train_labels.csv” files trong thư mục \object_detection\images
+- Tất cả các file trong \object_detection\training
+- Tất cả các file trong \object_detection\inference_graph
+
+Bây giờ, bạn đã sẵn sàng để bắt đầu huấn luyện object detector của bạn. Đảm bảo rằng các bước ở trên đã hoàn thành và các file liệt kê ở trên đã được xóa, sau đây tôi sẽ tiếp tục giải thích các tạo ra những file cho bộ dữ liệu đào tạo của riêng bạn.
+
+#### 2d. Thiết lập một Anaconda virtual environment mới
+Tiếp theo, chúng ta sẽ tiến hành thiết lập một Anaconda virtual environment cho tensorflow-gpu. Từ menu Start của Windows, tìm kiếm Anaconda Prompt, click vào nó, và chọn “Run as Administrator”. Nếu Windows hỏi bạn có đồng ý cho chạy với quyền Admin không thì hãy click vào Yes.
+
+Tại cửa sổ terminal vừa xuất hiện, tạo một virtual environment đặt tên là “tensorflow1” bằng cách sử dụng lệnh dưới đây:
+```
+C:\> conda create -n tensorflow1 pip python=3.5
+```
+Sau đó, kích hoạt môi trường và cập nhật pip bằng lệnh:
+```
+C:\> activate tensorflow1
+
+(tensorflow1) C:\>python -m pip install --upgrade pip
+```
+Cài đặt tensorflow-gpu tại môi trường này bằng lệnh:
+```
+(tensorflow1) C:\> pip install --ignore-installed --upgrade tensorflow-gpu
+```
+
+(Lưu ý: Bạn có thể chỉ sử dụng phiên bản TensorFlow dành cho CPU, nhưng nó sẽ chạy chậm hơn nhiều. Nếu bạn muốn sử dụng phiên bản, thay thế "tensorflow" bởi "tensorflow-gpu" ở lệnh cài đặt phía trên.)
+
+Cài đặt các packages cần thiết khác bằng các lệnh dưới đây:
+```
+(tensorflow1) C:\> conda install -c anaconda protobuf
+(tensorflow1) C:\> pip install pillow
+(tensorflow1) C:\> pip install lxml
+(tensorflow1) C:\> pip install Cython
+(tensorflow1) C:\> pip install contextlib2
+(tensorflow1) C:\> pip install jupyter
+(tensorflow1) C:\> pip install matplotlib
+(tensorflow1) C:\> pip install pandas
+(tensorflow1) C:\> pip install opencv-python
+```
+(Lưu ý: Thư viện ‘pandas’ và ‘opencv-python’ không cần thiết cho TensorFlow, nhưng chúng ta sẽ cần nó cho các Python scripts để tạo ra file TFRecords và làm việc với hình ảnh, video và đầu vào từ webcam.)
+
+#### 2e. Cấu hình đường dẫn PYTHONPATH cho môi trường
+Một đường dẫn PYTHONPATH thì cần phải được cấu hình như \models, \models\research, và \models\research\slim directories. Cấu hình nó bằng cách chạy lệnh dưới đây (từ bất kỳ thư mục nào):
+```
+(tensorflow1) C:\> set PYTHONPATH=C:\tensorflow1\models;C:\tensorflow1\models\research;C:\tensorflow1\models\research\slim
+```
+(Lưu ý: Mỗi khi "tensorflow1" virtual environment bị tắt, thì biến PYTHONPATH cần phải được thiết lập lại. Bạn có thể chạy "echo %PYTHONPATH% để xem nó có cần thiết lập hay không.)
+
+#### 2f. Biên dịch Protobufs và chạy setup.py
+Tiếp theo, biên dịch các file Protobuf, cái mà được sử dụng bởi TensorFlow để cấu hình model và các tham số huấn luyện. Không may rằng, lệnh biên dịch protoc ngắn gọn được đăng tại TensorFlow’s Object Detection API [installation page](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md) không hoạt động trên Windows. Mỗi file .proto trong \object_detection\protos cần được biên dịch thủ công riêng bởi lệnh.
+
+Tại Anaconda Command Prompt, đổi đường dẫn thư mục tới thư mục \models\research:
+```
+(tensorflow1) C:\> cd C:\tensorflow1\models\research
+```
+
+Sau đó copy và paste các lệnh dưới đây vào command line sau đó nhấn Enter:
+```
+protoc --python_out=. .\object_detection\protos\anchor_generator.proto .\object_detection\protos\argmax_matcher.proto .\object_detection\protos\bipartite_matcher.proto .\object_detection\protos\box_coder.proto .\object_detection\protos\box_predictor.proto .\object_detection\protos\eval.proto .\object_detection\protos\faster_rcnn.proto .\object_detection\protos\faster_rcnn_box_coder.proto .\object_detection\protos\grid_anchor_generator.proto .\object_detection\protos\hyperparams.proto .\object_detection\protos\image_resizer.proto .\object_detection\protos\input_reader.proto .\object_detection\protos\losses.proto .\object_detection\protos\matcher.proto .\object_detection\protos\mean_stddev_box_coder.proto .\object_detection\protos\model.proto .\object_detection\protos\optimizer.proto .\object_detection\protos\pipeline.proto .\object_detection\protos\post_processing.proto .\object_detection\protos\preprocessor.proto .\object_detection\protos\region_similarity_calculator.proto .\object_detection\protos\square_box_coder.proto .\object_detection\protos\ssd.proto .\object_detection\protos\ssd_anchor_generator.proto .\object_detection\protos\string_int_label_map.proto .\object_detection\protos\train.proto .\object_detection\protos\keypoint_box_coder.proto .\object_detection\protos\multiscale_anchor_generator.proto .\object_detection\protos\graph_rewriter.proto .\object_detection\protos\calibration.proto .\object_detection\protos\flexible_grid_anchor_generator.proto
+```
+Việc này tạo một file name_pb2.pt từ mỗi file name.proto trong thư mục \object_detection\protos.
+
+**(Lưu ý: TensorFlow thỉnh thoảng cập nhật các file .proto mới tại thư mục \protos. Nếu bạn gặp phải lỗi về ImportError: cannot import name 'something_something_pb2' , bạn có thể cần phải cập nhật các lệnh proto để thêm vào các file .proto mới.)**
+
+Cuối cùng, chạy các lệnh sau từ thư mục C:\tensorflow1\models\research:
+```
+(tensorflow1) C:\tensorflow1\models\research> python setup.py build
+(tensorflow1) C:\tensorflow1\models\research> python setup.py install
+```
+
+#### 2g. Kiểm tra thiết lập TensorFlow để đảm bảo nó hoạt động
+Phía trên là đầy đủ các cài đặt về TensorFlow Object Detection API để object detection, hoặc đào tạo một model mới. Bạn có thể kiểm thử nó để đảm bảo rằng các cài đặt hoạt động bằng cách chạy Jupyter notebook object_detection_tutorial.ipynb. Từ thư mục \object_detection, chạy lệnh sau:
+```
+(tensorflow1) C:\tensorflow1\models\research\object_detection> jupyter notebook object_detection_tutorial.ipynb
+```
+Lệnh này sẽ mở notebook tại một cửa sổ mới trên trình duyệt web của bạn và cho phép bạn chạy từng lệnh một trong notebook. Bạn có thể chuyển tiếp giữa các cell code bằng việc click vào nút "Run" tại thanh công cụ phía trên. Hoặc bạn có thể chọn "Run All" đê chạy tất cả các cell code trong notebook.
+
+(Lưu ý: có đoạn tải về ssd_mobilenet_v1 model từ GitHub, khoảng 74MB. Nên nó sẽ mất một chút thời gian để hoàn thành, hãy kiên nhẫn đợi)
+
+Khi bạn đã chạy tất cả script trong notebook, bạn sẽ thấy hai hình ảnh đã được gán nhãn ở phần dưới cùng của trang. Nếu bạn thấy nó, tất cả đã hoạt động tốt! Nếu không, phần dưới cùng sẽ báo ra một số lỗi mà có thể gặp phải. Xem tại [Appendix](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#appendix-common-errors) là một loạt các lỗi mà tôi gặp phải trong quá trình thiết lập.
+
+**Lưu ý: Nếu bạn chạy toàn bộ Jupyter Notebook mà không gặp lỗi nào, nhưng hình ảnh có gán nhãn không hiện lên, thử cái này: đi đến thư mục object_detection/utils/visualization_utils.py và comment lại các dòng 29 và 30 nơi chứa matplotlib. Sau đó, chạy lại toàn bộ Jupyter notebook.**
+
+
+
+
+
+### 3. Thu thập và gán nhãn hình ảnh
+Sau khi TensorFlow Object Detection API đã thiết lập thành công và sẵn sàng chạy, chúng ta cần cung cần cung cấp các hình ảnh mà sẽ dùng để đào tạo một detection classifier mới.
+
+#### 3a. Thu thập hình ảnh
+TensorFlow cần lượng lớn hình ảnh của một object để có thể đào tạo một detection classifier model tốt. Để đào tạo một bộ phân loại mạnh mẽ, các hình ảnh đào tạo cần có ngẫu nhiên các objects trong ảnh cùng với các objects mong muốn, và nên có đa dạng về nền và điều kiện ánh sáng khác nhau. Cần có một số hình ảnh mà trong đó object mong muốn bị che khuất một phần, chồng chéo với một thứ khác, hoặc chỉ ở giữa bức ảnh.
+
+Với Pinochle Card Detection classifier của tôi, tôi cso 6 objects khác nhau mà tôi muốn phát hiện (Thứ tự các quân bài chín, mười Ri, Q, K và Át - Đây chỉ là thứ tự, tôi không nhận diện quân Át). Tôi đã sử dụng iPhone để chụp 40 bức ảnh, với nhiều các vật thể không muốn cũng có trong ảnh. Sau đó, tôi chụp khoảng 100 bức khác cùng với đa dạng các quân bài cùng trong một bức ảnh. Tôi muốn phát hiện các thể khi chúng trùng lên nhau, vì vậy tôi chắc chắn rằng các thẻ có thể chồng lên nhau trong nhiều hình ảnh.
+
+
+
+
+
+Bạn có thể sử dụng điện thoại của bạn để chụp các hình ảnh về vật thể hoặc bạn có thể tải chúng từ Google Image Search. Tôi khuyến nghị bạn nên có ít nhất 200 ảnh tất cả. Tôi sử dụng 311 ảnh để đào tạo bộ phát hiện các quân bài của mình.
+
+Đảm bảo rằng các hình ảnh không quá lớn. Chúng nên nhỏ hơn 200KB mỗi bức, và độ phân giải của chúng không lớn hơn 720x1280. Hình ảnh càng lớn thì càng mất nhiều thời gian để đào tạo. Bạn có thể sử dụng resizer.py script trong repository để giảm kích thước của các hình ảnh xuống.
+
+Sau khi bạn có tất cả các hình ảnh bạn cần, chia chúng ra 20% đến thư mục \object_detection\images\test, và 80% còn lại vào thư mục \object_detection\images\train. Đảm bảo rằng có đa dạng hình ảnh trong cả hai thư mục \test và \train.
+
+#### 3b. Label Pictures
+Chúng ta đến với phần thú vị rồi đây! Cùng với tất cả hình ảnh mà bạn đã thu thập, bây giờ là lúc gán nhãn cho các vật thể mà bạn muốn nhận diện trong mỗi bức ảnh. LabelImg là một công cụ tuyệt vời để làm việc này, và GitHub của có đầy đủ các hướng dẫn để cài đặt và sử dụng nó.
+
+[Link Github của LabelImg](https://github.com/tzutalin/labelImg)
+
+[Link tải về LabelImg](https://www.dropbox.com/s/tq7zfrcwl44vxan/windows_v1.6.0.zip?dl=1)
+
+Tải xuống và cài đặt LabelImg, chuyển đường dẫn đến thư mục chứa ảnh đào tạo của bạn \images\train, và với mỗi ảnh vẽ một hình chữ nhật (box) bao quanh mỗi vật thể mà bạn muốn nhận dạng. Lặp lại quá trình này với tất cả các ảnh trong tập kiểm thử \images\test. Quá này này sẽ mất kha khá thời gian đấy! (**Lưu ý: Bạn hãy để định dạng là PascalVOC thay vì YOLO nhé!**)
+
+
+
+
+
+LabelImg lưu một file .xml bao gồm nhãn cho mỗi ảnh. Mỗi file .xml sẽ được sử dụng để tạo ra các file TFRecords, cái sẽ là đầu vào cho bộ huấn luyện với TensorFlow. Khi bạn gán nhãn và lưu mỗi ảnh, sẽ có một file .xml cho mỗi ảnh trong thư mục \test và \train.
+
+### 4. Generate Training Data
+Cùng với bộ dataset đã được gán nhãn, đây là lúc để tạo ra các file TFRecords cái mà sẽ làm đầu vào cho việc huấn luyện model với TensorFlow. Hướng dẫn này sử dụng file xml_to_csv.py và generate_tfrecord.py từ [Dat Tran’s Raccoon Detector dataset](https://github.com/datitran/raccoon_dataset), cùng với một số sử đổi nhỏ để có thể chạy được trong cấu trúc thư mục của chúng ta.
+
+Đầu tiên, các file ảnh và file .xml sẽ được sử dụng để tạo ra file .cvs bao gồm tất cả dữ liệu cho tập train và test. Từ thư mục \object_detection, ta chạy lệnh sau trong Anaconda Prompt:
+```
+(tensorflow1) C:\tensorflow1\models\research\object_detection> python xml_to_csv.py
+```
+Kết thúc lệnh các file train_labels.csv và test_labels.csv sẽ được tạo ra tại thư mục \object_detection\images.
+
+Tiếp theo, mở file generate_tfrecord.py trong một Text Editor. Thay thế các nhãn tại dòng thứ 31 bằng các nhãn của bạn, trong đó mỗi đối tượng được gán một ID. Việc đánh số thứ tự sẽ được sử dụng khi cấu hình file the labelmap.pbtxt tại Bước 5b.
+
+Ví dụ, bạn đang đào tạo một bộ phân loại để phát hiện bóng rổ, áo sơ-mi và giày. Bạn sẽ cần thay thế code trong file generate_tfrecord.py:
+```
+# TO-DO replace this with label map
+def class_text_to_int(row_label):
+ if row_label == 'nine':
+ return 1
+ elif row_label == 'ten':
+ return 2
+ elif row_label == 'jack':
+ return 3
+ elif row_label == 'queen':
+ return 4
+ elif row_label == 'king':
+ return 5
+ elif row_label == 'ace':
+ return 6
+ else:
+ None
+```
+Thành:
+```
+# TO-DO replace this with label map
+def class_text_to_int(row_label):
+ if row_label == 'basketball':
+ return 1
+ elif row_label == 'shirt':
+ return 2
+ elif row_label == 'shoe':
+ return 3
+ else:
+ None
+```
+Sau đó, tạo các file TFRecord bằng cách sử dụng lệnh dưới đây tại thư mục \object_detection:
+```
+python generate_tfrecord.py --csv_input=images\train_labels.csv --image_dir=images\train --output_path=train.record
+python generate_tfrecord.py --csv_input=images\test_labels.csv --image_dir=images\test --output_path=test.record
+```
+Các file train.record và a test.record sẽ được tạo ra tại thư mục \object_detection. Chúng sẽ được sử dụng để đào tạo một bộ phân loại vật thể mới.
+
+### 5. Tạo Label Map và cấu hình đào tạo
+Điều cuối cùng cần chuẩn bị trước khi đi vào huấn luyện model là tạo một file định nghĩa các nhãn (Label Map) và cấu hình file đào tạo.
+
+#### 5a. Định nghĩa các nhãn
+Label Map thì nói với bộ huấn luyện rằng tên mỗi vật thể được ánh xạ tương ứng với số ID. Sử dụng một Text Eidtor để tạo một file mới và lưu nó lại như là labelmap.pbtxt trong thư mục C:\tensorflow1\models\research\object_detection\training. (Đảm bảo rằng đuôi file là .pbtxt chứ không phải .txt !) Trong Text Editor, chỉnh sửa file Label Map theo format dưới đây (Ví dụ dưới đây là Label Map của bộ nhận diện các quân bài Pinochle):
+```
+item {
+ id: 1
+ name: 'nine'
+}
+
+item {
+ id: 2
+ name: 'ten'
+}
+
+item {
+ id: 3
+ name: 'jack'
+}
+
+item {
+ id: 4
+ name: 'queen'
+}
+
+item {
+ id: 5
+ name: 'king'
+}
+
+item {
+ id: 6
+ name: 'ace'
+}
+```
+Số ID trong Label Map phải giống với số đã được định nghĩa trong file generate_tfrecord.py. Ví dự với bộ phát hiện bóng rổ, áo sơ-mi, và giày được đề cập trong Bước 4, file labelmap.pbtxt sẽ trông như thế này:
+```
+item {
+ id: 1
+ name: 'basketball'
+}
+
+item {
+ id: 2
+ name: 'shirt'
+}
+
+item {
+ id: 3
+ name: 'shoe'
+}
+```
+
+#### 5b. Configure training
+Cuối cùng, quá trình đạo tạo bộ phát hiện vật thể cần được thiết lập. Nó thì định nghĩa cho model biết những tham số nào sẽ được sử dụng trong quá trình đào tạo. Đây là bước cuối cùng trước khi tiến hành chạy đào tạo!
+
+Chuyển đến thư mục C:\tensorflow1\models\research\object_detection\samples\configs và sao chép file faster_rcnn_inception_v2_pets.config đến thư mục \object_detection\training. Sau đó, mở file này trong một Text Editor. Cần một số thay đổi trong file .config, ví dụ cần phải thay đổi số lượng, và thêm đường dẫn đến thư mục chứa dataset.
+
+Tiến hành các thay đổi với file faster_rcnn_inception_v2_pets.config file theo hướng dẫn dưới đây. Lưu ý: Đường dẫn cần phải được nhập bằng dấu gạch chéo đơn (/) (KHÔNG phải dấu gạch chéo ngược (\)), dẫn đến TensorFlow sẽ có thể sinh ra lỗi với đường dẫn file! Ngoài ra, các đường dẫn phải được để trong dấu ngoặc kép ("), không phải là dấu ngoặc kép đơn (').
+
+- Dòng 9. Thay đổi num_classes thành số lượng objects mà bạn muốn phát hiện. Ví dụ trên với bộ phát hiện bóng rổ, áo sơ-mi, và giày thì num_classes bằng: 3.
+- Line 106. Thay đổi fine_tune_checkpoint thành:
+ - fine_tune_checkpoint : "C:/tensorflow1/models/research/object_detection/faster_rcnn_inception_v2_coco_2018_01_28/model.ckpt"
+
+- Lines 123 và 125. Trong mục train_input_reader, thay đổi input_path và label_map_path thành:
+ - input_path : "C:/tensorflow1/models/research/object_detection/train.record"
+ - label_map_path: "C:/tensorflow1/models/research/object_detection/training/labelmap.pbtxt"
+
+- Line 130. Thay đổi num_examples thành số lượng ảnh test bạn có trong thư mục \images\test directory.
+
+- Lines 135 và 137. Trong mục eval_input_reader, thay đổi input_path and label_map_path thành:
+ - input_path : "C:/tensorflow1/models/research/object_detection/test.record"
+ - label_map_path: "C:/tensorflow1/models/research/object_detection/training/labelmap.pbtxt"
+
+Lưu lại các file sau khi đã thay đổi. Vậy là xong! Cấu hình đào tạo đã sẵn sàng để chạy huấn luyện model!
+
+### 6. Chạy quá trình đào tạo
+**CẬP NHẬT 9/26/18:**
+*Ở phiên bản 1.9, TensorFlow đã thay thế file "train.py" bằng file "model_main.py". Tôi chưa tìm ra cách đê file model_main.py hoạt động chính xác (Tôi chạy và nó xảy ra lỗi). May mắn thay, file train.pt vẫn còn ở trong thư mục /object_detection/legacy. Đơn giản chỉ cần di chuyên file train.py từ thư mục /object_detection/legacy đến thư mục /object_detection và tiếp thục thực hiện theo các bước dưới đây*
+
+Nào chúng ta bắt đầu! Chuyển đến đường dẫn \object_detection, sau đó gõ lệnh sau để bắt đầu training:
+
+```
+python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
+```
+Nếu mọi thứ đã được thiết lập đúng, TensorFLow sẽ khởi tạo quá trình đào tạo. Việc khởi tạo này cần khoảng 30 trước khi bắt đầu đào tạo. Khi quá trình đào tạo bắt đầu, nó sẽ trông như thế này:
+
+
+
+
+
+Sau mỗi bước đào tạo, hàm loss sẽ được tính ra. Nó sẽ bắt đầu với giá trị cao và giảm dần trong suốt quá trình đào tạo. Với việc đào tạo model Faster-RCNN-Inception-V2 của tôi, nó bắt đầu vào khoảng 3.0 và nhanh chóng giảm xuống dưới 0.8. Tôi khuyên bạn nên đào tạo đến khi hàm loss giảm xuống dưới 0.05, việc này cần đến 40,000 bước, hoặc 2 giờ (phụ thuộc vào cấu hình CPU và GPU của bạn). Lưu ý: Hàm mất mát sẽ khác với các model khác nhau được sử dụng. MobileNet-SSD bắt đầu với hàm loss khoảng 20, và cần được đào tạo cho đến khi giảm xuống dưới 2.
+
+Bạn có thể thấy quá trình của việc đào tạo bằng việc sử dụng TensorBoard. Để làm được điều này, mở một terminal mới của Anaconda Prompt, kích hoạt môi trường tensorflow1, chuyển đường dẫn đến thư mục C:\tensorflow1\models\research\object_detection, sau đó chạy lệnh dưới đây:
+```
+(tensorflow1) C:\tensorflow1\models\research\object_detection>tensorboard --logdir=training
+```
+Lệnh này sẽ tạo ra một trang web trên máy cục bộ của bạn tại YourPCName:6006, ta có thể xem nó qua trình duyệt web. Trang TensorBoard cung cấp thông tin và biểu đồ về quá trình đào tạo. Một trong những biểu đồ quan trọng là biểu đồ Loss, cái mà minh họa cho tổng giá trị mất mát của bộ phân loại theo thời gian.
+
+
+
+
+
+Trong quá trình đào tạo các checkpoints sẽ được lưu lại sau mỗi 5 phút. Bạn có thể kết thúc quá trìnhd đào tạo bằng cách ấn Ctrl+C trong cửa sổ terminal. Tôi thường đợi sau khi một checkpint đã được lưu sau đó mới dừng đào tạo. Bạn có thể kết thúc và bắt đầu đào tạo lại tiếp, và nó sẽ bắt đầu từ cái checkpoint gần nhất được lưu lại. Checkpoint tại bước đào tạo lớn nhất sẽ được dùng để tạo ra Inference Graph (model).
+
+### 7. Tạo Inference Graph
+Bây giờ quá trình đào tạo đã hoàn tất, bước cuối cùng là tạo ra inference graph (.pb file). Từ thư mục \object_detection, chạy lệnh dưới đây, với “XXXX” trong “model.ckpt-XXXX” bằng giá trị trong tệp .ckpt được đánh số cao nhât trong thư mục đào tạo:
+```
+python export_inference_graph.py --input_type image_tensor --pipeline_config_path training/faster_rcnn_inception_v2_pets.config --trained_checkpoint_prefix training/model.ckpt-XXXX --output_directory inference_graph
+```
+Lệnh này sẽ tạo một file frozen_inference_graph.pb trong thư mục \object_detection\inference_graph. File .pb chứa model phát hiện phân loại đối tượng.
+
+### 8. Sử dụng Object Detection Classifier mới vừa được đào tạo!
+Object Detection Classifier đã sẵn sàng để chạy! Tôi đã viết một file Python để test nó trên một ảnh, video hoặc đầu vào từ webcam.
+
+Trước khi chạy file Python, bạn cần chỉnh lại biến NUM_CLASSES bằng với số lượng class mà bạn muốn nhận diện. (Với bộ nhận diện quân bài Pinochle, vì có 6 quân bài tôi muốn nhận diện, nên NUM_CLASSES = 6.)
+
+Để test bộ phát hiện vật thể của bạn, di chuyển hình ảnh chứa vật thể đó đến thư mục \object_detection, và thay đổi đường dẫn ảnh IMAGE_NAME trong file Object_detection_image.py bằng đường dẫn hình ảnh của bạn. Ngoài ra, bạn có thể sử dụng video chứa vật thể (sử dụng file Object_detection_video.py), hoặc chỉ cần cắm USB webcam và hướng nó vào nơi chứa vật thể (sử dụng Object_detection_webcam.py).
+
+Để chạy bất kì một file test nào, gõ "idle" trong Anaconda Command Prompt (cùng với môi trường ảo “tensorflow1” đã được kích hoạt) và nhấn ENTER. Việc này sẽ mở IDLE, và từ đây, bạn có thể mở bất kỳ các kịch bản test nào và chạy chúng.
+
+Nếu mọi thứ hoạt động bình thường, trình phát hiện đối tượng sẽ được khởi tạo trong khoảng 10 giây và sau đó hiện thỉ một cửa sổ với box của vật thể đã phát hiện được trong ảnh!
+
+
+
+
+
+Nếu bạn gặp lỗi, vui lòng kiểm tra Phụ lục: tại đây chứa một danh sách các lỗi và tôi gặp trong quá trình thiết lập bộ phát hiện và phân loại đối tượng của mình. Bạn cũng có thể thử tìm kiếm trên Google về lỗi bạn gặp phải. Thường có những thông tin hữu ích trên Stack Exchange hoặc các vấn đề với TensorFlow trên GitHub.
+
+## Phụ lục: Các lỗi thường gặp
+Dường như TensorFlow Object Detection API được phát triển trên hệ điều hành Linux và hầu hết tài liệu hướng dẫn đều dành cho hệ điều hành Linux. Việc cố gắng đê các thư viện được phát triển cho Linux hoạt động được trên Windows là một thách thức. Có rất nhiều vấn đề mà tôi gặp phải khi phải cố gắng thiết lập tensorflow-gpu để đào tạo một trình phát hiện và phân loại đối tượng trên Windows 10. Phụ lục này là danh sách các lỗi mà tôi gặp phải và hướng khắc phục chúng.
+
+
+#### 1. ModuleNotFoundError: No module named 'deployment' or No module named 'nets'
+
+Lỗi này gặp phải khi bạn cố gắng chạy file object_detection_tutorial.ipynb hoặc train.py khi bạn chưa thiết lập các biến môi trường PATH và PYTHONPATH một cách chính xác. Thoát khỏi môi trường ảnh bằng cách đóng và mở lại cửa sổ Anaconda Prompt. Sau đó, thực hiện “activate tensorflow1” để mở lại môi trường, bằng cách thực hiện các lệnh đã được hướng dẫn ở bước Step 2e.
+
+Bạn có thể sử dụng “echo %PATH%” và “echo %PYTHONPATH%” để kiểm tra các biến môi trường và đảm bảo mọi thứ đã được thiết lập đúng.
+
+Ngoài ra, đảm bảo bạn đã chạy các lệnh với đường dẫn là \models\research:
+```
+setup.py build
+setup.py install
+```
+
+#### 2. ImportError: cannot import name 'preprocessor_pb2'
+
+#### ImportError: cannot import name 'string_int_label_map_pb2'
+
+#### (hoặc lỗi tương tự với các file pb2 khác)
+
+Lỗi này xảy ra khi các file (trong trường hợp này, preprocessor.proto) chưa được biên dịch. Chạy lại lệnh protoc theo chỉ dẫn ở Bước 2f. Kiểm tra thư mục \object_detection\protos để đảm bảo rằng mỗi file name_pb2.py sẽ có một file name.proto tương ứng.
+
+
+#### 3. object_detection/protos/.proto: No such file or directory
+
+Lỗi này xảy ra khi bạn cố gắng chạy lệnh:
+```
+“protoc object_detection/protos/*.proto --python_out=.”
+```
+Lệnh này được đưa ra trên trang cài đặt TensorFlow Object Detection API. Rất tiếc, nó không hoạt động trên Windows! Thay vào đó copy và paste tất các các lệnh được đưa trong Bước 2f. Có thể có cách đơn giản hơn để làm việc này, nhưng tôi chưa tìm ra lệnh đó là gì.
+
+#### 4. Unsuccessful TensorSliceReader constructor: Failed to get "file path" … Tên tệp, tên thư mục, hoặc số lượng nhãn không chính xác.
+
+Lỗi này xảy ra khi đường dẫn trong file cấu hình hình đào tạo (faster_rcnn_inception_v2_pets.config hoặc tương tự) chư được nhập bằng dấu gạch chéo ngược thay vì dấu gạch chéo xuôi. Mở file .config và đảm bảo rằng tất cả các đường dẫn tuân theo định dạng sau:
+```
+“C:/path/to/model.file”
+```
+
+#### 5. ValueError: Tried to convert 't' to a tensor and failed. Error: Argument must be a dense tensor: range(0, 3) - got shape [3], but wanted [].
+
+Vấn đề với models/research/object_detection/utils/learning_schedules.py hiện tại nó là
+```
+rate_index = tf.reduce_max(tf.where(tf.greater_equal(global_step, boundaries),
+ range(num_boundaries),
+ [0] * num_boundaries))
+```
+Sửa lại list() xung quanh range() giống như thế này:
+
+```
+rate_index = tf.reduce_max(tf.where(tf.greater_equal(global_step, boundaries),
+ list(range(num_boundaries)),
+ [0] * num_boundaries))
+```
+
+[Ref: Tensorflow Issue#3705](https://github.com/tensorflow/models/issues/3705#issuecomment-375563179)
+
+#### 6. ImportError: DLL load failed: The specified procedure could not be found. (or other DLL-related errors)
+Lỗi này xảy ra do các phiên bản CUDA và cuDNN bạn cài đặt không tương thích với phiên bản TensorFLow bạn đang sử dụng. Cách dễ nhất để khắc phục lỗi này là sử dụng các gói cudatookit của Anaconda thay vì cài đặt thủ công CUDA và cuDNN. Nếu bạn gặp phải lỗi này, hãy thử tạo một Anaconda virtual environment mới:
+```
+conda create -n tensorflow2 pip python=3.5
+```
+Sau đó, khi đã kích hoạt môi trường, cài đặt TensorFlow sử dụng CONDA thay vì PIP:
+```
+conda install tensorflow-gpu
+```
+Sau đó, thực hiện lại hướng dẫn này từ Bước 2 ( nhưng bạn có thể bỏ qua việc cài đặt TensorFlow tại Bước 2d).
+
+#### 7. Tại Bước 2g, Jupyter Notebook chạy mà không xảy ra lỗi, nhưng không có hình ảnh nào được hiển thị vào cuối cùng.
+Nếu bạn chạy Jupyter Notebook mà không gặp bất kì lỗi nào, nhưng các hình ảnh được gán nhãn vấn không xuất hiện, thử cách sau: truy cập file object_detection/utils/visualization_utils.py và comment các câu lệnh tại dòng 29 và 30 cái mà bao gồm matplotlib. Sau đó, thử chạy lại Jupyter notebook. ( File visualization_utils.py được thay đổi khá nhiều, do đó nó có thể không chính xác tại dòng 29 và 30.)
diff --git a/translate/doc/C_drive_tensorflow1.jpg b/translate/doc/C_drive_tensorflow1.jpg
new file mode 100644
index 00000000..ad178004
Binary files /dev/null and b/translate/doc/C_drive_tensorflow1.jpg differ
diff --git a/translate/doc/YouTube video.jpg b/translate/doc/YouTube video.jpg
new file mode 100644
index 00000000..01954365
Binary files /dev/null and b/translate/doc/YouTube video.jpg differ
diff --git a/translate/doc/collage.jpg b/translate/doc/collage.jpg
new file mode 100644
index 00000000..9f2cda2d
Binary files /dev/null and b/translate/doc/collage.jpg differ
diff --git a/translate/doc/detector1.jpg b/translate/doc/detector1.jpg
new file mode 100644
index 00000000..49e4b629
Binary files /dev/null and b/translate/doc/detector1.jpg differ
diff --git a/translate/doc/detector2.jpg b/translate/doc/detector2.jpg
new file mode 100644
index 00000000..546a47b7
Binary files /dev/null and b/translate/doc/detector2.jpg differ
diff --git a/translate/doc/jupyter_notebook_dogs.jpg b/translate/doc/jupyter_notebook_dogs.jpg
new file mode 100644
index 00000000..aee95de4
Binary files /dev/null and b/translate/doc/jupyter_notebook_dogs.jpg differ
diff --git a/translate/doc/labels.jpg b/translate/doc/labels.jpg
new file mode 100644
index 00000000..905c7184
Binary files /dev/null and b/translate/doc/labels.jpg differ
diff --git a/translate/doc/loss_graph.JPG b/translate/doc/loss_graph.JPG
new file mode 100644
index 00000000..f05b6fac
Binary files /dev/null and b/translate/doc/loss_graph.JPG differ
diff --git a/translate/doc/models.jpg b/translate/doc/models.jpg
new file mode 100644
index 00000000..3072c5cc
Binary files /dev/null and b/translate/doc/models.jpg differ
diff --git a/translate/doc/object_detection_directory.jpg b/translate/doc/object_detection_directory.jpg
new file mode 100644
index 00000000..7385476d
Binary files /dev/null and b/translate/doc/object_detection_directory.jpg differ
diff --git a/translate/doc/rcnn_vs_ssd.jpg b/translate/doc/rcnn_vs_ssd.jpg
new file mode 100644
index 00000000..f000bf1f
Binary files /dev/null and b/translate/doc/rcnn_vs_ssd.jpg differ
diff --git a/translate/doc/training.jpg b/translate/doc/training.jpg
new file mode 100644
index 00000000..69d26573
Binary files /dev/null and b/translate/doc/training.jpg differ