This repository is forked from tensorflow/models and modified by LIFOsitory
- custom_models
- model_zoo
- dataset
- generate_dataset_old.py
- generate_dataset.py
- visualize_dataset.py
- generate_tfrecord.py
- generate_tflite.py
- infer_ckpt.py
- test_tflite.py
- detect.tflite
- detect_old.tflite
𧑠research μμμ μμ νμμ΅λλ€.
𧑠visualize_dataset.pyμ μ μΈνκ³€ λ νΌλ°μ€λ₯Ό λ°νμΌλ‘ μ λΆ μ§μ μμ νκ±°λ μμ±νμμ΅λλ€.
𧑠dataset νμΌμ΄ λ무 ν° κ΄κ³λ‘ train, test ν΄λλ μ μΈνμμ΅λλ€. generate dataset.pyλ₯Ό ν΅ν΄ μμ±ν μ μμ΅λλ€.
cd models/research
# Compile protos.
protoc object_detection/protos/*.proto --python_out=.
# Install TensorFlow
pip install tensorflow-gpu
# Install TensorFlow Object Detection API.
cp object_detection/packages/tf2/setup.py .
python -m pip install --use-feature=2020-resolver .
# Test the installation.
python object_detection/builders/model_builder_tf2_test.py
Dataset for object detection on EMNIST letters with COCO 2017 Background. By default, the script generates a dataset with the following attributes:
- 10,000 images in train. 1,000 images in test
- 26 Classes(A ~ Z)
- Between 1 and 5 letters per image
- Gaussian Blur
- Threshold 200
- If the pixel value of EMNIST exceeds the threshold, replace it with COCO image
python generate_dataset.py --data_dir="d:/tensorflow_dataset"
β Tensorflow Datasetμ ν΅ν΄ μλμΌλ‘ λ€μ΄λ‘λ λλλ‘ κ΅¬μ±νμμ΅λλ€.
β COCO 2017μ μ¬μ©νλ―λ‘ λ€μ΄λ‘λ(25.20 GiB) λ° μμΆ ν΄μ μκ°μ΄ μ€λ 걸립λλ€.(1~2μκ°)
The dataset can be visualized with the following command:
python visualize_dataset.py
The dataset can be converted to TFRecord file with the following command:
python generate_tfrecord.py
A local training job can be run with the following command:
python object_detection/model_main_tf2.py --pipeline_config_path="model_zoo/ssd_mobilenet_v2_320x320_coco17_tpu-8/pipeline.config" --model_dir="custom_models/ssd_mobilenet_v2_320x320_coco17_tpu-8" --alsologtostderr
π‘ Traing Step: 50000
A local evaluation job can be run with the following command:
python object_detection/model_main_tf2.py --pipeline_config_path="model_zoo/ssd_mobilenet_v2_320x320_coco17_tpu-8/pipeline.config" --model_dir="custom_models/ssd_mobilenet_v2_320x320_coco17_tpu-8" --checkpoint_dir="custom_models\ssd_mobilenet_v2_320x320_coco17_tpu-8" --alsologtostderr
Progress for training and eval jobs can be inspected using Tensorboard. If using the recommended directory structure, Tensorboard can be run using the following command:
tensorboard --logdir="custom_models/ssd_mobilenet_v2_320x320_coco17_tpu-8"
python infer_ckpt.py --pipeline_config_path="model_zoo/ssd_mobilenet_v2_320x320_coco17_tpu-8/pipeline.config" --checkpoint_dir="custom_models/ssd_mobilenet_v2_320x320_coco17_tpu-8/" --checkpoint_number="ckpt-52" --test_image_path="dataset/emnist_letters_detection/test/images/541.jpg"
An intermediate SavedModel that can be used with the TFLite Converter via commandline or Python API can be generated with the following command:
python object_detection/export_tflite_graph_tf2.py --pipeline_config_path "model_zoo/ssd_mobilenet_v2_320x320_coco17_tpu-8/pipeline.config" --trained_checkpoint_dir "custom_models/ssd_mobilenet_v2_320x320_coco17_tpu-8" --output_directory "custom_models/ssd_mobilenet_v2_320x320_coco17_tpu-8"
The SavedModel can be converted to TFLite with the following command:
python generate_tflite.py
You can infer the TFLite file with the following command:
python test_tflite.py
Pi image installation instructions
TensorFlow Lite Python object detection example with Pi Camera
π© λ λ€ μλλ λΉ λ₯΄λ μΉ΄λ©λΌ μ¬μ©μ μ νλκ° νμ ν λ¨μ΄μ§λλ€. (TγTo)
π© Dataset μμ± λ°©μμ λ°κΎΈκ±°λ λ€λ₯Έ Datasetμ νμ©μ κ³ λ €ν΄λ΄μΌκ² μ΅λλ€.
νμΌμ΄λ ν΄λλͺ λ€μ _oldκ° λΆμ κ²½μ° λ€μμ 쑰건μμ μμ±λ νμΌ:
- fixed size 300 x 300 by resizing
- 4 Classes(A ~ D)
- Threshold 255
- NO Random Crop
- NO Random Horizontal Flip
μΌλ°μ μΈ κΈμ μ΄λ―Έμ§μ λν΄μ νμ΅νμ§ μμ κ΅¬κΈ μ΄λ―Έμ§μ λν΄μλ μ±λ₯μ΄ μ’μ§ λͺ»ν¨.
- Training and Evaluation with TensorFlow 2
- 2.1. Custom DatasetμΌλ‘ TFRecord νμΌ λ§λ€κΈ°
- How to Create to a TFRecord File for Computer Vision and Object Detection
- Install 64 bit OS on Raspberry Pi 4 + USB boot
- TensorFlow Datasets, A collection of ready-to-use datasets
- Cohen, G., Afshar, S., Tapson, J., & Van Schaik, A. (2017, May). EMNIST: Extending MNIST to handwritten letters. In 2017 International Joint Conference on Neural Networks (IJCNN) (pp. 2921-2926). IEEE.
- Sandler, M., Howard, A., Zhu, M., Zhmoginov, A., & Chen, L. C. (2018). Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE conference on computer vision and pattern recognition (pp. 4510-4520).
- Liu, W., Anguelov, D., Erhan, D., Szegedy, C., Reed, S., Fu, C. Y., & Berg, A. C. (2016, October). Ssd: Single shot multibox detector. In European conference on computer vision (pp. 21-37). Springer, Cham.