Пример #1
0
WINDOW_Y = 80

# load test data
print("Loading images for test...")
x_test, x_test_files = file_handler.load_images_for_keras(
    my_paths.VALIDATION_PATH,
    "png",
    100000,
    WINDOW_X,
    WINDOW_Y,
    num_channels=3,
    scale=True)
x_test = x_test / 255

print("Loading dictionary for y_train...")
my_logger = r_logger.R_logger(os.path.join(my_paths.INFO_PATH, "data.csv"))
my_y_values = my_logger.load_dictionary()

print("Get y values...")
y_test = image_handler.get_y_value(x_test_files, my_y_values,
                                   my_paths.human_labels)

#create y_train and y_test values
print('Number of images in x_test', x_test.shape[0])
print('Number of images in y_test', y_test.shape[0])

# load the trained neural network
from keras.models import load_model

model_name = "path_1_richardson_X1.h5"
my_model = load_model(model_name)
#dimensions of input image
WINDOW_X = 80
WINDOW_Y = 80

from keras import backend as K

print(K.tensorflow_backend._get_available_gpus())

import matplotlib.pyplot as plt

max_images = 20000
input_shape = (WINDOW_Y, WINDOW_X, 3)

print("Loading dictionary for y_train...")
my_logger = r_logger.R_logger(os.path.join(my_paths.INFO_PATH, "data.csv"))
my_y_values = my_logger.load_dictionary()

print("Loading images for train...")
x_train, x_train_files = file_handler.load_images_for_keras(
    my_paths.TRAIN_PATH, "png", max_images, WINDOW_X, WINDOW_Y, num_channels=3)
x_train = x_train / 255

print("Loading images for test...")
x_test, x_test_files = file_handler.load_images_for_keras(
    my_paths.VALIDATION_PATH,
    "png",
    max_images,
    WINDOW_X,
    WINDOW_Y,
    num_channels=3)
Пример #3
0
boxes = load_data(richardson_path.META_FILE, richardson_path.META_PATH)

img_list = []
for label_name in richardson_path.human_labels:
    rows_human = boxes.loc[boxes.LabelName == label_name]

    #create a list
    for row in rows_human.ImageID:
        if row not in img_list:  # make sure you only have unique entries!
            img_list.append(row)

# select rows with ImageID
#img_id = "00a159a661a2f5aa"

from Richardson_Logger import r_logger
my_logger = r_logger.R_logger(richardson_path.INFO_PATH + '/' + "data.csv")
my_logger.clear()
my_logger.write_line("tvt,flag_person,imgid\n")

total_collection = 0  # keep track of how many images are in your dataset
for img_id in img_list:
    #img_id = img_list[2]

    #remove extension
    img_id = img_id.split('.')[0]

    select_rows = boxes.loc[boxes.ImageID == img_id]
    if (len(select_rows.index) == 0):
        continue
    #print(select_rows)
Пример #4
0
        lineType)
    '''     
    #save image with bounding boxes to output folder       
    
    file_handler.save_image('obj_detected' + str(img_index) +'.png', path = my_paths.OBJ_TEST_RESULTS, image_data = my_image, flag_png = True, remove_color = False)
   
    return

if os.path.exists(my_paths.OBJ_TEST_RESULTS) == False:
	os.mkdir(my_paths.OBJ_TEST_RESULTS)

my_model.summary()
meta_data = data.get('_via_img_metadata')
files = file_handler.get_file_list(my_paths.TTC_PATH)

my_logger = r_logger.R_logger(os.path.join("richardson_info_files", "obj_mAP_values.csv"))
my_logger.clear()
my_logger.write_line("Detector threshold: " + str(detector_threshold) + "\n")
my_logger.write_line("Model Name: " + model_name + "\n")
my_logger.write_line("imageid, boundingbox_id, IOU, sourceimage\n")

img_index=0
for file_to_scan in files:
    #get ground truth bounding box from JSON
    true_bounding_boxes = get_bounding_box(meta_data, file_to_scan)
    my_image = file_handler.load_image(file_to_scan, path=my_paths.TTC_PATH, flag_bw_load=False)[0]
    process_image(my_image, img_index, my_logger, true_bounding_boxes)
    img_index = img_index + 1