#convert the coords to image before streching to 448*448 left = left/448.0 * W right = right/448.0 * W up = up/448.0 * H down = down/448.0 * H #drawable.rectangle([left,up,right,down],outline="red") if(class_num == 4): fbottle.write(img_name+' '+str(round(prob,6))+' '+str(round(left,6))+' '+str(round(up,6))+' '+str(round(right,6))+' '+str(round(down,6))+'\n') elif(class_num == 6): fcar.write(img_name+' '+str(round(prob,6))+' '+str(round(left,6))+' '+str(round(up,6))+' '+str(round(right,6))+' '+str(round(down,6))+'\n') elif(class_num == 7): fcat.write(img_name+' '+str(round(prob,6))+' '+str(round(left,6))+' '+str(round(up,6))+' '+str(round(right,6))+' '+str(round(down,6))+'\n') elif(class_num == 18): ftrain.write(img_name+' '+str(round(prob,6))+' '+str(round(left,6))+' '+str(round(up,6))+' '+str(round(right,6))+' '+str(round(down,6))+'\n') #img.save(os.path.join(os.getcwd(),'results',img_name+'.jpg')) return model = model_from_json(open('Tiny_Yolo_Architecture.json').read(),custom_objects={'custom_loss':custom_loss}) model.load_weights('Tiny_Yolo_weights_07_12_33102_iter2.h5') #Measure Test Accuracy sample_number = 4952 vocPath= os.path.join(os.getcwd(),'dataset/VOCdevkit/VOC2007') imageNameFile= os.path.join(vocPath,'ImageSets/Main/test.txt') imageList = prepareBatch(0,sample_number,imageNameFile,vocPath) Acc(imageList,model)
def MeasureAcc(model,sample_number,vocPath,imageNameFile): imageList = prepareBatch(0,sample_number,imageNameFile,vocPath) acc = Acc(imageList,model) re = Recall(imageList,model) return acc,re
def MeasureAcc(model, sample_number, vocPath, imageNameFile): imageList = prepareBatch(0, sample_number, imageNameFile, vocPath) acc = Acc(imageList, model) re = Recall(imageList, model) return acc, re
if (preds[24] > thresh): predcit_class = np.argmax(preds[4:24]) if (predcit_class == true_class): correct += 1 return correct * 1.0 / obj_num def MeasureAcc(model, sample_number, vocPath, imageNameFile): imageList = prepareBatch(0, sample_number, imageNameFile, vocPath) acc = Acc(imageList, model) re = Recall(imageList, model) return acc, re model = model_from_json(open('Tiny_Yolo_Architecture.json').read(), custom_objects={'custom_loss': custom_loss}) model.load_weights('weights2.hdf5') #Measure Test Accuracy sample_number = 4952 vocPath = os.path.join(os.getcwd(), 'dataset/VOCdevkit/VOC2007') imageNameFile = os.path.join(vocPath, 'ImageSets/Main/test.txt') imageList = prepareBatch(0, sample_number, imageNameFile, vocPath) acc = Acc(imageList, model) #re = Recall(imageList,model) #print "Accuracy and Recall are: ",acc,re print "Accuracy is: ", acc