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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342 | @app.command(
help=(
"Run the Modosaic pipeline with configurable dataset, modalities, "
"models, validators, and quality-gate constraints."
),
short_help="Run with CLI configuration.",
)
def run(
dataset: Annotated[
DatasetKind,
Option("--dataset", help="Dataset adapter to use."),
] = DatasetKind.LOCAL,
root: Annotated[
Path | None,
Option(
"--root",
exists=True,
file_okay=False,
help="Local image folder. Required when --dataset local.",
),
] = None,
parquet_path: Annotated[
Path | None,
Option(
"--parquet-path",
exists=True,
help="Parquet file or directory. Required when --dataset parquet.",
),
] = None,
recursive: Annotated[
bool,
Option(
"--recursive/--top-level",
help="Scan local folders recursively or only at the top level.",
),
] = True,
extensions: Annotated[
list[str] | None,
Option(
"--extension",
"-e",
help="Local image extension to include. Repeat to include many.",
),
] = None,
image_column: Annotated[
str,
Option("--image-column", help="Parquet column containing image bytes or paths."),
] = "image",
id_column: Annotated[
str | None,
Option("--id-column", help="Optional Parquet sample-id column."),
] = None,
extension_column: Annotated[
str | None,
Option("--extension-column", help="Optional Parquet image-extension column."),
] = None,
metadata_columns: Annotated[
list[str] | None,
Option(
"--metadata-column",
help="Parquet metadata column to keep. Repeat to include many.",
),
] = None,
batch_size: Annotated[
int,
Option("--batch-size", help="Parquet read batch size."),
] = 512,
modalities: Annotated[
list[ModalityName] | None,
Option(
"--modality",
"-m",
help=(
"Modality to generate. Repeat to select many; omitted means all "
"modalities in dependency-safe order."
),
),
] = None,
text_model: Annotated[
TextModelName,
Option("--text-model", help="Captioning model for the text modality."),
] = TextModelName.QWEN_2_2B,
segmentation_model: Annotated[
SegmentationModelName,
Option("--segmentation-model", help="Mask generator for segmentation."),
] = SegmentationModelName.SAM3,
depth_model: Annotated[
DepthModelName,
Option("--depth-model", help="Depth generator for depth maps."),
] = DepthModelName.DEPTH_ANYTHING_V2_SMALL,
normals_model: Annotated[
NormalsModelName,
Option("--normals-model", help="Normal-field generator for normals."),
] = NormalsModelName.OMNIDATA,
validators: Annotated[
bool,
Option("--validators/--no-validators", help="Run modality validators."),
] = True,
constraints: Annotated[
bool,
Option(
"--constraints/--no-constraints",
help="Use validator constraints as quality gates.",
),
] = True,
text_siglip_minimum: Annotated[
float,
Option("--text-siglip-min", help="Minimum SIGLIP text-image score."),
] = 0.60,
segmentation_mask_quality_minimum: Annotated[
float,
Option("--segmentation-mask-quality-min", help="Minimum weighted mask quality."),
] = 0.75,
segmentation_boundary_minimum: Annotated[
float,
Option("--segmentation-boundary-min", help="Minimum RGB boundary F1."),
] = 0.20,
depth_imagebind_minimum: Annotated[
float,
Option("--depth-imagebind-min", help="Minimum ImageBind depth-image score."),
] = 0.55,
depth_segmentation_boundary_minimum: Annotated[
float,
Option(
"--depth-segmentation-boundary-min",
help="Minimum depth-vs-segmentation boundary F1.",
),
] = 0.20,
normals_depth_agreement_minimum: Annotated[
float,
Option(
"--normals-depth-agreement-min",
help="Minimum depth/normal angular agreement score.",
),
] = 0.35,
normals_field_quality_minimum: Annotated[
float,
Option("--normals-field-quality-min", help="Minimum normal-field quality score."),
] = 0.50,
segmentation_boundary_thickness: Annotated[
int,
Option("--segmentation-boundary-thickness", help="Mask boundary thickness in pixels."),
] = 1,
segmentation_tolerance_radius: Annotated[
int,
Option("--segmentation-tolerance-radius", help="RGB edge matching tolerance in pixels."),
] = 2,
segmentation_rgb_edge_quantile: Annotated[
float,
Option("--segmentation-rgb-edge-quantile", help="RGB edge quantile for boundary checks."),
] = 0.90,
depth_boundary_thickness: Annotated[
int,
Option("--depth-boundary-thickness", help="Segmentation boundary thickness for depth checks."),
] = 1,
depth_tolerance_radius: Annotated[
int,
Option("--depth-tolerance-radius", help="Depth edge matching tolerance in pixels."),
] = 2,
depth_edge_quantile: Annotated[
float,
Option("--depth-edge-quantile", help="Depth edge quantile for boundary checks."),
] = 0.90,
normals_eps: Annotated[
float,
Option("--normals-eps", help="Epsilon for normal-vector normalization."),
] = 1e-6,
normals_nz_min: Annotated[
float,
Option("--normals-nz-min", help="Minimum |nz| used by normals integrability scoring."),
] = 0.1,
limit: Annotated[
int | None,
Option("--limit", "-n", help="Maximum number of samples to process."),
] = None,
experiment_root: Annotated[
Path,
Option(
"--experiment-root",
file_okay=False,
help="Directory where experiment artifacts will be written.",
),
] = Path("experiments"),
experiment_name: Annotated[
str | None,
Option("--experiment-name", help="Optional experiment folder name."),
] = None,
log_path: Annotated[
Path | None,
Option("--log-path", file_okay=False, help="Directory where logs will be stored."),
] = DEFAULT_LOG_PATH,
seed: Annotated[
int,
Option("--seed", help="Global seed for reproducible model execution."),
] = 42,
json_summary: Annotated[
bool,
Option("--json", help="Print the run summary as JSON."),
] = False,
) -> None:
"""Run a configurable pipeline from CLI options."""
config = RunConfig(
dataset=DatasetConfig(
kind=dataset,
root=root,
parquet_path=parquet_path,
recursive=recursive,
extensions=tuple(extensions or ()),
image_column=image_column,
id_column=id_column,
extension_column=extension_column,
metadata_columns=tuple(metadata_columns or ()),
batch_size=batch_size,
),
modalities=normalize_modalities(modalities),
models=ModelConfig(
text=text_model,
segmentation=segmentation_model,
depth=depth_model,
normals=normals_model,
),
validators=ValidatorConfig(
enabled=validators,
constraints=ConstraintConfig(
enabled=constraints,
text_siglip_minimum=text_siglip_minimum,
segmentation_mask_quality_minimum=segmentation_mask_quality_minimum,
segmentation_boundary_minimum=segmentation_boundary_minimum,
depth_imagebind_minimum=depth_imagebind_minimum,
depth_segmentation_boundary_minimum=depth_segmentation_boundary_minimum,
normals_depth_agreement_minimum=normals_depth_agreement_minimum,
normals_field_quality_minimum=normals_field_quality_minimum,
),
segmentation_boundary_thickness=segmentation_boundary_thickness,
segmentation_tolerance_radius=segmentation_tolerance_radius,
segmentation_rgb_edge_quantile=segmentation_rgb_edge_quantile,
depth_boundary_thickness=depth_boundary_thickness,
depth_tolerance_radius=depth_tolerance_radius,
depth_edge_quantile=depth_edge_quantile,
normals_eps=normals_eps,
normals_nz_min=normals_nz_min,
),
limit=limit,
experiment_root=experiment_root,
experiment_name=experiment_name,
log_path=log_path,
seed=seed,
json_summary=json_summary,
)
_run_or_exit(config)
|