srijaydeshpande commited on
Commit
d3c1d96
·
verified ·
1 Parent(s): 5840d6c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -238,6 +238,14 @@ def predict_wsi(image):
238
  def segment_image(image):
239
  img = image
240
  img = np.asarray(img)
 
 
 
 
 
 
 
 
241
  if (np.max(img) > 100):
242
  img = img / 255.0
243
  transform = T.Compose([T.ToTensor()])
 
238
  def segment_image(image):
239
  img = image
240
  img = np.asarray(img)
241
+
242
+ # pad if necessary
243
+ h, w = img.shape[:2]
244
+ pad_h = max(0, min_side - h)
245
+ pad_w = max(0, min_side - w)
246
+ if(pad_h > 0 or pad_w > 0):
247
+ img = np.pad(img, ((0, pad_h), (0, pad_w), (0, 0)), mode='constant', constant_values=0)
248
+
249
  if (np.max(img) > 100):
250
  img = img / 255.0
251
  transform = T.Compose([T.ToTensor()])