Skip to content

Commit

Permalink
fix: only CSV's images when -all arg is False
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre-Delplanque committed Jun 17, 2023
1 parent addbc9b commit c0bfc31
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tools/patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Please contact the author Alexandre Delplanque ([email protected]) for any questions.
Last modification: March 29, 2023
Last modification: June 17, 2023
"""
__author__ = "Alexandre Delplanque"
__license__ = "CC BY-NC-SA 4.0"
Expand All @@ -21,6 +21,7 @@
import torchvision
import numpy
import cv2
import pandas

from albumentations import PadIfNeeded

Expand Down Expand Up @@ -57,6 +58,9 @@ def main():
patches_buffer = PatchesBuffer(args.csv, args.root, (args.height, args.width), overlap=args.overlap, min_visibility=args.min).buffer
patches_buffer.drop(columns='limits').to_csv(os.path.join(args.dest, 'gt.csv'), index=False)

if not args.all:
images_paths = [os.path.join(args.root, x) for x in pandas.read_csv(args.csv)['images'].unique()]

for img_path in tqdm(images_paths, desc='Exporting patches'):
pil_img = PIL.Image.open(img_path)
img_tensor = torchvision.transforms.ToTensor()(pil_img)
Expand Down

0 comments on commit c0bfc31

Please sign in to comment.