示例#1
0

"""Load the train/test split information if update, else split and write out which images are in which dataset"""
if update:
    trainFs, testFs     = getTrainTestSplit(update,folder)
else:
    trainFs, testFs     = getTrainTestSplit(update,folder,numEx,trainTestSplit,ld)
trainL  = len(trainFs)
testL   = len(testFs)


print "number of examples: ", numEx
print "training examples : ", trainL
print "test examples : ", testL

OCRfeatures,labels  = getOCRTargets() #get the ECFP vector for each CID
#testAverages(direct,OCRfeatures)   # determind the RMSE of guessing the mean
outsize             = len(OCRfeatures[OCRfeatures.keys()[0]]) #this it the size of the target (# of OCRfeatures)

"""If we are training a new model, define it"""   
print "loading model"
if not update:
    model = Sequential()
    
    model.add(Convolution2D(16, 1, lay1size, lay1size, border_mode='full')) 
    model.add(Activation('relu'))

    model.add(MaxPooling2D(poolsize=(2,2)))

    model.add(Convolution2D(32, 16, lay1size, lay1size, border_mode='full')) 
    model.add(Activation('relu'))
示例#2
0
#else:
#    print "Initializing in folder "+folder
"""Load the train/test split information if update, else split and write out which images are in which dataset"""
if update:
    trainFs, testFs = getTrainTestSplit(update, folder)
else:
    trainFs, testFs = getTrainTestSplit(update, folder, numEx, trainTestSplit,
                                        ld)
trainL = len(trainFs)
testL = len(testFs)

print "number of examples: ", numEx
print "training examples : ", trainL
print "test examples : ", testL

OCRfeatures, labels = getOCRTargets()  #get the ECFP vector for each CID
#testAverages(direct,OCRfeatures)   # determind the RMSE of guessing the mean
outsize = len(OCRfeatures[
    OCRfeatures.keys()[0]])  #this it the size of the target (# of OCRfeatures)
"""If we are training a new model, define it"""
print "loading model"
if not update:
    model = Sequential()

    model.add(Convolution2D(16, 1, lay1size, lay1size, border_mode='full'))
    model.add(Activation('relu'))

    model.add(MaxPooling2D(poolsize=(2, 2)))

    model.add(Convolution2D(32, 16, lay1size, lay1size, border_mode='full'))
    model.add(Activation('relu'))
示例#3
0
def getSize(folder):
    fold = folder[folder[-1].rfind("/") + 1:]
    fold = fold[:fold.find("_")]
    print fold
    fold = fold[fold.rfind("/") + 1:]
    print fold
    return fold


with open(sys.argv[1] + "wholeModel.pickle", 'rb') as f:
    model = cPickle.load(f)

size = int(getSize(sys.argv[1]))
imdim = size
#OCRfeatures, labels     = getOCRScaledTargets()
OCRTargets, labels = getOCRTargets()
means, stds = getMeansStds()

if True:
    ld = listdir("/home/test/usan/")
    images = np.zeros((1, 1, imdim, imdim), dtype=np.float)
    for x in ld:
        print x
        try:
            CID = x
            print "reading in"
            image = io.imread("/home/test/usan/" + x, as_grey=True)
            image = minusOnes(image)
            print "numpying"
            image = np.array(image)
            #image   = convertIt(image)
示例#4
0
def getSize(folder):
    fold 	= folder[folder[-1].rfind("/")+1:]
    fold 	= fold[:fold.find("_")]
    print fold
    fold 	= fold[fold.rfind("/")+1:]
    print fold
    return fold

with open(sys.argv[1]+"wholeModel.pickle",'rb') as f:
    model   = cPickle.load(f)
    
size 	= int(getSize(sys.argv[1]))
imdim   = size
#OCRfeatures, labels     = getOCRScaledTargets()
OCRTargets, labels  = getOCRTargets()
means,stds  = getMeansStds()
    
    
if True:
    ld  = listdir("/home/test/usan/")
    images  = np.zeros((1,1,imdim,imdim),dtype=np.float)
    for x in ld:
        print x
        try:
            CID     = x
            print "reading in"
            image   = io.imread("/home/test/usan/"+x,as_grey=True)
            image   = minusOnes(image)
            print "numpying"
            image   = np.array(image)