soumickmj commited on
Commit
4e75471
1 Parent(s): d1efa41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -6
app.py CHANGED
@@ -48,14 +48,9 @@ def infer_full_vol(tensor, model):
48
 
49
  def infer_patch_based(tensor, model, patch_size=64, stride_length=32, stride_width=32, stride_depth=16, batch_size=10, num_worker=2):
50
  test_subject = tio.Subject(img = tio.ScalarImage(tensor=tensor.unsqueeze(0))) # adding channel dim while creating the TorchIO subject
51
-
52
  overlap = np.subtract(patch_size, (stride_length, stride_width, stride_depth))
53
 
54
  def normaliser(batch):
55
- """
56
- Purpose: Normalise pixel intensities of each patch using the max values in the 3D patch
57
- :param batch: 5D array (batch_size x channel x width x depth x height)
58
- """
59
  for i in range(batch.shape[0]):
60
  batch[i] = batch[i] / batch[i].max()
61
  return batch
@@ -74,7 +69,6 @@ def infer_patch_based(tensor, model, patch_size=64, stride_length=32, stride_wid
74
  st.text(f"Processing batch {i + 1} of {total_batches}...")
75
 
76
  local_batch = normaliser(patches_batch['img'][tio.DATA].float())
77
- local_batch = local_batch / local_batch.max()
78
  locations = patches_batch[tio.LOCATION]
79
 
80
  local_batch = torch.movedim(local_batch, -1, -3)
 
48
 
49
  def infer_patch_based(tensor, model, patch_size=64, stride_length=32, stride_width=32, stride_depth=16, batch_size=10, num_worker=2):
50
  test_subject = tio.Subject(img = tio.ScalarImage(tensor=tensor.unsqueeze(0))) # adding channel dim while creating the TorchIO subject
 
51
  overlap = np.subtract(patch_size, (stride_length, stride_width, stride_depth))
52
 
53
  def normaliser(batch):
 
 
 
 
54
  for i in range(batch.shape[0]):
55
  batch[i] = batch[i] / batch[i].max()
56
  return batch
 
69
  st.text(f"Processing batch {i + 1} of {total_batches}...")
70
 
71
  local_batch = normaliser(patches_batch['img'][tio.DATA].float())
 
72
  locations = patches_batch[tio.LOCATION]
73
 
74
  local_batch = torch.movedim(local_batch, -1, -3)