afiliot commited on
Commit
62af27b
·
verified ·
1 Parent(s): 8cb3a29

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +4 -3
README.md CHANGED
@@ -165,8 +165,8 @@ dataloader = DataLoader(
165
  slide_features = []
166
  current_num_tiles = 0
167
 
168
- for i, (slide_ids, tile_ids, imgs) in tqdm(
169
- enumerate(dataloader),
170
  total=ceil(num_slides * num_tiles / batch_size),
171
  desc="Extracting features"
172
  ):
@@ -176,7 +176,8 @@ for i, (slide_ids, tile_ids, imgs) in tqdm(
176
  if all(slide_id == reference_slide_id for slide_id in slide_ids):
177
  batch_stack = process_imgs(imgs, tile_ids)
178
  slide_features.append(batch_stack)
179
- current_num_tiles += batch_size
 
180
  # If the current batch contains exactly the last `batch_size` tile features for the slide,
181
  # export the slide features and reset `slide_features` and `current_num_tiles`
182
  if current_num_tiles == num_tiles:
 
165
  slide_features = []
166
  current_num_tiles = 0
167
 
168
+ for (slide_ids, tile_ids, imgs) in tqdm(
169
+ dataloader,
170
  total=ceil(num_slides * num_tiles / batch_size),
171
  desc="Extracting features"
172
  ):
 
176
  if all(slide_id == reference_slide_id for slide_id in slide_ids):
177
  batch_stack = process_imgs(imgs, tile_ids)
178
  slide_features.append(batch_stack)
179
+ # For the very last slide, the last batch may be of size < `batch_size`
180
+ current_num_tiles += batch_stack.shape[0]
181
  # If the current batch contains exactly the last `batch_size` tile features for the slide,
182
  # export the slide features and reset `slide_features` and `current_num_tiles`
183
  if current_num_tiles == num_tiles: