srijaydeshpande commited on
Commit
4f478b4
·
verified ·
1 Parent(s): aac0c54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -237,18 +237,19 @@ def predict_wsi(image):
237
  @spaces.GPU(duration=120)
238
  def segment_image(image):
239
  img = image
 
240
 
241
  # resize if necessary
242
- # min_side=768
243
- # print(img.size)
244
- # w, h = img.size
245
- # if min(w, h) < min_side:
246
- # scale = min_side / min(w, h)
247
- # new_w, new_h = int(w * scale), int(h * scale)
248
- # img = img.resize((new_w, new_h), Image.ANTIALIAS)
 
 
249
 
250
- img = np.asarray(img)
251
- print(img.shape)
252
  if (np.max(img) > 100):
253
  img = img / 255.0
254
  transform = T.Compose([T.ToTensor()])
 
237
  @spaces.GPU(duration=120)
238
  def segment_image(image):
239
  img = image
240
+ img = np.asarray(img)
241
 
242
  # resize if necessary
243
+ h, w = img.shape[:2]
244
+ if min(h, w) < min_side:
245
+ scale = min_side / min(h, w)
246
+ new_w, new_h = int(w * scale), int(h * scale)
247
+ # Convert NumPy array to PIL Image
248
+ image = Image.fromarray(img)
249
+ # Resize the image using PIL
250
+ resized_image = image.resize((new_w, new_h), Image.ANTIALIAS)
251
+ img = np.array(resized_image)
252
 
 
 
253
  if (np.max(img) > 100):
254
  img = img / 255.0
255
  transform = T.Compose([T.ToTensor()])