Add --config/--create-pr support to lighton-ocr2.py
Browse files- lighton-ocr2.py +22 -1
lighton-ocr2.py
CHANGED
|
@@ -289,6 +289,8 @@ def main(
|
|
| 289 |
shuffle: bool = False,
|
| 290 |
seed: int = 42,
|
| 291 |
output_column: str = "markdown",
|
|
|
|
|
|
|
| 292 |
):
|
| 293 |
"""Process images from HF dataset through LightOnOCR-2 model."""
|
| 294 |
|
|
@@ -422,7 +424,15 @@ def main(
|
|
| 422 |
|
| 423 |
# Push to hub
|
| 424 |
logger.info(f"Pushing to {output_dataset}")
|
| 425 |
-
dataset.push_to_hub(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
|
| 427 |
# Create and push dataset card
|
| 428 |
logger.info("Creating dataset card")
|
|
@@ -579,6 +589,15 @@ Examples:
|
|
| 579 |
parser.add_argument(
|
| 580 |
"--private", action="store_true", help="Make output dataset private"
|
| 581 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 582 |
parser.add_argument(
|
| 583 |
"--shuffle", action="store_true", help="Shuffle dataset before processing"
|
| 584 |
)
|
|
@@ -615,4 +634,6 @@ Examples:
|
|
| 615 |
shuffle=args.shuffle,
|
| 616 |
seed=args.seed,
|
| 617 |
output_column=args.output_column,
|
|
|
|
|
|
|
| 618 |
)
|
|
|
|
| 289 |
shuffle: bool = False,
|
| 290 |
seed: int = 42,
|
| 291 |
output_column: str = "markdown",
|
| 292 |
+
config: str = None,
|
| 293 |
+
create_pr: bool = False,
|
| 294 |
):
|
| 295 |
"""Process images from HF dataset through LightOnOCR-2 model."""
|
| 296 |
|
|
|
|
| 424 |
|
| 425 |
# Push to hub
|
| 426 |
logger.info(f"Pushing to {output_dataset}")
|
| 427 |
+
dataset.push_to_hub(
|
| 428 |
+
output_dataset,
|
| 429 |
+
private=private,
|
| 430 |
+
token=HF_TOKEN,
|
| 431 |
+
config_name=config,
|
| 432 |
+
create_pr=create_pr,
|
| 433 |
+
commit_message=f"Add {MODEL} OCR results ({len(dataset)} samples)"
|
| 434 |
+
+ (f" [{config}]" if config else ""),
|
| 435 |
+
)
|
| 436 |
|
| 437 |
# Create and push dataset card
|
| 438 |
logger.info("Creating dataset card")
|
|
|
|
| 589 |
parser.add_argument(
|
| 590 |
"--private", action="store_true", help="Make output dataset private"
|
| 591 |
)
|
| 592 |
+
parser.add_argument(
|
| 593 |
+
"--config",
|
| 594 |
+
help="Config/subset name when pushing to Hub (for benchmarking multiple models in one repo)",
|
| 595 |
+
)
|
| 596 |
+
parser.add_argument(
|
| 597 |
+
"--create-pr",
|
| 598 |
+
action="store_true",
|
| 599 |
+
help="Create a pull request instead of pushing directly (for parallel benchmarking)",
|
| 600 |
+
)
|
| 601 |
parser.add_argument(
|
| 602 |
"--shuffle", action="store_true", help="Shuffle dataset before processing"
|
| 603 |
)
|
|
|
|
| 634 |
shuffle=args.shuffle,
|
| 635 |
seed=args.seed,
|
| 636 |
output_column=args.output_column,
|
| 637 |
+
config=args.config,
|
| 638 |
+
create_pr=args.create_pr,
|
| 639 |
)
|