Open natures66 opened 4 years ago
You can use the COCO evaluation metrics to evaluate your trained model. Notes on how to do this can be found here and here.
You can use the COCO evaluation metrics to evaluate your trained model. Notes on how to do this can be found here and here.
so can I measure my trained model by using eval.py just change images of eval to images of test?
I trained the model on my own dataset, then I modified the object_detection_test.ipynb to my_test_tutorial.py for my test images. But I found this code just for draw predict bounding box, how I change it to draw ground truth box and calculate the precison and recall of every class?
`# Imports import time
start = time.time() import numpy as np import os import six.moves.urllib as urllib import sys import tarfile import tensorflow as tf import zipfile import cv2
from collections import defaultdict from io import StringIO from matplotlib import pyplot as plt from PIL import Image
os.chdir('D:\models-master\models\research\object_detection')
sys.path.append("..")
from utils import label_map_util
from utils import visualization_utils as vis_util
MODEL_NAME = 'D:\models-master\models\research\object_detection\myoutput'
PATH_TO_CKPT = MODEL_NAME + '/frozen_inference_graph.pb'
PATH_TO_LABELS = os.path.join('D:\models-master\models\research\object_detection\mydata', 'mylabelmap.pbtxt')
NUM_CLASSES = 5
detection_graph = tf.Graph() with detection_graph.as_default(): od_graph_def = tf.GraphDef() with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid: serialized_graph = fid.read() od_graph_def.ParseFromString(serialized_graph) tf.import_graph_def(od_graph_def, name='')
label_map = label_map_util.load_labelmap(PATH_TO_LABELS) categories = label_map_util.convert_label_map_to_categories(label_map, max_num_classes=NUM_CLASSES, use_display_name=True) category_index = label_map_util.create_category_index(categories)
def load_image_into_numpy_array(image): (im_width, im_height) = image.size return np.array(image.getdata()).reshape( (im_height, im_width, 3)).astype(np.uint16)
PATH_TO_TEST_IMAGES_DIR = 'D:\models-master\models\research\object_detection\myimages\test_images' os.chdir(PATH_TO_TEST_IMAGES_DIR) TEST_IMAGE_PATHS = os.listdir(PATH_TO_TEST_IMAGES_DIR)
IMAGE_SIZE = (12, 8)
output_path = ('D:\models-master\models\research\object_detection\mytestout\')
with detection_graph.as_default(): with tf.Session(graph=detection_graph) as sess:
end = time.time() print("Execution Time: ", end - start)`