You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+98-3
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ TensorFlow is an open source library for numerical computation, specializing in
24
24
### Prepare data:
25
25
You need one dataset for tranning. If you want to classifier flower, flag, car,... you need 1 dataset of them. <br>
26
26
Guide:
27
-
* Fatkun downloader chrome extension: go google, type what you need, click tab images (there are many images), then click Fatkun logo, you NEED CLEAN the DATASET, delete all images not involve, download all of extractly you need.
27
+
* Fatkun downloader chrome extension: go google, type what you need, click tab images (there are many images), then click Fatkun logo, you NEED CLEAN the DATASET, delete all images not involve, download all of extractly you need. Copy all of images into 1 folder that's name is comom name of label of them.
28
28
29
29
### Prepare environment:
30
30
To work with tensorflow and android, you need:
@@ -45,8 +45,103 @@ Install and run docker (all in one) every you need at here:
45
45
46
46
When you downloaded, run this command to install docker container:
47
47
48
-
<b>docker run -it -p 8888:8888 -v $HOME/tf_files:/tf_files tensorflow/tensorflow:nightly-devel</b>
48
+
> docker run -it -p 8888:8888 -v $HOME/tf_files:/tf_files tensorflow/tensorflow:nightly-devel</b>
49
49
50
-
It share folder tf_files at your main computer with docker container
50
+
It share folder tf_files at your main computer with docker container. Update tensor:
51
+
52
+
> pip install --upgrade "tensorflow==1.7.*"
53
+
54
+
Your structure folder:
55
+
56
+
tf_files
57
+
58
+
---|-----script
59
+
60
+
---|-----photos
61
+
62
+
---|-----tf_files
63
+
64
+
tf_files at root of apps, script contains files .py that train and optimize the model, file photos contains folders of images input, tf_files contains result of next steps (files model, label, bottleneck,...)
The retrain script is from the TensorFlow Hub repo, but it is not installed as part of the pip package. So for simplicity I've included it in the codelab repository. You can run the script using the python command. Take a minute to skim its "help".
77
+
78
+
> python -m scripts.retrain -h
79
+
80
+
Start your retraining with one big command (note the --summaries_dir option, sending training progress reports to the directory that tensorboard is monitoring) :
Note that: --how_many_training_steps=500, you can increase this number to get higher accuracy, ${ARCHITECTURE} you change it into inception_v3 (i use inceptionv3) or mobilenet, softmax,... --image_dir=tf_files/flower_photo, you must change this folder name by the folder name of photos you download at before step.
93
+
94
+
retrained_graph.pb & retrained_labels.txt is the most important file of this program.
95
+
96
+
Next, verify that the model is producing sane results before starting to modifying it.
97
+
98
+
The scripts/ directory contains a simple command line script, label_image.py, to test the network. Now we'll test:
Optimize for inference: To avoid problems caused by unsupported training ops, the TensorFlow installation includes a tool, optimize_for_inference, that removes all nodes that aren't needed for a given set of input and outputs.
105
+
106
+
The script also does a few other optimizations that help speed up the model, such as merging explicit batch normalization operations into the convolutional weights to reduce the number of calculations. This can give a 30% speed up, depending on the input model. Here's how you run the script:
Quantize the network weights: Applying an almost identical process to your neural network weights has a similar effect. It gives a lot more repetition for the compression algorithm to take advantage of, while reducing the precision by a small amount (typically less than a 1% drop in precision).
115
+
116
+
It does this without any changes to the structure of the network, it simply quantizes the constants in place.
117
+
118
+
Now use the quantize_graph script to apply these changes:
119
+
120
+
> python -m scripts.quantize_graph \
121
+
> --input=tf_files/optimized_graph.pb \
122
+
> --output=tf_files/rounded_graph.pb \
123
+
> --output_node_names=final_result \
124
+
> --mode=weights_rounded
125
+
126
+
## Add your model files to the project
127
+
The demo project is configured to search for a graph.pb, and a labels.txt files in the android/tfmobile/assets directory. Replace those two files with your versions. The following command accomplishes this task:
0 commit comments