yongyong-e
[Tensorflow Object Detection API] 3. Testing your own dataset 본문
[Tensorflow Object Detection API] 3. Testing your own dataset
Yonghan Kim 2017. 9. 4. 10:491) Exporting the Tensorflow Graph
Training후, 생성된 model.ckpt-{CEHCKPOINT_NUMBER}.* 파일들을 inference_graph로 변환하여 학습된 모델을 평가해보자.
# models/object_detection/
python export_inference_graph.py \
--input_type image_tensor \
--pipeline_config_path training/ssd_mobilenet_v1_pets.config \
--trained_checkpoint_prefix training/model.ckpt-{CHECKPOINT_NUMBER} \
--output_directory inference_graph_fish
스크립트 실행 후, 다음과 같이 inference_graph가 생성된 것을 볼 수 있다.
2) Test preparation
이제 test를 위해 models/object_detection/test_images 디렉토리에 test하고 싶은 이미지를 image{NUMBER}.jpg으로 저장하도록 한다.
그리고 object_detection_tutorial.ipynb의 코드 몇몇 부분을 수정하여 test를 해보자.
In[4]:
# What model to download.
MODEL_NAME = 'inference_graph_fish'
# MODEL_FILE = MODEL_NAME + '.tar.gz'
# DOWNLOAD_BASE = 'http://download.tensorflow.org/models/object_detection/'
# Path to frozen detection graph. This is the actual model that is used for the object detection.
PATH_TO_CKPT = MODEL_NAME + '/frozen_inference_graph.pb'
# List of the strings that is used to add correct label for each box.
PATH_TO_LABELS = os.path.join('data', 'object-detection.pbtxt')
NUM_CLASSES = 1
In[5]:
Download Model 부분의 코드는 삭제.
In[8]:
# For the sake of simplicity we will use only 2 images:
# image1.jpg
# image2.jpg
# If you want to test the code with your images, just add path to the images to the TEST_IMAGE_PATHS.
PATH_TO_TEST_IMAGES_DIR = 'test_images'
TEST_IMAGE_PATHS = [ os.path.join(PATH_TO_TEST_IMAGES_DIR, 'image{}.jpg'.format(i)) for i in range(3, 6) ]
# Size, in inches, of the output images.
IMAGE_SIZE = (12, 8)
3) Run All
이제 object_detection_tutorial.ipynb를 실행하여 결과를 확인해보자.
'머신러닝 > Tensorflow - Models' 카테고리의 다른 글
[Error] protoc object_detection/protos/*.proto --python_out=. (1) | 2018.05.02 |
---|---|
[Tensorflow Object Detection API] Download tensorflow detection models (0) | 2017.09.27 |
[Tensorflow Object Detection API] 2. Training your own dataset (11) | 2017.08.30 |
[Tensorflow Object Detection API] 1. Creating your own dataset (25) | 2017.08.29 |
[Tensorflow-Slim] Convert to TFRecord file (0) | 2017.08.16 |