Changeset - 5f42b982809c
[Not reviewed]
default
0 3 0
Laman - 6 years ago 2019-05-24 11:31:52

deferred data preprocessing saving space
3 files changed with 6 insertions and 6 deletions:
0 comments (0 inline, 0 general)
exp/kerokero/prepare_data.py
Show inline comments
 
@@ -37,7 +37,7 @@ class Sample:
 
			m=np.matmul(mi,m)
 
		m=np.matmul(self._computeCrop(m),m)
 
		img=cv.warpPerspective(self.img,m,(self.SIDE,self.SIDE))
 
		img=np.float32(img)/128-1
 
		img=np.uint8(img)
 
		grid=Corners(c.transform(m) for c in self.grid)
 
		grid=list(map(lambda p: list(2*p/self.SIDE-EPoint(1,1)), grid))
 
		return (img,grid)
 
@@ -108,8 +108,8 @@ def loadDataset(root):
 
	labels=[labels[k] for k in keys]
 
	m=int(n*trainRatio)
 
	return (
 
		(np.float32(images[:m]),np.float32(labels[:m])),
 
		(np.float32(images[m:]),np.float32(labels[m:]))
 
		(np.uint8(images[:m]),np.float32(labels[:m])),
 
		(np.uint8(images[m:]),np.float32(labels[m:]))
 
	)
 

	
 

	
exp/kerokero/test.py
Show inline comments
 
@@ -24,7 +24,7 @@ model.summary()
 

	
 
log.info("loading data...")
 
with np.load(args.data) as data:
 
	testImages=data["testImages"].reshape((-1,224,224,1))
 
	testImages=(np.float32(data["testImages"])/128-1).reshape((-1,224,224,1))
 
	testLabels=data["testLabels"].reshape((-1,4,2))
 
log.info("done")
 

	
exp/kerokero/train.py
Show inline comments
 
@@ -79,9 +79,9 @@ if args.load_model:
 

	
 
log.info("loading data...")
 
with np.load(args.data) as data:
 
	trainImages=data["trainImages"].reshape((-1,224,224,1))
 
	trainImages=(np.float32(data["trainImages"])/128-1).reshape((-1,224,224,1))
 
	trainLabels=data["trainLabels"].reshape((-1,4,2))
 
	testImages=data["testImages"].reshape((-1,224,224,1))
 
	testImages=(np.float32(data["testImages"])/128-1).reshape((-1,224,224,1))
 
	testLabels=data["testLabels"].reshape((-1,4,2))
 
log.info("done")
 

	
0 comments (0 inline, 0 general)