-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
162 lines (142 loc) · 4.19 KB
/
Copy pathmain.py
File metadata and controls
162 lines (142 loc) · 4.19 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
"""Main entry point for CBCT Report Generation pipeline.
Commands:
preprocess: Preprocess ToothFairy3 dataset and extract regional tokens
train: Train the report generation model
evaluate: Evaluate the model on test set
"""
import argparse
import sys
from pathlib import Path
def preprocess_command(args):
"""Run preprocessing on the dataset."""
from src.preprocess_dataset import preprocess_dataset
preprocess_dataset(
dataset_root=args.dataset_root,
output_dir=args.output_dir,
skip_existing=args.skip_existing,
max_samples=args.max_samples,
generate_tsne=args.tsne,
generate_pca=args.pca,
)
def train_command(args):
"""Train the report generation model."""
print("Training not yet implemented")
# TODO: Implement training
pass
def evaluate_command(args):
"""Evaluate the model."""
print("Evaluation not yet implemented")
# TODO: Implement evaluation
pass
def main():
parser = argparse.ArgumentParser(
description='CBCT Report Generation Pipeline',
formatter_class=argparse.RawDescriptionHelpFormatter,
)
subparsers = parser.add_subparsers(dest='command', help='Command to run')
# Preprocess command
preprocess_parser = subparsers.add_parser(
'preprocess',
help='Preprocess dataset and extract regional tokens'
)
preprocess_parser.add_argument(
'--dataset-root',
type=str,
default='data/ToothFairy3',
help='Root directory of ToothFairy3 dataset'
)
preprocess_parser.add_argument(
'--output-dir',
type=str,
default='data/preprocessed_tokens',
help='Directory to save preprocessed tokens'
)
preprocess_parser.add_argument(
'--skip-existing',
action='store_true',
default=True,
help='Skip processing if output file exists'
)
preprocess_parser.add_argument(
'--no-skip-existing',
dest='skip_existing',
action='store_false',
help='Reprocess all files even if they exist'
)
preprocess_parser.add_argument(
'--max-samples',
type=int,
default=None,
help='Maximum number of samples to process (for testing)'
)
preprocess_parser.add_argument(
'--tsne',
action='store_true',
help='Generate t-SNE visualizations for each patient'
)
preprocess_parser.add_argument(
'--pca',
action='store_true',
help='Generate PCA RGB 3D volumes for slice visualization (saved to data/preprocessed_tsne/)'
)
# Train command
train_parser = subparsers.add_parser(
'train',
help='Train the report generation model'
)
train_parser.add_argument(
'--config',
type=str,
help='Path to training configuration file'
)
train_parser.add_argument(
'--data-dir',
type=str,
default='data/preprocessed_tokens',
help='Directory with preprocessed tokens'
)
train_parser.add_argument(
'--output-dir',
type=str,
default='outputs/training',
help='Directory to save model checkpoints'
)
# Evaluate command
eval_parser = subparsers.add_parser(
'evaluate',
help='Evaluate the trained model'
)
eval_parser.add_argument(
'--checkpoint',
type=str,
required=True,
help='Path to model checkpoint'
)
eval_parser.add_argument(
'--data-dir',
type=str,
default='data/preprocessed_tokens',
help='Directory with preprocessed tokens'
)
eval_parser.add_argument(
'--output-dir',
type=str,
default='outputs/evaluation',
help='Directory to save evaluation results'
)
args = parser.parse_args()
if args.command is None:
parser.print_help()
sys.exit(1)
# Execute command
if args.command == 'preprocess':
preprocess_command(args)
elif args.command == 'train':
train_command(args)
elif args.command == 'evaluate':
evaluate_command(args)
else:
parser.print_help()
sys.exit(1)
if __name__ == '__main__':
main()