'code_vs_no_code_strict.h5', 'code_vs_no_code_partially.h5', 'code_vs_no_code_partially_handwritten.h5', 'handwritten_vs_else.h5', 'all_four.h5' ] # java-python weight training ops weights = ['java_python.h5' ] #,'java_python_no_code.h5','java_python_pv_no_code.h5'] for weight in weights: if weight == 'all_four.h5': options = four_options model = VGG(shape, 4) else: options = two_options model = VGG(shape, 2) # load weights file model.load_weights('../../jp_Fold_0/' + weight) # make directory for images os.mkdir('jp_Images/' + weight.replace('.h5', '/')) # predict classes for testing images predicitions = model.predict(images) # iterate over all the predictions to produce cam for i in range(len(predicitions)): # get class label from prediction code = np.argmax(predicitions[i]) # label photo name = '_Predicted ' + options[code] location = 'jp_Images/' + weight.replace('.h5', '/') + str(i) + name cam = visualize_cam(model, len(model.layers) - 1, code,
""" import config as cf from model import VGG from keras.models import * from prepare_data import * import matplotlib.pyplot as plt import random train_x,train_y,val_x,val_y = create_data_test() model = VGG(shape=(64, 256, 1)) model.summary() model.load_weights(cf.CKP_PATH) n = val_x.shape[0] count = 0 pred = model.predict(val_x) pred = np.argmax(pred,axis=-1) true = np.argmax(val_y,axis = -1) for i in range(n): if np.all(pred[i,:]==true[i]): count +=1 print("total acc: " +str(count/n*100)+"%") k = random.randint(0,10000) imgplot = plt.imshow(val_x[k,:,:,:].reshape(64,256))