Ejemplo n.º 1
0
OS_UPPER_PATH = os.getcwd()
labels_path = OS_UPPER_PATH + "/Resources/SWUPark/test.txt"
root_images_folder = OS_UPPER_PATH + "/Resources/SWUPark/All"
weights_file = OS_UPPER_PATH + "/" + model_prop.weight_filename
text_output_filename = "TEXT_" + model_prop.weight_filename

#Initialize Variables
batch_size = 1000
image_color_channel = 3
image_size_w = 224
image_size_h = 224
resume_at_epoch = 0

#Initialize Necessary  Object
confusion_mat = ConfusionMatrixObject()
file_writer = FileWriterObject(f_name=OS_UPPER_PATH + "/" +
                               text_output_filename + ".final")

model = MiniAlexnet(base_lr=model_prop.base_lr,
                    momentum=model_prop.momentum,
                    decay_rate=model_prop.decay_rate,
                    nesterov=model_prop.nesterov)
model.load_weights(weights_file)
model.summary()

confusion_mat = ConfusionMatrixObject()

i = 0
while (True):
    x_test, y_test, test_num = read_labels_batch_out(
        labels_path, (224, 224), (224, 224),
        root_images_folder,
iteration_count = 999
image_color_channel = 3
image_size_w = 224
image_size_h = 224

#Initialize Files Directory
prototxt_path = LINUX_UPPER_PATH + "/Resources/NewModels/mAlexNet-on-CNRParkAB_all-val-CNRPark-EXT_val/deploy.prototxt"
caffemodel_path = LINUX_UPPER_PATH + "/Resources/NewModels/mAlexNet-on-CNRParkAB_all-val-CNRPark-EXT_val/snapshot_iter_870.caffemodel"
labels_path = LINUX_UPPER_PATH + "/Resources/SWUPark/test.txt"
means_images_npy_path = ""
root_images_folder = LINUX_UPPER_PATH + "/Resources/SWUPark/All"
text_output_filename = "TEXT_result_B_(mAlexNet-on-CNRParkAB_all-val-CNRPark-EXT_val)_SWUPark-TEST_caffe"

#Initialize Necessary  Object
confusion_mat = ConfusionMatrixObject()
file_writer = FileWriterObject(f_name=LINUX_UPPER_PATH + "/" +
                               text_output_filename + ".final")

print("---All Of Nesessary Initialize Complete---")

######################################################################################################
######################################################################################################
######################################################################################################

#Import Model
net = caffe.Net(prototxt_path, caffemodel_path, caffe.TEST)

#Set Preprocessor
transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape})
#(Swap) H x W x C >>> C x H x W
transformer.set_transpose('data', (2, 0, 1))
#(Swap) R : G : B >>> B : G : R