-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess_tiles.py
35 lines (27 loc) · 1.22 KB
/
process_tiles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
import pandas as pd
from classes.PlipDataProcess import PlipDataProcess
from transformers import CLIPImageProcessor
import argparse
def main(csv_file, root_dir, save_dir):
df4 = pd.read_csv(csv_file).set_index('PatientID')
files = [file for file in os.listdir(root_dir) if os.path.isdir(os.path.join(root_dir, file))]
img_processor = CLIPImageProcessor.from_pretrained("./plip/")
dataset = PlipDataProcess(
root_dir=root_dir,
files=files,
df=df4,
img_processor=img_processor,
num_tiles_per_patient=2000,
max_workers=64,
save_dir=save_dir
)
for i in range(len(dataset)):
_ = dataset[i]
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Process WSI images and generate tiles")
parser.add_argument('--csv_file', type=str, required=True, help='Path to the CSV file with patient scores')
parser.add_argument('--root_dir', type=str, required=True, help='Root directory for WSI tiles')
parser.add_argument('--save_dir', type=str, required=True, help='Directory to save the processed tile data')
args = parser.parse_args()
main(csv_file=args.csv_file, root_dir=args.root_dir, save_dir=args.save_dir)