コード例 #1
0
import sklearn

from lasagne.layers import InputLayer, Conv2DLayer, DenseLayer, MaxPool2DLayer, InverseLayer

### DATASET
dataSet = myTools.loadImages('../../images', 1024, 1024, 4)

dataSet = myTools.oneDimension(dataSet)

dataSet = dataSet.astype(numpy.uint8)

dataSet = myTools.cropCenter(dataSet, 80)

dataSet = myTools.augmentData(dataSet,
                              numOfTiles=4,
                              overlap=False,
                              imageWidth=819,
                              imageHeight=819)

dataSet = dataSet.astype(numpy.float32)
#plt.show(plt.imshow(dataSet[0][0], cmap=cm.binary))

### MASKS
masks = myTools.loadImages('../../masks', 819, 819, 1)

for x in numpy.nditer(masks, op_flags=['readwrite']):
    if x > 0:
        x[...] = 1

masks = masks.astype(numpy.float32)
コード例 #2
0
    try:
        myTifs.seek(i)
        images[i][0]=myTifs
    except EOFError:
        # Not enough frames in img
        break


#plt.show(plt.imshow(images[0][0]))\
for j in range(30):

	image=images[j, :, :, :]
	image=image.reshape(1, 1, images.shape[2], images.shape[3])

	image=image.astype(numpy.uint8)
	image=myTools.augmentData(image, numOfTiles=1, overlap=False, imageWidth=512, imageHeight=512)
	image=image.astype(numpy.float32)
	imageMeans=numpy.mean(image, axis=(1,2,3), keepdims=True)


	image=image-imageMeans
	#setting parameters for the network
	data_size=(None,1,images[0][0].shape[0],images[0][0].shape[1])
	#load the pretrained network
	myNet=myTools.createPretrainedNN2(data_size, modelFile=modelFilename, filters=numberOfFilters)
	#make predictions for the image
	res=myNet(image)
	#results[j, :, :]=res[0][0]
	scipy.misc.imsave('../../ISBIdata/areYouKiddingMe/res'+str(j)+'.png', res[0][0])

コード例 #3
0
ファイル: mainISBI.py プロジェクト: thanasis-com/MSc-Project
dataSet = np.array(np.zeros(shape=(30, 1, 512, 512)))

for i in range(30):
    try:
        myTifs.seek(i)
        dataSet[i][0] = myTifs
    except EOFError:
        # Not enough frames in img
        break

dataSet = dataSet.astype(numpy.uint8)

dataSet = myTools.augmentData(dataSet,
                              numOfTiles=1,
                              overlap=False,
                              imageWidth=512,
                              imageHeight=512)  #830 850

dataSet = dataSet.astype(numpy.float32)

imageMeans = numpy.mean(dataSet, axis=(1, 2, 3), keepdims=True)

dataSet = dataSet - imageMeans

### MASKS
myTifsMasks = Image.open('../../ISBIdata/train-labels.tif')

masks = np.array(np.zeros(shape=(30, 1, 512, 512)))

for i in range(30):
コード例 #4
0
#get the image path
imagePath=sys.argv[1]
#set output filename
outName=sys.argv[2]
#open the image
image=Image.open(imagePath)
#image as numpy array
image=numpy.asarray(image)
#keep only one dimension
image=image[:,:,0]
#most needed type casting
image=image.astype(numpy.uint8)
#crop the center
image=myTools.cropCenter1(image, 83.1)
#split image to 4
splits=myTools.augmentData(image.reshape(1,1,image.shape[0],image.shape[1]), numOfTiles=4, overlap=False, imageWidth=image.shape[0], imageHeight=image.shape[1])
#another vital type casting
splits=splits.astype(numpy.float32)
#keep only the 4 original tiles
splits=splits[0:4,:,:,:]
#setting parameters for the network
data_size=(None,1,splits[0][0].shape[0],splits[0][0].shape[1])
#load the pretrained network
myNet=myTools.createPretrainedNN(data_size)
#make predictions for the 4 tiles
print(splits.dtype)
res=myNet(splits)
#crop the center of the predictions
res=myTools.cropCenter(res, 93)
#concatenate on the x axis
top=np.concatenate((res[0][0],res[2][0]),axis=1)
コード例 #5
0
outName = sys.argv[2]

#open the image
image = Image.open(imagePath)
#image as numpy array
image = numpy.asarray(image)
#keep only one dimension
image = image[:, :, 0]
#most needed type casting
image = image.astype(numpy.uint8)
#crop the center
#image=myTools.cropCenter1(image, 100)
#this step is mysteriously needed
image = myTools.augmentData(image.reshape(1, 1, image.shape[0],
                                          image.shape[1]),
                            numOfTiles=1,
                            overlap=False,
                            imageWidth=image.shape[0],
                            imageHeight=image.shape[1])
#another vital type casting
image = image.astype(numpy.float32)
#setting parameters for the network
data_size = (None, 1, image[0][0].shape[0], image[0][0].shape[1])

imageMean = numpy.mean(image, keepdims=True)
image = image - imageMean

#load the pretrained network
myNet1 = myTools.createPretrainedNN2(data_size,
                                     modelFile='myModel102Plus90.npz',
                                     filters=32)
#make predictions for the image
コード例 #6
0
        myTifs.seek(i)
        images[i][0] = myTifs
    except EOFError:
        # Not enough frames in img
        break

#plt.show(plt.imshow(images[0][0]))\
for j in range(30):

    image = images[j, :, :, :]
    image = image.reshape(1, 1, images.shape[2], images.shape[3])

    image = image.astype(numpy.uint8)
    image = myTools.augmentData(image,
                                numOfTiles=1,
                                overlap=False,
                                imageWidth=512,
                                imageHeight=512)
    image = image.astype(numpy.float32)
    imageMeans = numpy.mean(image, axis=(1, 2, 3), keepdims=True)

    image = image - imageMeans
    #setting parameters for the network
    data_size = (None, 1, images[0][0].shape[0], images[0][0].shape[1])
    #load the pretrained network
    myNet = myTools.createPretrainedNN2(data_size,
                                        modelFile=modelFilename,
                                        filters=numberOfFilters)
    #make predictions for the image
    res = myNet(image)
    #results[j, :, :]=res[0][0]
コード例 #7
0
ファイル: test.py プロジェクト: thanasis-com/MSc-Project
from sklearn.metrics import confusion_matrix
import sklearn

from lasagne.layers import InputLayer, Conv2DLayer, DenseLayer, MaxPool2DLayer, InverseLayer


### DATASET
dataSet=myTools.loadImages('../../images', 1024, 1024, 4)

dataSet=myTools.oneDimension(dataSet)

dataSet=dataSet.astype(numpy.uint8)

dataSet=myTools.cropCenter(dataSet, 80)

dataSet=myTools.augmentData(dataSet, numOfTiles=4, overlap=False, imageWidth=819, imageHeight=819)
	
dataSet=dataSet.astype(numpy.float32)
#plt.show(plt.imshow(dataSet[0][0], cmap=cm.binary))

### MASKS
masks=myTools.loadImages('../../masks', 819, 819, 1)

for x in numpy.nditer(masks, op_flags=['readwrite']):
     if x>0:
             x[...]=1

masks=masks.astype(numpy.float32)

masks=myTools.augmentData(masks, numOfTiles=4, overlap=False, imageWidth=819, imageHeight=819)
コード例 #8
0
ファイル: main.py プロジェクト: thanasis-com/MSc-Project
print('Learning rate: %f' % (argLR))
print('Weight decay: %f' % (argWD))
print('Number of epochs: %d' % (argEpochs))

random.seed(123)

### DATASET
dataSet=myTools.loadImages('../../images', 1024, 1024, 4)

dataSet=myTools.oneDimension(dataSet)

dataSet=dataSet.astype(numpy.uint8)

dataSet=myTools.cropCenter(dataSet, 83.1)#81.2 83.1

dataSet=myTools.augmentData(dataSet, numOfTiles=1, overlap=False, imageWidth=850, imageHeight=850)#830 850

dataSet=dataSet.astype(numpy.float32)


imageMeans=numpy.mean(dataSet, axis=(1,2,3), keepdims=True)


dataSet=dataSet-imageMeans



### MASKS
masks=myTools.loadImages('../../masksExpertBig', 850, 850, 1)

masks[masks<=50]=0