Ejemplo n.º 1
0
	def get_dice_score(self,prediction,ground_truth):
		masks=(self.get_whole_tumor, self.get_tumor_core, self.get_enhancing_tumor)
		pred=torch.exp(prediction)
		p=np.uint8(np.argmax(pred.data.cpu().numpy(), axis=1))
		gt=np.uint8(ground_truth.data.cpu().numpy())
		wt,tc,et=[2*np.sum(func(p)*func(gt)) / (np.sum(func(p)) + np.sum(func(gt))+1e-3) for func in masks]
		return wt,tc,et
Ejemplo n.º 2
0
	def get_dice_score(self,prediction,ground_truth):
		masks=(self.background, self.opticdisk, self.opticcup)
		pred=torch.exp(prediction)
		p=np.uint8(np.argmax(pred.data.cpu().numpy(), axis=1))
		gt=np.uint8(ground_truth.data.cpu().numpy())
		wt,tc,et=[2*np.sum(func(p)*func(gt)) / (np.sum(func(p)) + np.sum(func(gt))+1e-3) for func in masks]
		return wt,tc,et
 def wrapper(*args, **kwargs):
     beg_ts = time.time()
     retval = func(*args, **kwargs)
     end_ts = time.time()
     # print(fname, "elapsed time: %f" % (end_ts - beg_ts))
     return retval
Ejemplo n.º 4
0
 def __torch_function__(self, func, types, args=(), kwargs=None):
     if kwargs is None:
         kwargs = {}
     args = [a.tensor if hasattr(a, 'tensor') else a for a in args]
     ret = func(*args, **kwargs)
     return ret