コード例 #1
0
        shuffle(ld)
        numTrainEx      = len(listdir(indir+"tempTrain/"))
        trainImages     = np.zeros((numTrainEx,timeSteps,1,wSize,wSize),dtype=np.float)
        trainTargets    = np.zeros((numTrainEx,outsize),dtype=np.float)
        trainCIDs            = []

        added   = 0 #keep track of how many images have been added
        count   = 0
        while added < numTrainEx:
            x   = ld[count]
            if x.find(".sdf") > -1:
                try:
                    try:
                        CID     = x[:x.find(".sdf")]
                        
                        image   = helperFuncs.processImage(CID,trainFolder,binarize,blur,padding,size,noise=True)                        
                        #mi.imsave("../evaluation/"+str(CID)+".jpg",image)                        
                        subprocess.call("rm "+trainFolder+x,shell=True)
                        image   = im2window(image,wSize,stride)                        
                        trainImages[added,:,:,:,:]  = image
                        trainTargets[added]         = targets[CID] 
                        trainCIDs.append(CID)
                        
                        added+=1
                        print added
                    except (IOError,ValueError) as e:
                        print e
                except (KeyError, ValueError) as e:
                    subprocess.call("rm "+trainFolder+x,shell=True) #This means this molecule was too big
            count+=1
            if count > len(ld)-1:
コード例 #2
0
        numTrainEx      = len(listdir(indir+"tempTrain/"))
        trainImages     = np.zeros((numTrainEx,1,size,size),dtype=np.float)
        trainTargets    = np.zeros((numTrainEx,outsize),dtype=np.float)
        trainCIDs            = []

        added   = 0
        count   = 0
        while added < numTrainEx:
            x   = ld[count]
            print x, added
            if x.find(".sdf") > -1:
                try:
                    try:
                        CID     = x[:x.find(".sdf")]
                        
                        image   = helperFuncs.processImage(CID,trainFolder,binarize,blur,padding,size,noise=True)                        
                        subprocess.call("rm "+trainFolder+x,shell=True)                        
                        trainImages[added,0,:,:]    = image
                        trainTargets[added]         = targets[CID] 
                        trainCIDs.append(CID)
                        added+=1

                    except (IOError,ValueError) as e:
                        print e
                except (KeyError, ValueError) as e:
                    subprocess.call("rm "+trainFolder+x,shell=True) #This means this molecule was too big
            count+=1
            if count > len(ld)-1:
                count = 0
                ld = listdir(trainFolder)
            while len(ld) == 0:
コード例 #3
0
        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)
            print "resizing"
            print image.shape

            image = helperFuncs.processImage(None,
                                             "/",
                                             True,
                                             0.3,
                                             "random",
                                             300,
                                             noise=True,
                                             image=image)

            #            image   = myResize(image,imdim)
            #image   = putInSize(image,imdim)
            #            image   = np.where(image >0.05, 1.,0)
            #            image   = filters.gaussian_filter(image,0.2)
            #            image   = 0.05*np.random.rand(image.shape[0], image.shape[1]) + image

            #image   = filters.gaussian_filter(image,0.2)
            #print "binarizing"
            print image.shape
            #image   = np.where(image>0.2,1,0)
            #            for countzor in range(0,image.shape[0]):
コード例 #4
0
    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)
            print "resizing"
            print image.shape
            
            image   = helperFuncs.processImage(None,"/",True,0.3,"random",300,noise=True,image=image)            
            
#            image   = myResize(image,imdim)
            #image   = putInSize(image,imdim)
#            image   = np.where(image >0.05, 1.,0)
#            image   = filters.gaussian_filter(image,0.2)
#            image   = 0.05*np.random.rand(image.shape[0], image.shape[1]) + image

            #image   = filters.gaussian_filter(image,0.2)
            #print "binarizing"
            print image.shape
            #image   = np.where(image>0.2,1,0)
#            for countzor in range(0,image.shape[0]):
#                print image[countzor,:]
#                stop=raw_input("")
            #image   = np.where(image > 0.1,1.0,0.0)