├── .gitignore
├── 01_train_data
├── .gitkeep
├── 000001.jpg
├── 000002.jpg
├── 000003.jpg
├── 000004.jpg
├── 000005.jpg
├── 000006.jpg
├── 000007.jpg
├── 000008.jpg
├── 000009.jpg
├── 000010.jpg
├── 000011.jpg
├── 000012.jpg
├── 000013.jpg
├── 000014.jpg
├── 000015.jpg
├── 000016.jpg
├── 000017.jpg
├── 000018.jpg
├── 000019.jpg
├── 000020.jpg
├── 000021.jpg
├── 000022.jpg
├── 000023.jpg
├── 000024.jpg
├── 000025.jpg
├── 000026.jpg
├── 000027.jpg
├── 000028.jpg
├── 000029.jpg
├── 000030.jpg
├── 000031.jpg
├── 000032.jpg
├── 000033.jpg
├── 000034.jpg
├── 000035.jpg
├── 000036.jpg
├── 000037.jpg
├── 000038.jpg
├── 000039.jpg
├── 000040.jpg
├── 000041.jpg
├── 000042.jpg
├── 000043.jpg
├── 000044.jpg
├── 000045.jpg
├── 000046.jpg
├── 000047.jpg
├── 000048.jpg
├── 000049.jpg
└── 000050.jpg
├── 02_tfrecord
└── .gitkeep
├── 03_pretrained_model
└── efficientdet_d0_coco17_tpu-32
│ ├── checkpoint
│ ├── checkpoint
│ ├── ckpt-0.data-00000-of-00001
│ └── ckpt-0.index
│ ├── pipeline.config
│ └── saved_model
│ ├── saved_model.pb
│ └── variables
│ ├── variables.data-00000-of-00001
│ └── variables.index
├── 04_test_data
├── .gitkeep
├── 000101.jpg
├── 000102.jpg
├── 000103.jpg
├── 000104.jpg
├── 000105.jpg
├── 000106.jpg
├── 000107.jpg
├── 000108.jpg
├── 000109.jpg
├── 000110.jpg
├── 000111.jpg
├── 000112.jpg
├── 000113.jpg
├── 000114.jpg
├── 000115.jpg
├── 000116.jpg
├── 000117.jpg
├── 000118.jpg
├── 000119.jpg
├── 000120.jpg
├── 000121.jpg
├── 000122.jpg
├── 000123.jpg
├── 000124.jpg
├── 000125.jpg
├── 000126.jpg
├── 000127.jpg
├── 000128.jpg
├── 000129.jpg
├── 000130.jpg
├── 000131.jpg
├── 000132.jpg
├── 000133.jpg
├── 000134.jpg
├── 000135.jpg
├── 000136.jpg
├── 000137.jpg
├── 000138.jpg
├── 000139.jpg
├── 000140.jpg
├── 000141.jpg
├── 000142.jpg
├── 000143.jpg
├── 000144.jpg
├── 000145.jpg
├── 000146.jpg
├── 000147.jpg
├── 000148.jpg
├── 000149.jpg
└── 000150.jpg
├── LICENSE
├── README.md
├── README_EN.md
└── [Colaboratory]Tensorflow2-ObjectDetectionAPI-Colab-Hands-On.ipynb
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | *.py,cover
51 | .hypothesis/
52 | .pytest_cache/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 |
64 | # Flask stuff:
65 | instance/
66 | .webassets-cache
67 |
68 | # Scrapy stuff:
69 | .scrapy
70 |
71 | # Sphinx documentation
72 | docs/_build/
73 |
74 | # PyBuilder
75 | target/
76 |
77 | # Jupyter Notebook
78 | .ipynb_checkpoints
79 |
80 | # IPython
81 | profile_default/
82 | ipython_config.py
83 |
84 | # pyenv
85 | .python-version
86 |
87 | # pipenv
88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
91 | # install all needed dependencies.
92 | #Pipfile.lock
93 |
94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95 | __pypackages__/
96 |
97 | # Celery stuff
98 | celerybeat-schedule
99 | celerybeat.pid
100 |
101 | # SageMath parsed files
102 | *.sage.py
103 |
104 | # Environments
105 | .env
106 | .venv
107 | env/
108 | venv/
109 | ENV/
110 | env.bak/
111 | venv.bak/
112 |
113 | # Spyder project settings
114 | .spyderproject
115 | .spyproject
116 |
117 | # Rope project settings
118 | .ropeproject
119 |
120 | # mkdocs documentation
121 | /site
122 |
123 | # mypy
124 | .mypy_cache/
125 | .dmypy.json
126 | dmypy.json
127 |
128 | # Pyre type checker
129 | .pyre/
130 |
131 | # bat
132 | *.bat
133 |
134 | # VoTT
135 | *.vott
136 | *-asset.json
137 | *.tfrecord
138 | tf_label_map.pbtxt
139 |
140 | # pipeline.config
141 | pipeline.config
--------------------------------------------------------------------------------
/01_train_data/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/.gitkeep
--------------------------------------------------------------------------------
/01_train_data/000001.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000001.jpg
--------------------------------------------------------------------------------
/01_train_data/000002.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000002.jpg
--------------------------------------------------------------------------------
/01_train_data/000003.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000003.jpg
--------------------------------------------------------------------------------
/01_train_data/000004.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000004.jpg
--------------------------------------------------------------------------------
/01_train_data/000005.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000005.jpg
--------------------------------------------------------------------------------
/01_train_data/000006.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000006.jpg
--------------------------------------------------------------------------------
/01_train_data/000007.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000007.jpg
--------------------------------------------------------------------------------
/01_train_data/000008.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000008.jpg
--------------------------------------------------------------------------------
/01_train_data/000009.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000009.jpg
--------------------------------------------------------------------------------
/01_train_data/000010.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000010.jpg
--------------------------------------------------------------------------------
/01_train_data/000011.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000011.jpg
--------------------------------------------------------------------------------
/01_train_data/000012.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000012.jpg
--------------------------------------------------------------------------------
/01_train_data/000013.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000013.jpg
--------------------------------------------------------------------------------
/01_train_data/000014.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000014.jpg
--------------------------------------------------------------------------------
/01_train_data/000015.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000015.jpg
--------------------------------------------------------------------------------
/01_train_data/000016.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000016.jpg
--------------------------------------------------------------------------------
/01_train_data/000017.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000017.jpg
--------------------------------------------------------------------------------
/01_train_data/000018.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000018.jpg
--------------------------------------------------------------------------------
/01_train_data/000019.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000019.jpg
--------------------------------------------------------------------------------
/01_train_data/000020.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000020.jpg
--------------------------------------------------------------------------------
/01_train_data/000021.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000021.jpg
--------------------------------------------------------------------------------
/01_train_data/000022.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000022.jpg
--------------------------------------------------------------------------------
/01_train_data/000023.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000023.jpg
--------------------------------------------------------------------------------
/01_train_data/000024.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000024.jpg
--------------------------------------------------------------------------------
/01_train_data/000025.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000025.jpg
--------------------------------------------------------------------------------
/01_train_data/000026.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000026.jpg
--------------------------------------------------------------------------------
/01_train_data/000027.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000027.jpg
--------------------------------------------------------------------------------
/01_train_data/000028.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000028.jpg
--------------------------------------------------------------------------------
/01_train_data/000029.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000029.jpg
--------------------------------------------------------------------------------
/01_train_data/000030.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000030.jpg
--------------------------------------------------------------------------------
/01_train_data/000031.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000031.jpg
--------------------------------------------------------------------------------
/01_train_data/000032.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000032.jpg
--------------------------------------------------------------------------------
/01_train_data/000033.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000033.jpg
--------------------------------------------------------------------------------
/01_train_data/000034.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000034.jpg
--------------------------------------------------------------------------------
/01_train_data/000035.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000035.jpg
--------------------------------------------------------------------------------
/01_train_data/000036.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000036.jpg
--------------------------------------------------------------------------------
/01_train_data/000037.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000037.jpg
--------------------------------------------------------------------------------
/01_train_data/000038.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000038.jpg
--------------------------------------------------------------------------------
/01_train_data/000039.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000039.jpg
--------------------------------------------------------------------------------
/01_train_data/000040.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000040.jpg
--------------------------------------------------------------------------------
/01_train_data/000041.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000041.jpg
--------------------------------------------------------------------------------
/01_train_data/000042.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000042.jpg
--------------------------------------------------------------------------------
/01_train_data/000043.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000043.jpg
--------------------------------------------------------------------------------
/01_train_data/000044.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000044.jpg
--------------------------------------------------------------------------------
/01_train_data/000045.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000045.jpg
--------------------------------------------------------------------------------
/01_train_data/000046.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000046.jpg
--------------------------------------------------------------------------------
/01_train_data/000047.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000047.jpg
--------------------------------------------------------------------------------
/01_train_data/000048.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000048.jpg
--------------------------------------------------------------------------------
/01_train_data/000049.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000049.jpg
--------------------------------------------------------------------------------
/01_train_data/000050.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/01_train_data/000050.jpg
--------------------------------------------------------------------------------
/02_tfrecord/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/02_tfrecord/.gitkeep
--------------------------------------------------------------------------------
/03_pretrained_model/efficientdet_d0_coco17_tpu-32/checkpoint/checkpoint:
--------------------------------------------------------------------------------
1 | model_checkpoint_path: "ckpt-0"
2 | all_model_checkpoint_paths: "ckpt-0"
3 | all_model_checkpoint_timestamps: 1594350062.036581
4 | last_preserved_timestamp: 1594350060.3811114
5 |
--------------------------------------------------------------------------------
/03_pretrained_model/efficientdet_d0_coco17_tpu-32/checkpoint/ckpt-0.data-00000-of-00001:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/03_pretrained_model/efficientdet_d0_coco17_tpu-32/checkpoint/ckpt-0.data-00000-of-00001
--------------------------------------------------------------------------------
/03_pretrained_model/efficientdet_d0_coco17_tpu-32/checkpoint/ckpt-0.index:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/03_pretrained_model/efficientdet_d0_coco17_tpu-32/checkpoint/ckpt-0.index
--------------------------------------------------------------------------------
/03_pretrained_model/efficientdet_d0_coco17_tpu-32/pipeline.config:
--------------------------------------------------------------------------------
1 | model {
2 | ssd {
3 | num_classes: 90
4 | image_resizer {
5 | keep_aspect_ratio_resizer {
6 | min_dimension: 512
7 | max_dimension: 512
8 | pad_to_max_dimension: true
9 | }
10 | }
11 | feature_extractor {
12 | type: "ssd_efficientnet-b0_bifpn_keras"
13 | conv_hyperparams {
14 | regularizer {
15 | l2_regularizer {
16 | weight: 3.9999998989515007e-05
17 | }
18 | }
19 | initializer {
20 | truncated_normal_initializer {
21 | mean: 0.0
22 | stddev: 0.029999999329447746
23 | }
24 | }
25 | activation: SWISH
26 | batch_norm {
27 | decay: 0.9900000095367432
28 | scale: true
29 | epsilon: 0.0010000000474974513
30 | }
31 | force_use_bias: true
32 | }
33 | bifpn {
34 | min_level: 3
35 | max_level: 7
36 | num_iterations: 3
37 | num_filters: 64
38 | }
39 | }
40 | box_coder {
41 | faster_rcnn_box_coder {
42 | y_scale: 1.0
43 | x_scale: 1.0
44 | height_scale: 1.0
45 | width_scale: 1.0
46 | }
47 | }
48 | matcher {
49 | argmax_matcher {
50 | matched_threshold: 0.5
51 | unmatched_threshold: 0.5
52 | ignore_thresholds: false
53 | negatives_lower_than_unmatched: true
54 | force_match_for_each_row: true
55 | use_matmul_gather: true
56 | }
57 | }
58 | similarity_calculator {
59 | iou_similarity {
60 | }
61 | }
62 | box_predictor {
63 | weight_shared_convolutional_box_predictor {
64 | conv_hyperparams {
65 | regularizer {
66 | l2_regularizer {
67 | weight: 3.9999998989515007e-05
68 | }
69 | }
70 | initializer {
71 | random_normal_initializer {
72 | mean: 0.0
73 | stddev: 0.009999999776482582
74 | }
75 | }
76 | activation: SWISH
77 | batch_norm {
78 | decay: 0.9900000095367432
79 | scale: true
80 | epsilon: 0.0010000000474974513
81 | }
82 | force_use_bias: true
83 | }
84 | depth: 64
85 | num_layers_before_predictor: 3
86 | kernel_size: 3
87 | class_prediction_bias_init: -4.599999904632568
88 | use_depthwise: true
89 | }
90 | }
91 | anchor_generator {
92 | multiscale_anchor_generator {
93 | min_level: 3
94 | max_level: 7
95 | anchor_scale: 4.0
96 | aspect_ratios: 1.0
97 | aspect_ratios: 2.0
98 | aspect_ratios: 0.5
99 | scales_per_octave: 3
100 | }
101 | }
102 | post_processing {
103 | batch_non_max_suppression {
104 | score_threshold: 9.99999993922529e-09
105 | iou_threshold: 0.5
106 | max_detections_per_class: 100
107 | max_total_detections: 100
108 | }
109 | score_converter: SIGMOID
110 | }
111 | normalize_loss_by_num_matches: true
112 | loss {
113 | localization_loss {
114 | weighted_smooth_l1 {
115 | }
116 | }
117 | classification_loss {
118 | weighted_sigmoid_focal {
119 | gamma: 1.5
120 | alpha: 0.25
121 | }
122 | }
123 | classification_weight: 1.0
124 | localization_weight: 1.0
125 | }
126 | encode_background_as_zeros: true
127 | normalize_loc_loss_by_codesize: true
128 | inplace_batchnorm_update: true
129 | freeze_batchnorm: false
130 | add_background_class: false
131 | }
132 | }
133 | train_config {
134 | batch_size: 128
135 | data_augmentation_options {
136 | random_horizontal_flip {
137 | }
138 | }
139 | data_augmentation_options {
140 | random_scale_crop_and_pad_to_square {
141 | output_size: 512
142 | scale_min: 0.10000000149011612
143 | scale_max: 2.0
144 | }
145 | }
146 | sync_replicas: true
147 | optimizer {
148 | momentum_optimizer {
149 | learning_rate {
150 | cosine_decay_learning_rate {
151 | learning_rate_base: 0.07999999821186066
152 | total_steps: 300000
153 | warmup_learning_rate: 0.0010000000474974513
154 | warmup_steps: 2500
155 | }
156 | }
157 | momentum_optimizer_value: 0.8999999761581421
158 | }
159 | use_moving_average: false
160 | }
161 | fine_tune_checkpoint: "PATH_TO_BE_CONFIGURED"
162 | num_steps: 300000
163 | startup_delay_steps: 0.0
164 | replicas_to_aggregate: 8
165 | max_number_of_boxes: 100
166 | unpad_groundtruth_tensors: false
167 | fine_tune_checkpoint_type: "classification"
168 | use_bfloat16: true
169 | fine_tune_checkpoint_version: V2
170 | }
171 | train_input_reader: {
172 | label_map_path: "PATH_TO_BE_CONFIGURED/label_map.txt"
173 | tf_record_input_reader {
174 | input_path: "PATH_TO_BE_CONFIGURED/train2017-?????-of-00256.tfrecord"
175 | }
176 | }
177 |
178 | eval_config: {
179 | metrics_set: "coco_detection_metrics"
180 | use_moving_averages: false
181 | batch_size: 1;
182 | }
183 |
184 | eval_input_reader: {
185 | label_map_path: "PATH_TO_BE_CONFIGURED/label_map.txt"
186 | shuffle: false
187 | num_epochs: 1
188 | tf_record_input_reader {
189 | input_path: "PATH_TO_BE_CONFIGURED/val2017-?????-of-00032.tfrecord"
190 | }
191 | }
192 |
--------------------------------------------------------------------------------
/03_pretrained_model/efficientdet_d0_coco17_tpu-32/saved_model/saved_model.pb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/03_pretrained_model/efficientdet_d0_coco17_tpu-32/saved_model/saved_model.pb
--------------------------------------------------------------------------------
/03_pretrained_model/efficientdet_d0_coco17_tpu-32/saved_model/variables/variables.data-00000-of-00001:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/03_pretrained_model/efficientdet_d0_coco17_tpu-32/saved_model/variables/variables.data-00000-of-00001
--------------------------------------------------------------------------------
/03_pretrained_model/efficientdet_d0_coco17_tpu-32/saved_model/variables/variables.index:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/03_pretrained_model/efficientdet_d0_coco17_tpu-32/saved_model/variables/variables.index
--------------------------------------------------------------------------------
/04_test_data/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/.gitkeep
--------------------------------------------------------------------------------
/04_test_data/000101.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000101.jpg
--------------------------------------------------------------------------------
/04_test_data/000102.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000102.jpg
--------------------------------------------------------------------------------
/04_test_data/000103.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000103.jpg
--------------------------------------------------------------------------------
/04_test_data/000104.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000104.jpg
--------------------------------------------------------------------------------
/04_test_data/000105.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000105.jpg
--------------------------------------------------------------------------------
/04_test_data/000106.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000106.jpg
--------------------------------------------------------------------------------
/04_test_data/000107.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000107.jpg
--------------------------------------------------------------------------------
/04_test_data/000108.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000108.jpg
--------------------------------------------------------------------------------
/04_test_data/000109.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000109.jpg
--------------------------------------------------------------------------------
/04_test_data/000110.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000110.jpg
--------------------------------------------------------------------------------
/04_test_data/000111.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000111.jpg
--------------------------------------------------------------------------------
/04_test_data/000112.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000112.jpg
--------------------------------------------------------------------------------
/04_test_data/000113.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000113.jpg
--------------------------------------------------------------------------------
/04_test_data/000114.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000114.jpg
--------------------------------------------------------------------------------
/04_test_data/000115.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000115.jpg
--------------------------------------------------------------------------------
/04_test_data/000116.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000116.jpg
--------------------------------------------------------------------------------
/04_test_data/000117.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000117.jpg
--------------------------------------------------------------------------------
/04_test_data/000118.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000118.jpg
--------------------------------------------------------------------------------
/04_test_data/000119.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000119.jpg
--------------------------------------------------------------------------------
/04_test_data/000120.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000120.jpg
--------------------------------------------------------------------------------
/04_test_data/000121.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000121.jpg
--------------------------------------------------------------------------------
/04_test_data/000122.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000122.jpg
--------------------------------------------------------------------------------
/04_test_data/000123.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000123.jpg
--------------------------------------------------------------------------------
/04_test_data/000124.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000124.jpg
--------------------------------------------------------------------------------
/04_test_data/000125.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000125.jpg
--------------------------------------------------------------------------------
/04_test_data/000126.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000126.jpg
--------------------------------------------------------------------------------
/04_test_data/000127.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000127.jpg
--------------------------------------------------------------------------------
/04_test_data/000128.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000128.jpg
--------------------------------------------------------------------------------
/04_test_data/000129.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000129.jpg
--------------------------------------------------------------------------------
/04_test_data/000130.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000130.jpg
--------------------------------------------------------------------------------
/04_test_data/000131.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000131.jpg
--------------------------------------------------------------------------------
/04_test_data/000132.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000132.jpg
--------------------------------------------------------------------------------
/04_test_data/000133.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000133.jpg
--------------------------------------------------------------------------------
/04_test_data/000134.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000134.jpg
--------------------------------------------------------------------------------
/04_test_data/000135.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000135.jpg
--------------------------------------------------------------------------------
/04_test_data/000136.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000136.jpg
--------------------------------------------------------------------------------
/04_test_data/000137.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000137.jpg
--------------------------------------------------------------------------------
/04_test_data/000138.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000138.jpg
--------------------------------------------------------------------------------
/04_test_data/000139.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000139.jpg
--------------------------------------------------------------------------------
/04_test_data/000140.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000140.jpg
--------------------------------------------------------------------------------
/04_test_data/000141.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000141.jpg
--------------------------------------------------------------------------------
/04_test_data/000142.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000142.jpg
--------------------------------------------------------------------------------
/04_test_data/000143.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000143.jpg
--------------------------------------------------------------------------------
/04_test_data/000144.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000144.jpg
--------------------------------------------------------------------------------
/04_test_data/000145.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000145.jpg
--------------------------------------------------------------------------------
/04_test_data/000146.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000146.jpg
--------------------------------------------------------------------------------
/04_test_data/000147.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000147.jpg
--------------------------------------------------------------------------------
/04_test_data/000148.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000148.jpg
--------------------------------------------------------------------------------
/04_test_data/000149.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000149.jpg
--------------------------------------------------------------------------------
/04_test_data/000150.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/50ecb0035567f92385b497b6059ad8aae59411a2/04_test_data/000150.jpg
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 KazuhitoTakahashi
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [Japanese/[English](https://github.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/blob/master/README_EN.md)]
2 | # Tensorflow2-ObjectDetectionAPI-Colab-Hands-On
3 | 
4 |
5 | Tensorflow2 Object Detection APIのハンズオン用資料です。
6 | VoTTでのアノテーションをローカルPCで実施し、学習~推論はColaboratory上で実施します。
7 | 以下の内容を含みます。
8 | * 学習用データセット ※アノテーション未実施
9 | * テスト用データセット
10 | * ファインチューニング用モデル(EffientDet D0)
11 | * Colaboratory用スクリプト(環境設定、モデル訓練、推論結果確認)
12 |
13 |
14 | ディレクトリ構成
15 |
16 |
17 | │ [Colaboratory]Tensorflow2_ObjectDetectionAPI_Colab_Hands_On.ipynb
18 | |
19 | ├─01_train_data─┬─000000.jpg
20 | │ │ :
21 | │ └─000049.jpg
22 | │
23 | ├─02_tfrecord
24 | │
25 | ├─03_pretrained_model─efficientdet_d0_coco17_tpu-32─┬─pipeline.config
26 | │ ├─checkpoint──┬─checkpoint
27 | │ │ ├─ckpt-0.data-00000-of-00001
28 | │ │ └─ckpt-0.index
29 | │ └─saved_model─┬─saved_model.pb
30 | │ └─variables─┬─variables.data-00000-of-00001
31 | │ └─variables.index
32 | │
33 | └─04_test_data─┬─000050.jpg
34 | │ :
35 | └─000099.jpg
36 |
37 |
38 |
39 | #### [Colaboratory]Tensorflow2_ObjectDetectionAPI_Colab_Hands_On.ipynb
40 | Colaboratory用スクリプト(環境設定、モデル訓練、推論結果確認)
41 |
42 | #### 01_train_data
43 | 学習用データセット ※アノテーション未実施
44 |
45 | #### 02_tfrecord
46 | アノテーション実施済みTFRecord格納先
47 |
48 | #### 03_pretrained_mode
49 | ファインチューニング用モデル(EffientDet D0)
50 |
51 | #### 04_test_data
52 | テスト用データセット
53 |
54 |
55 |
56 | # Requirement
57 | Tensorflow 2.3.0
58 |
59 | # Overview
60 | 2時間程度のボリュームの想定です。
61 | 1. VoTT:アノテーション(約30~60分)
62 | 1. Colaboratory:Object Detection API設定
63 | 1. パイプラインコンフィグ修正
64 | 1. Colaboratory:モデル訓練(約25分)
65 | 1. Colaboratory:推論
66 |
67 | # Preparations
68 | 事前準備として以下が必要です。
69 | * このリポジトリのローカル環境へのクローン
70 | * [VoTT](https://github.com/microsoft/VoTT)のインストール
71 | * Googleアカウント(Google Colaboratory、Googleドライブで使用)
72 |
73 | # 1. VoTT:アノテーション
74 | [VoTT](https://github.com/microsoft/VoTT)を使用してアノテーションを行い、TFRecord形式で出力します。
75 |
76 |
77 | VoTTのプロジェクト設定
78 |
79 | #### 「新規プロジェクト」を選択する
80 | 
81 | #### プロジェクト設定を行う
82 | 表示名:Tensorflow2-ObjectDetectionAPI-Colab-Hands-On
83 | セキュリティトークン:Generate New Security Token
84 | ソース接続:「Add Connection」を押下
85 | 
86 | #### ソース接続の接続設定を行う
87 | 表示名:Tensorflow2-ObjectDetectionAPI-Colab-Hands-On-TrainData
88 | 
89 | プロバイダー:ローカルファイルシステム
90 | 
91 | フォルダーパス:クローンしたリポジトリの「01_train_data」ディレクトリを指定
92 | 
93 | #### ターゲット接続の接続設定を行う
94 | ターゲット接続:Add Connection
95 | 
96 | 表示名:Tensorflow2-ObjectDetectionAPI-Colab-Hands-On-TFRecord
97 | プロバイダー:ローカルファイルシステム
98 | フォルダーパス:クローンしたリポジトリの「02_tfrecord」ディレクトリを指定
99 | 
100 |
102 | #### タグを追加し設定を保存する
103 | タグ:「Fish」を追加
104 | 「プロジェクトを保存」を押下
105 | 
106 |
107 |
108 |
109 | VoTTを使用してアノテーションを実施
110 |
111 | #### マウス左ドラッグで魚を選択する
112 | 
113 | #### TAGSから「Fish」を選択する
114 | 南京錠のマークを選択しておくことでタグを使用するタグを固定することが可能
115 | 
116 |
118 |
119 |
120 |
121 | TFRecordエクスポート
122 |
123 | #### エクスポート設定
124 | プロバイダー:Tensorflow レコード
125 | アセットの状態:タグ付きアセットのみ
126 | 「エクスポート設定を保存」を押下する
127 | 
128 | アノテーション画面からエクスポートマークを押下し、TFRecordをエクスポートする。
129 | 
130 |
131 |
132 |
133 | 注意事項(詳細確認中)
134 |
135 | 画像の端の対象をアノテーションする際に、以下のように端から少し隙間を設けてください。
136 | 
137 | 問題の詳細は確認中ですが、隙間を開けずにアノテーションをすると、
138 | VoTTの問題かTensorflowの問題か、モデル学習時に以下のエラーが発生します。
139 |
140 | W0921 13:29:32.965700 140050120722176 optimizer_v2.py:1275] Gradients do not exist for variables ['top_bn/gamma:0', 'top_bn/beta:0'] when minimizing the loss.
141 | Traceback (most recent call last):
142 | File "object_detection/model_main_tf2.py", line 113, in
143 | tf.compat.v1.app.run()
144 | File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/platform/app.py", line 40, in run
145 | _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
146 | File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 300, in run
147 | _run_main(main, args)
148 | File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 251, in _run_main
149 | sys.exit(main(argv))
150 | File "object_detection/model_main_tf2.py", line 110, in main
151 | record_summaries=FLAGS.record_summaries)
152 | File "/usr/local/lib/python3.6/dist-packages/object_detection/model_lib_v2.py", line 639, in train_loop
153 | loss = _dist_train_step(train_input_iter)
154 | File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py", line 780, in __call__
155 | result = self._call(*args, **kwds)
156 | File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py", line 807, in _call
157 | return self._stateless_fn(*args, **kwds) # pylint: disable=not-callable
158 | File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py", line 2829, in __call__
159 | return graph_function._filtered_call(args, kwargs) # pylint: disable=protected-access
160 | File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py", line 1848, in _filtered_call
161 | cancellation_manager=cancellation_manager)
162 | File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py", line 1924, in _call_flat
163 | ctx, args, cancellation_manager=cancellation_manager))
164 | File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py", line 550, in call
165 | ctx=ctx)
166 | File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/execute.py", line 60, in quick_execute
167 | inputs, attrs, num_outputs)
168 | tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
169 | (0) Invalid argument: assertion failed: [[0.15956609][0.103383526][0.109880842]...] [[0.23180081][0.133959055][0.132812485]...]
170 | [[{{node Assert_1/AssertGuard/else/_35/Assert_1/AssertGuard/Assert}}]]
171 | [[MultiDeviceIteratorGetNextFromShard]]
172 | [[RemoteCall]]
173 | [[IteratorGetNext]]
174 | [[Loss/localization_loss_1/write_summary/summary_cond/pivot_t/_4/_111]]
175 | (1) Invalid argument: assertion failed: [[0.15956609][0.103383526][0.109880842]...] [[0.23180081][0.133959055][0.132812485]...]
176 | [[{{node Assert_1/AssertGuard/else/_35/Assert_1/AssertGuard/Assert}}]]
177 | [[MultiDeviceIteratorGetNextFromShard]]
178 | [[RemoteCall]]
179 | [[IteratorGetNext]]
180 |
181 |
182 |
183 | # 2. Colaboratory:Object Detection API設定
184 | [](https://colab.research.google.com/github/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/blob/master/[Colaboratory]Tensorflow2-ObjectDetectionAPI-Colab-Hands-On.ipynb)
185 | 以降の作業はGoogle Colaboratory上で実施します。※パイプラインコンフィグ修正をのぞく
186 | [Open In Colab]リンクからノートブックを開き、以下の順に実行してください。
187 | * Google Driveマウント
188 | * Tensorflow Object Detection API設定
189 | * Tensorflow2-ObjectDetectionAPI-Colab-Hands-Onリポジトリクローン
190 |
191 | # 3.TFRecordアップロード
192 | 「Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/02_tfrecord」に
VoTTからエクスポートしたTFRecordとtf_label_map.pbtxtを格納してください。
193 | 格納後、以下を実行してください。
194 | * 学習データ/検証データ 分割
195 |
196 | # 4. パイプラインコンフィグ修正
197 | 「03_pretrained_model\efficientdet_d0_coco17_tpu-32\pipeline.config」のパイプラインコンフィグを以下のように修正して、
198 | Colaboratory上の「Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/03_pretrained_model」にアップロードしてください。
199 |
200 | パイプラインコンフィグ修正箇所
201 |
202 | * 3行目(Line 3):クラス数(num_classes)
変更前(Before) : 90
変更後(After) : 1
203 | * 134行目(Line 134):バッチサイズ(batch_size)
変更前(Before) : 128
変更後(After) : 16
204 | * 161行目(Line 161):ファインチューニング用のチェックポイント格納先(fine_tune_checkpoint)
変更前(Before) : "PATH_TO_BE_CONFIGURED"
変更後(After) : "/content/models/research/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/03_pretrained_model/efficientdet_d0_coco17_tpu-32/checkpoint/ckpt-0"
205 | * 167行目(Line 167):ファインチューニング方法(fine_tune_checkpoint_type)
変更前(Before) : "classification"
変更後(After) : "detection"
206 | * 168行目(Line 168):Googleカスタム 16ビットbrain浮動小数点の使用有無(use_bfloat16)
変更前(Before) : true
変更後(After) : false
207 | * 172行目(Line 172):ラベルマップファイルの格納先(label_map_path)
変更前(Before) : "PATH_TO_BE_CONFIGURED/label_map.txt"
変更後(After) : "/content/models/research/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/02_tfrecord/tf_label_map.pbtxt"
208 | * 174行目(Line 174):学習データの格納先(input_path)
変更前(Before) : "PATH_TO_BE_CONFIGURED/train2017-?????-of-00256.tfrecord"
変更後(After) : "/content/models/research/train_data/??????.tfrecord"
209 | * 185行目(Line 185):ラベルマップファイルの格納先(label_map_path)
変更前(Before) : "PATH_TO_BE_CONFIGURED/label_map.txt"
変更後(After) : "/content/models/research/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/02_tfrecord/tf_label_map.pbtxt"
210 | * 189行目(Line 189):バリデーションデータの格納先(input_path)
変更前(Before) : "PATH_TO_BE_CONFIGURED/val2017-?????-of-00032.tfrecord"
変更後(After) : "/content/models/research/val_data/??????.tfrecord"
211 |
212 |
213 |
214 | パイプラインコンフィグ修正箇所 ※余裕のある方向け
215 |
216 | パイプラインコンフィグにはデータ拡張設定も記載されています。
217 | 初期のパイプラインコンフィグには、以下の水平反転、ランダムスケールクロップのみのデータ拡張が設定されています。
218 |
219 | data_augmentation_options {
220 | random_horizontal_flip {
221 | }
222 | }
223 | data_augmentation_options {
224 | random_scale_crop_and_pad_to_square {
225 | output_size: 512
226 | scale_min: 0.10000000149011612
227 | scale_max: 2.0
228 | }
229 | }
230 |
231 |
232 | 使用可能なデータ拡張手法は、[preprocessor.proto](https://github.com/tensorflow/models/blob/master/research/object_detection/protos/preprocessor.proto)、[preprocessor.py](https://github.com/tensorflow/models/blob/master/research/object_detection/core/preprocessor.py)に記載されているため、
233 | 必要に応じて追加してみてください。
234 |
235 |
236 | # 5. Colaboratory:モデル訓練
237 | 以下の順に実行してください。
238 | * Googleドライブに保存先ディレクトリを作成
239 | * TensorBoard
240 | * 学習
241 | * saved model形式へエクスポート
242 |
243 | # 6. Colaboratory:推論
244 | 以下の順に実行してください。
245 | * モデルロード
246 | * 推論
247 | * 推論結果確認
248 |
249 | # ToDo
250 | * [ ] pip依存関係解決のため、一時的に以下オプションを付与。
```!python -m pip install . --use-deprecated=legacy-resolver```
[tensorflow/models Issue #10375](https://github.com/tensorflow/models/issues/10375)、[Tensorflow2-ObjectDetectionAPI-Colab-Hands-On Issues #2](https://github.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/issues/2)
251 |
252 | # Author
253 | 高橋かずひと(https://twitter.com/KzhtTkhs)
254 |
255 | # License
256 | Tensorflow2-ObjectDetectionAPI-Colab-Hands-On is under [MIT license](https://en.wikipedia.org/wiki/MIT_License).
257 |
--------------------------------------------------------------------------------
/README_EN.md:
--------------------------------------------------------------------------------
1 | [[Japanese](https://github.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On)/English]
2 | # Tensorflow2-ObjectDetectionAPI-Colab-Hands-On
3 | 
4 |
5 | Hands-on documentation for the Tensorflow2 Object Detection API.
6 | Annotation with VoTT is performed on the local PC, and learning-inference is performed on Colaboratory.
7 | This repository contains the following:
8 | * Dataset for learning (Annotation not implemented)
9 | * Test dataset
10 | * Model for fine-tuning(EffientDet D0)
11 | * Script for Google Colaboratory(Environment setting, model training, inference result confirmation)
12 |
13 |
14 | Directory structure
15 |
16 |
17 | │ [Colaboratory]Tensorflow2_ObjectDetectionAPI_Colab_Hands_On.ipynb
18 | |
19 | ├─01_train_data─┬─000000.jpg
20 | │ │ :
21 | │ └─000049.jpg
22 | │
23 | ├─02_tfrecord
24 | │
25 | ├─03_pretrained_model─efficientdet_d0_coco17_tpu-32─┬─pipeline.config
26 | │ ├─checkpoint──┬─checkpoint
27 | │ │ ├─ckpt-0.data-00000-of-00001
28 | │ │ └─ckpt-0.index
29 | │ └─saved_model─┬─saved_model.pb
30 | │ └─variables─┬─variables.data-00000-of-00001
31 | │ └─variables.index
32 | │
33 | └─04_test_data─┬─000050.jpg
34 | │ :
35 | └─000099.jpg
36 |
37 |
38 |
39 | #### [Colaboratory]Tensorflow2_ObjectDetectionAPI_Colab_Hands_On.ipynb
40 | Script for Google Colaboratory(Environment setting, model training, inference result confirmation)
41 |
42 | #### 01_train_data
43 | Dataset for learning (Annotation not implemented)
44 |
45 | #### 02_tfrecord
46 | Annotated TFRecord storage location
47 |
48 | #### 03_pretrained_mode
49 | Model for fine-tuning(EffientDet D0)
50 |
51 | #### 04_test_data
52 | Test dataset
53 |
54 |
55 |
56 | # Requirement
57 | Tensorflow 2.3.0
58 |
59 | # Overview
60 | This hands-on assumes about 2 hours.
61 | 1. VoTT:Annotation(30-60minutes)
62 | 1. Colaboratory:Object Detection API Setting
63 | 1. Pipeline-config correction
64 | 1. Colaboratory:Model training(About 25minutes)
65 | 1. Colaboratory:Inference
66 |
67 | # Preparations
68 | The following is required as a preliminary preparation.
69 | * Clone this repository to your local PC.
70 | * [VoTT](https://github.com/microsoft/VoTT) installation.
71 | * Google account(Used in Google Drive, Google Colaboratory)
72 |
73 | # 1. VoTT:Annotation
74 | Annotate using [VoTT](https://github.com/microsoft/VoTT) and output in TFRecord format.
75 |
76 |
77 | VoTT project settings
78 |
79 | #### Select "New Project"
80 | 
81 | #### Make project settings
82 | Display name:Tensorflow2-ObjectDetectionAPI-Colab-Hands-On
83 | Security token:Generate New Security Token
84 | Source connection:「Add Connection」を押下
85 | 
86 | #### Set the connection of the source connection
87 | Display name:Tensorflow2-ObjectDetectionAPI-Colab-Hands-On-TrainData
88 | 
89 | Provider: Local file system
90 | 
91 | Folder path:Specify the "01_train_data" directory of the cloned repository
92 | 
93 | #### Set the connection of the target connection
94 | Target connection:Add Connection
95 | 
96 | Display name:Tensorflow2-ObjectDetectionAPI-Colab-Hands-On-TFRecord
97 | Provider: Local file system
98 | Folder path:Specify the "02_tfrecord" directory of the cloned repository
99 | 
100 |
102 | #### Add tags and save settings
103 | Tags:Add "Fish"
104 | Press "Save Project"
105 | 
106 |
107 |
108 |
109 | Annotate using VoTT
110 |
111 | #### Select a fish by left dragging the mouse
112 | 
113 | #### Select "Fish" from TAGS
114 | You can lock the tag you want to use by selecting the padlock mark.
115 | 
116 |
118 |
119 |
120 |
121 | TFRecord export
122 |
123 | #### Export settings
124 | Provider:Tensorflow record
125 | Asset status: Tagged assets only
126 | Click "Save Export Settings"
127 | 
128 | Click the export icon from the annotation screen to export TFRecord.
129 | 
130 |
131 |
132 |
133 | Precautions (details are being confirmed)
134 |
135 | When annotating the target at the edge of the image, leave a small gap from the edge as shown below.
136 | 
137 | I am checking the details of the problem, but if I annotate without opening a gap,
138 | I do not know whether it is a VoTT problem or a Tensorflow problem, but the following error occurs when training the model.
139 |
140 | W0921 13:29:32.965700 140050120722176 optimizer_v2.py:1275] Gradients do not exist for variables ['top_bn/gamma:0', 'top_bn/beta:0'] when minimizing the loss.
141 | Traceback (most recent call last):
142 | File "object_detection/model_main_tf2.py", line 113, in
143 | tf.compat.v1.app.run()
144 | File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/platform/app.py", line 40, in run
145 | _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
146 | File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 300, in run
147 | _run_main(main, args)
148 | File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 251, in _run_main
149 | sys.exit(main(argv))
150 | File "object_detection/model_main_tf2.py", line 110, in main
151 | record_summaries=FLAGS.record_summaries)
152 | File "/usr/local/lib/python3.6/dist-packages/object_detection/model_lib_v2.py", line 639, in train_loop
153 | loss = _dist_train_step(train_input_iter)
154 | File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py", line 780, in __call__
155 | result = self._call(*args, **kwds)
156 | File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py", line 807, in _call
157 | return self._stateless_fn(*args, **kwds) # pylint: disable=not-callable
158 | File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py", line 2829, in __call__
159 | return graph_function._filtered_call(args, kwargs) # pylint: disable=protected-access
160 | File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py", line 1848, in _filtered_call
161 | cancellation_manager=cancellation_manager)
162 | File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py", line 1924, in _call_flat
163 | ctx, args, cancellation_manager=cancellation_manager))
164 | File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py", line 550, in call
165 | ctx=ctx)
166 | File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/execute.py", line 60, in quick_execute
167 | inputs, attrs, num_outputs)
168 | tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
169 | (0) Invalid argument: assertion failed: [[0.15956609][0.103383526][0.109880842]...] [[0.23180081][0.133959055][0.132812485]...]
170 | [[{{node Assert_1/AssertGuard/else/_35/Assert_1/AssertGuard/Assert}}]]
171 | [[MultiDeviceIteratorGetNextFromShard]]
172 | [[RemoteCall]]
173 | [[IteratorGetNext]]
174 | [[Loss/localization_loss_1/write_summary/summary_cond/pivot_t/_4/_111]]
175 | (1) Invalid argument: assertion failed: [[0.15956609][0.103383526][0.109880842]...] [[0.23180081][0.133959055][0.132812485]...]
176 | [[{{node Assert_1/AssertGuard/else/_35/Assert_1/AssertGuard/Assert}}]]
177 | [[MultiDeviceIteratorGetNextFromShard]]
178 | [[RemoteCall]]
179 | [[IteratorGetNext]]
180 |
181 |
182 |
183 | # 2. Colaboratory:Object Detection API Setting
184 | [](https://colab.research.google.com/github/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/blob/master/[Colaboratory]Tensorflow2-ObjectDetectionAPI-Colab-Hands-On.ipynb)
185 | Subsequent work will be performed on Google Colaboratory. ※Except for pipeline config modification
186 | Open your notebook from the [Open In Colab] link and run it in the following order.
187 | * Google Drive mount
188 | * Set Tensorflow Object Detection API
189 | * Clone Tensorflow2-ObjectDetectionAPI-Colab-Hands-On repository
190 |
191 | # 3.Upload TFRecord
192 | Store the TFRecord exported from VoTT and tf_label_map.pbtxt in "Tensorflow2-Object Detection API-Colab-Hands-On / 02_tfrecord".
193 | After storing, execute the following.
194 | * Split Training data/validation data
195 |
196 | # 4. Pipeline-config correction
197 | Modify the pipeline config of "03_pretrained_model/coefficientdet_d0_coco17_tpu-32/pipeline.config" as follows,
198 | Please upload to "Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/03_pretrained_model" on Colaboratory.
199 |
200 | Pipeline-config correction part
201 |
202 | * 3行目(Line 3):クラス数(num_classes)
変更前(Before) : 90
変更後(After) : 1
203 | * 134行目(Line 134):バッチサイズ(batch_size)
変更前(Before) : 128
変更後(After) : 16
204 | * 161行目(Line 161):ファインチューニング用のチェックポイント格納先(fine_tune_checkpoint)
変更前(Before) : "PATH_TO_BE_CONFIGURED"
変更後(After) : "/content/models/research/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/03_pretrained_model/efficientdet_d0_coco17_tpu-32/checkpoint/ckpt-0"
205 | * 167行目(Line 167):ファインチューニング方法(fine_tune_checkpoint_type)
変更前(Before) : "classification"
変更後(After) : "detection"
206 | * 168行目(Line 168):Googleカスタム 16ビットbrain浮動小数点の使用有無(use_bfloat16)
変更前(Before) : true
変更後(After) : false
207 | * 172行目(Line 172):ラベルマップファイルの格納先(label_map_path)
変更前(Before) : "PATH_TO_BE_CONFIGURED/label_map.txt"
変更後(After) : "/content/models/research/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/02_tfrecord/tf_label_map.pbtxt"
208 | * 174行目(Line 174):学習データの格納先(input_path)
変更前(Before) : "PATH_TO_BE_CONFIGURED/train2017-?????-of-00256.tfrecord"
変更後(After) : "/content/models/research/train_data/??????.tfrecord"
209 | * 185行目(Line 185):ラベルマップファイルの格納先(label_map_path)
変更前(Before) : "PATH_TO_BE_CONFIGURED/label_map.txt"
変更後(After) : "/content/models/research/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/02_tfrecord/tf_label_map.pbtxt"
210 | * 189行目(Line 189):バリデーションデータの格納先(input_path)
変更前(Before) : "PATH_TO_BE_CONFIGURED/val2017-?????-of-00032.tfrecord"
変更後(After) : "/content/models/research/val_data/??????.tfrecord"
211 |
212 |
213 |
214 | Pipeline-config correction parts ※Those who can afford
215 |
216 | Data Augmentation settings are also listed in the pipeline config.
217 | In the initial pipeline config, the following horizontal inversion and random scale crop only data augmentation are set.
218 |
219 | data_augmentation_options {
220 | random_horizontal_flip {
221 | }
222 | }
223 | data_augmentation_options {
224 | random_scale_crop_and_pad_to_square {
225 | output_size: 512
226 | scale_min: 0.10000000149011612
227 | scale_max: 2.0
228 | }
229 | }
230 |
231 |
232 | Available data augmentation techniques are [preprocessor.proto](https://github.com/tensorflow/models/blob/master/research/object_detection/protos/preprocessor.proto)、[preprocessor.py](https://github.com/tensorflow/models/blob/master/research/object_detection/core/preprocessor.py)so
233 | Try adding as needed.
234 |
235 |
236 | # 5. Colaboratory:Model training
237 | Please execute in the following order.
238 | * Create directory in Google Drive
239 | * TensorBoard
240 | * Training
241 | * Export to saved-model format
242 |
243 | # 6. Colaboratory:Inference
244 | Please execute in the following order.
245 | * Load model
246 | * Inference
247 | * Inference result confirmation
248 |
249 | # ToDo
250 | * [ ] The following options are temporarily added to resolve the pip dependency.
```!python -m pip install . --use-deprecated=legacy-resolver```
[tensorflow/models Issue #10375](https://github.com/tensorflow/models/issues/10375)、[Tensorflow2-ObjectDetectionAPI-Colab-Hands-On Issues #2](https://github.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/issues/2)
251 |
252 | # Author
253 | Kazuhito Takahashi(https://twitter.com/KzhtTkhs)
254 |
255 | # License
256 | Tensorflow2-ObjectDetectionAPI-Colab-Hands-On is under [MIT license](https://en.wikipedia.org/wiki/MIT_License).
257 |
--------------------------------------------------------------------------------
/[Colaboratory]Tensorflow2-ObjectDetectionAPI-Colab-Hands-On.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {
6 | "id": "VUCNWeZ2wBFp"
7 | },
8 | "source": [
9 | "# [Colaboratory]Tensorflow2-ObjectDetectionAPI-Colab-Hands-On.ipynb
\n",
10 | "このノートブックはTensorflow2 Object Detection APIの学習/推論のハンズオン用スクリプトです(This notebook is a hands-on script for learning/inference of the Tensorflow2 Object Detection API)
\n",
11 | "Colaboratoryのハードウェア アクセラレータ設定をGPUにして実行してください(Set the hardware accelerator setting of Colaboratory to GPU and execute it.)
\n",
12 | "Github URL : [Tensorflow2-ObjectDetectionAPI-Colab-Hands-On](https://github.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On)\n",
13 | "\n"
14 | ]
15 | },
16 | {
17 | "cell_type": "markdown",
18 | "metadata": {
19 | "id": "Gr36a9P3whVQ"
20 | },
21 | "source": [
22 | "# Google Driveマウント(Google Drive mount)\n",
23 | "※checkpoint、saved model格納先 (checkpoint, saved model storage location)"
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": null,
29 | "metadata": {
30 | "id": "RdjNWM8HwitO"
31 | },
32 | "outputs": [],
33 | "source": [
34 | "from google.colab import drive\n",
35 | "drive.mount('./gdrive')"
36 | ]
37 | },
38 | {
39 | "cell_type": "markdown",
40 | "metadata": {
41 | "id": "FATF4iQ4ANdF"
42 | },
43 | "source": [
44 | "# Tensorflow Object Detection API設定(Set Tensorflow Object Detection API)"
45 | ]
46 | },
47 | {
48 | "cell_type": "markdown",
49 | "metadata": {
50 | "id": "WpgBfSdZAT82"
51 | },
52 | "source": [
53 | "### Protocol Buffers"
54 | ]
55 | },
56 | {
57 | "cell_type": "code",
58 | "execution_count": null,
59 | "metadata": {
60 | "id": "tvMZTXVbARNZ"
61 | },
62 | "outputs": [],
63 | "source": [
64 | "!curl -OL https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip\n",
65 | "!unzip protoc-3.2.0-linux-x86_64.zip -d protoc3\n",
66 | "!sudo mv protoc3/bin/* /usr/local/bin/\n",
67 | "!sudo mv protoc3/include/* /usr/local/include/\n",
68 | "!rm -rf protoc3 protoc-3.2.0-linux-x86_64.zip"
69 | ]
70 | },
71 | {
72 | "cell_type": "code",
73 | "execution_count": null,
74 | "metadata": {
75 | "id": "80tsIvjRAV6m"
76 | },
77 | "outputs": [],
78 | "source": [
79 | "!git clone --depth 1 https://github.com/tensorflow/models\n",
80 | "%cd /content/models/research\n",
81 | "\n",
82 | "!/usr/local/bin/protoc object_detection/protos/*.proto --python_out=."
83 | ]
84 | },
85 | {
86 | "cell_type": "markdown",
87 | "metadata": {
88 | "id": "OFkjFNTGAcaT"
89 | },
90 | "source": [
91 | "### 必要ライブラリインストール(Installation of required libraries)"
92 | ]
93 | },
94 | {
95 | "cell_type": "code",
96 | "execution_count": null,
97 | "metadata": {
98 | "id": "nem-gkjuAV_U"
99 | },
100 | "outputs": [],
101 | "source": [
102 | "!cp /content/models/research/object_detection/packages/tf2/setup.py .\n",
103 | "# ToDo:https://github.com/tensorflow/models/issues/10375\n",
104 | "!python -m pip install . --use-deprecated=legacy-resolver"
105 | ]
106 | },
107 | {
108 | "cell_type": "code",
109 | "execution_count": null,
110 | "metadata": {
111 | "id": "h7LjWeQFAV3b"
112 | },
113 | "outputs": [],
114 | "source": [
115 | "# インストール成否確認(Confirmation of successful installation)\n",
116 | "!python /content/models/research/object_detection/builders/model_builder_tf2_test.py"
117 | ]
118 | },
119 | {
120 | "cell_type": "markdown",
121 | "metadata": {
122 | "id": "A9_s3CAtzKFI"
123 | },
124 | "source": [
125 | "# Tensorflow2-ObjectDetectionAPI-Colab-Hands-Onリポジトリクローン(Clone repository)"
126 | ]
127 | },
128 | {
129 | "cell_type": "code",
130 | "execution_count": null,
131 | "metadata": {
132 | "id": "yg73roLzzVyW"
133 | },
134 | "outputs": [],
135 | "source": [
136 | "!git clone https://github.com/Kazuhito00/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On"
137 | ]
138 | },
139 | {
140 | "cell_type": "markdown",
141 | "metadata": {
142 | "id": "1kfwGjF4kols"
143 | },
144 | "source": [
145 | "# TFRecordをアップロード(Upload TF Record)\n",
146 | "「Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/02_tfrecord」にVoTTからエクスポートしたTFRecordとtf_label_map.pbtxtを格納してください。
(Please store the TFRecord and tf_label_map.pbtxt exported from VoTT in \"Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/02_tfrecord\".)\n",
147 | "
\n",
148 | "\n"
149 | ]
150 | },
151 | {
152 | "cell_type": "markdown",
153 | "metadata": {
154 | "id": "08ZcM9-Bw8Xy"
155 | },
156 | "source": [
157 | "# 学習データ/検証データ 分割(Split Training data/validation data)"
158 | ]
159 | },
160 | {
161 | "cell_type": "code",
162 | "execution_count": null,
163 | "metadata": {
164 | "id": "5g-2VP8j6bgB"
165 | },
166 | "outputs": [],
167 | "source": [
168 | "original_data_dir = '/content/models/research/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/02_tfrecord'\n",
169 | "train_data_dir = '/content/models/research/train_data'\n",
170 | "val_data_dir = '/content/models/research/val_data'"
171 | ]
172 | },
173 | {
174 | "cell_type": "code",
175 | "execution_count": null,
176 | "metadata": {
177 | "id": "u7NoOeHkwk_V"
178 | },
179 | "outputs": [],
180 | "source": [
181 | "# ディレクトリ作成(Create a directory)\n",
182 | "import os\n",
183 | "import shutil\n",
184 | "\n",
185 | "shutil.rmtree(train_data_dir, ignore_errors=True)\n",
186 | "shutil.rmtree(val_data_dir, ignore_errors=True)\n",
187 | "os.mkdir(train_data_dir)\n",
188 | "os.mkdir(val_data_dir)"
189 | ]
190 | },
191 | {
192 | "cell_type": "code",
193 | "execution_count": null,
194 | "metadata": {
195 | "id": "_XAfNhTVjUes"
196 | },
197 | "outputs": [],
198 | "source": [
199 | "import glob\n",
200 | "\n",
201 | "# ファイル数カウント(Count the number of files)\n",
202 | "file_count = len(glob.glob(original_data_dir + '/*.tfrecord'))\n",
203 | "print('File count : ' + str(file_count))"
204 | ]
205 | },
206 | {
207 | "cell_type": "code",
208 | "execution_count": null,
209 | "metadata": {
210 | "id": "KxJk4E1P11pT"
211 | },
212 | "outputs": [],
213 | "source": [
214 | "import random\n",
215 | "\n",
216 | "# 学習データ/検証データ 分割(Split Training data/validation data.)\n",
217 | "train_ratio = 0.75\n",
218 | "\n",
219 | "file_list = glob.glob(original_data_dir + '/*.tfrecord')\n",
220 | "random_sample_list = random.sample(file_list, file_count)\n",
221 | "\n",
222 | "# ディレクトリへコピー(Copy to directory)\n",
223 | "for index, filepath in enumerate(random_sample_list):\n",
224 | " if index < int(file_count * train_ratio):\n",
225 | " # 学習データ(Training data)\n",
226 | " shutil.copy2(filepath, train_data_dir)\n",
227 | " else:\n",
228 | " # 検証データ(Validation data)\n",
229 | " shutil.copy2(filepath, val_data_dir)"
230 | ]
231 | },
232 | {
233 | "cell_type": "markdown",
234 | "metadata": {
235 | "id": "_A-UvwHC7hLW"
236 | },
237 | "source": [
238 | "# 学習済モデル(Pre-Trained model)\n",
239 | "\n",
240 | "このハンズオンでは「Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/03_pretrained_model」に学習済モデル(EfficientDet-D0)が格納してあります。
(In this hands-on, the pre-trained model(EfficientDet-D0) is stored in \"Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/03_pretrained_model\")
学習済モデル取得元(Pre-Trained model acquisition source):http://download.tensorflow.org/models/object_detection/tf2/20200711/efficientdet_d0_coco17_tpu-32.tar.gz"
241 | ]
242 | },
243 | {
244 | "cell_type": "markdown",
245 | "metadata": {
246 | "id": "1_bm5VtPk4SO"
247 | },
248 | "source": [
249 | "# パイプラインコンフィグアップロード(Pipeline config upload)\n",
250 | "\n",
251 | "パイプラインコンフィグを修正し「Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/03_pretrained_model」にアップロードしてください(Please modify the pipeline config and upload it to \"Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/03_pretrained_model\")
\n",
252 | "パイプラインコンフィグは以下の行を修正します(Pipeline Config modifies the following line)
\n",
253 | "\n",
254 | "* 3行目(Line 3):クラス数(num_classes)
変更前(Before) : 90
変更後(After) : 1
\n",
255 | "* 134行目(Line 134):バッチサイズ(batch_size)
変更前(Before) : 128
変更後(After) : 16
\n",
256 | "* 161行目(Line 161):ファインチューニング用のチェックポイント格納先(fine_tune_checkpoint)
変更前(Before) : \"PATH_TO_BE_CONFIGURED\"
変更後(After) : \"/content/models/research/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/03_pretrained_model/efficientdet_d0_coco17_tpu-32/checkpoint/ckpt-0\"\n",
257 | "* 167行目(Line 167):ファインチューニング方法(fine_tune_checkpoint_type)
変更前(Before) : \"classification\"
変更後(After) : \"detection\"
\n",
258 | "* 168行目(Line 168):Googleカスタム 16ビットbrain浮動小数点の使用有無(use_bfloat16)
変更前(Before) : true
変更後(After) : false
\n",
259 | "* 172行目(Line 172):ラベルマップファイルの格納先(label_map_path)
変更前(Before) : \"PATH_TO_BE_CONFIGURED/label_map.txt\"
変更後(After) : \"/content/models/research/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/02_tfrecord/tf_label_map.pbtxt\"
\n",
260 | "* 174行目(Line 174):学習データの格納先(input_path)
変更前(Before) : \"PATH_TO_BE_CONFIGURED/train2017-?????-of-00256.tfrecord\"
変更後(After) : \"/content/models/research/train_data/??????.tfrecord\"
\n",
261 | "* 185行目(Line 185):ラベルマップファイルの格納先(label_map_path)
変更前(Before) : \"PATH_TO_BE_CONFIGURED/label_map.txt\"
変更後(After) : \"/content/models/research/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/02_tfrecord/tf_label_map.pbtxt\"
\n",
262 | "* 189行目(Line 189):バリデーションデータの格納先(input_path)
変更前(Before) : \"PATH_TO_BE_CONFIGURED/val2017-?????-of-00032.tfrecord\"
変更後(After) : \"/content/models/research/val_data/??????.tfrecord\"\n",
263 | "
\n",
264 | "\n"
265 | ]
266 | },
267 | {
268 | "cell_type": "markdown",
269 | "metadata": {
270 | "id": "ORYqE_A0Bm0y"
271 | },
272 | "source": [
273 | "# モデル訓練(Model training)"
274 | ]
275 | },
276 | {
277 | "cell_type": "markdown",
278 | "metadata": {
279 | "id": "wO6EZSbnIY-s"
280 | },
281 | "source": [
282 | "### Googleドライブに保存先ディレクトリを作成(Create directory in Google Drive)"
283 | ]
284 | },
285 | {
286 | "cell_type": "code",
287 | "execution_count": null,
288 | "metadata": {
289 | "id": "R-ElsZLHxHvK"
290 | },
291 | "outputs": [],
292 | "source": [
293 | "!mkdir '/content/gdrive/My Drive/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On'"
294 | ]
295 | },
296 | {
297 | "cell_type": "markdown",
298 | "metadata": {
299 | "id": "-_7GvE2KIbMk"
300 | },
301 | "source": [
302 | "### TensorBoard"
303 | ]
304 | },
305 | {
306 | "cell_type": "code",
307 | "execution_count": null,
308 | "metadata": {
309 | "id": "ctvO4SJD11u3"
310 | },
311 | "outputs": [],
312 | "source": [
313 | "%load_ext tensorboard"
314 | ]
315 | },
316 | {
317 | "cell_type": "code",
318 | "execution_count": null,
319 | "metadata": {
320 | "id": "a-M__9iNHK80"
321 | },
322 | "outputs": [],
323 | "source": [
324 | "tensorboard --logdir '/content/gdrive/My Drive/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On'"
325 | ]
326 | },
327 | {
328 | "cell_type": "markdown",
329 | "metadata": {
330 | "id": "EpEgC85TIeVR"
331 | },
332 | "source": [
333 | "# 学習(Training)\n",
334 | "\n",
335 | "学習はColaboratory上で1000ステップにつき、約25分かかります(Learning takes about 25 minutes per 1000 steps on the Colaboratory)"
336 | ]
337 | },
338 | {
339 | "cell_type": "code",
340 | "execution_count": null,
341 | "metadata": {
342 | "id": "WLOMjRA28IHg"
343 | },
344 | "outputs": [],
345 | "source": [
346 | "!python object_detection/model_main_tf2.py \\\n",
347 | " --pipeline_config_path=\"/content/models/research/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/03_pretrained_model/pipeline.config\" \\\n",
348 | " --model_dir=\"/content/gdrive/My Drive/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On\" \\\n",
349 | " --num_train_steps=1000 \\\n",
350 | " --alsologtostderr \\\n",
351 | " --sample_1_of_n_eval_examples=1 \\\n",
352 | " --num_eval_steps=100"
353 | ]
354 | },
355 | {
356 | "cell_type": "markdown",
357 | "metadata": {
358 | "id": "V0ZTEuHAnMxp"
359 | },
360 | "source": [
361 | "# saved model形式へエクスポート(Export to saved-model format)"
362 | ]
363 | },
364 | {
365 | "cell_type": "code",
366 | "execution_count": null,
367 | "metadata": {
368 | "id": "VuL08MMmIBzQ"
369 | },
370 | "outputs": [],
371 | "source": [
372 | "!python object_detection/exporter_main_v2.py \\\n",
373 | " --input_type=image_tensor \\\n",
374 | " --pipeline_config_path=\"/content/models/research/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/03_pretrained_model/pipeline.config\" \\\n",
375 | " --trained_checkpoint_dir=\"/content/gdrive/My Drive/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On\" \\\n",
376 | " --output_directory=\"/content/gdrive/My Drive/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/output\""
377 | ]
378 | },
379 | {
380 | "cell_type": "markdown",
381 | "metadata": {
382 | "id": "mB6Z34Wcs6NW"
383 | },
384 | "source": [
385 | "# モデルロード(Load model)"
386 | ]
387 | },
388 | {
389 | "cell_type": "code",
390 | "execution_count": null,
391 | "metadata": {
392 | "id": "XUaigXpntNVz"
393 | },
394 | "outputs": [],
395 | "source": [
396 | "import tensorflow as tf\n",
397 | "\n",
398 | "model_path = '/content/gdrive/My Drive/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/output/saved_model'\n",
399 | "\n",
400 | "DEFAULT_FUNCTION_KEY = 'serving_default'\n",
401 | "loaded_model = tf.saved_model.load(model_path)\n",
402 | "inference_func = loaded_model.signatures[DEFAULT_FUNCTION_KEY]"
403 | ]
404 | },
405 | {
406 | "cell_type": "markdown",
407 | "metadata": {
408 | "id": "gtKvTGJXLBZE"
409 | },
410 | "source": [
411 | "# 推論(Inference)"
412 | ]
413 | },
414 | {
415 | "cell_type": "code",
416 | "execution_count": null,
417 | "metadata": {
418 | "id": "1VHkShurKtVC"
419 | },
420 | "outputs": [],
421 | "source": [
422 | "# 推論対象のテスト画像一覧(List of test images to be inferred)\n",
423 | "import glob\n",
424 | "import copy\n",
425 | "import cv2\n",
426 | "from google.colab.patches import cv2_imshow\n",
427 | "\n",
428 | "test_data_dir = '/content/models/research/Tensorflow2-ObjectDetectionAPI-Colab-Hands-On/04_test_data'\n",
429 | "testfile_list = sorted(glob.glob(test_data_dir + '/*.jpg'))"
430 | ]
431 | },
432 | {
433 | "cell_type": "code",
434 | "execution_count": null,
435 | "metadata": {
436 | "id": "EEIBDIeRpswu"
437 | },
438 | "outputs": [],
439 | "source": [
440 | "# 推論用関数(Function for inference)\n",
441 | "def run_inference_single_image(image, inference_func):\n",
442 | " tensor = tf.convert_to_tensor(image)\n",
443 | " output = inference_func(tensor)\n",
444 | "\n",
445 | " output['num_detections'] = int(output['num_detections'][0])\n",
446 | " output['detection_classes'] = output['detection_classes'][0].numpy()\n",
447 | " output['detection_boxes'] = output['detection_boxes'][0].numpy()\n",
448 | " output['detection_scores'] = output['detection_scores'][0].numpy()\n",
449 | " return output"
450 | ]
451 | },
452 | {
453 | "cell_type": "code",
454 | "execution_count": null,
455 | "metadata": {
456 | "id": "RPdZ-PLMLZeY"
457 | },
458 | "outputs": [],
459 | "source": [
460 | "import cv2\n",
461 | "import numpy as np\n",
462 | "from PIL import Image\n",
463 | "\n",
464 | "filenames = []\n",
465 | "\n",
466 | "# 動画書き出し用設定(VideoWriter setting)\n",
467 | "temp_image = cv2.imread(testfile_list[0], cv2.IMREAD_UNCHANGED)\n",
468 | "image_width, image_height = temp_image.shape[1], temp_image.shape[0]\n",
469 | "fourcc = 'mp4v'\n",
470 | "writer_fourcc = cv2.VideoWriter_fourcc(*fourcc)\n",
471 | "videowriter = cv2.VideoWriter('result.mp4', writer_fourcc, 10, (image_width, image_height))\n",
472 | "\n",
473 | "# 推論(Inference)\n",
474 | "for filecount, testfile in enumerate(testfile_list):\n",
475 | " image = cv2.imread(testfile, cv2.IMREAD_UNCHANGED)\n",
476 | " debug_image = copy.deepcopy(image)\n",
477 | "\n",
478 | " image_width, image_height = image.shape[1], image.shape[0]\n",
479 | " image = image[:, :, [2, 1, 0]] # BGR2RGB\n",
480 | " image_np_expanded = np.expand_dims(image, axis=0)\n",
481 | "\n",
482 | " output = run_inference_single_image(image_np_expanded, inference_func)\n",
483 | "\n",
484 | " num_detections = output['num_detections']\n",
485 | " for i in range(num_detections):\n",
486 | " score = output['detection_scores'][i]\n",
487 | " bbox = output['detection_boxes'][i]\n",
488 | " # class_id = output['detection_classes'][i].astype(np.int)\n",
489 | "\n",
490 | " if score < 0.85:\n",
491 | " continue\n",
492 | "\n",
493 | " x1, y1 = int(bbox[1] * image_width), int(bbox[0] * image_height)\n",
494 | " x2, y2 = int(bbox[3] * image_width), int(bbox[2] * image_height)\n",
495 | "\n",
496 | " # 推論結果描画(Inference result drawing)\n",
497 | " cv2.rectangle(debug_image, (x1, y1), (x2, y2), (255, 255, 255), 2)\n",
498 | " cv2.putText(debug_image, str('{:.2f}'.format(score)), (x1, y1-10), cv2.FONT_HERSHEY_PLAIN, 1.5, (255, 255, 255), 2, cv2.LINE_AA)\n",
499 | " cv2.rectangle(debug_image, (x1, y1), (x2, y2), (255, 255, 255), 2)\n",
500 | " videowriter.write(debug_image)\n",
501 | "videowriter.release()"
502 | ]
503 | },
504 | {
505 | "cell_type": "markdown",
506 | "metadata": {
507 | "id": "gXJBbDNYxnp0"
508 | },
509 | "source": [
510 | "# 推論結果確認(Inference result confirmation)"
511 | ]
512 | },
513 | {
514 | "cell_type": "code",
515 | "execution_count": null,
516 | "metadata": {
517 | "id": "W9kmLlk0-TPa"
518 | },
519 | "outputs": [],
520 | "source": [
521 | "import imageio\n",
522 | "import matplotlib.pyplot as plt\n",
523 | "import matplotlib.animation as animation\n",
524 | "from IPython.display import HTML\n",
525 | "\n",
526 | "def play_video(video, interval=100):\n",
527 | " video = imageio.mimread(video)\n",
528 | " fig = plt.figure(figsize=(9, 6))\n",
529 | "\n",
530 | " movie = []\n",
531 | " for i in range(len(video)):\n",
532 | " img = plt.imshow(video[i], animated=True)\n",
533 | " plt.axis('off')\n",
534 | " movie.append([img])\n",
535 | "\n",
536 | " anime = animation.ArtistAnimation(fig, movie, interval=interval, repeat_delay=1000)\n",
537 | " plt.close()\n",
538 | " return anime\n",
539 | "\n",
540 | "HTML(play_video('result.mp4').to_html5_video()) "
541 | ]
542 | }
543 | ],
544 | "metadata": {
545 | "accelerator": "GPU",
546 | "colab": {
547 | "collapsed_sections": [],
548 | "name": "[Colaboratory]Tensorflow2-ObjectDetectionAPI-Colab-Hands-On.ipynb",
549 | "provenance": [],
550 | "toc_visible": true
551 | },
552 | "kernelspec": {
553 | "display_name": "Python 3",
554 | "name": "python3"
555 | }
556 | },
557 | "nbformat": 4,
558 | "nbformat_minor": 0
559 | }
560 |
--------------------------------------------------------------------------------