add config and create_pr for nanonets-ocr2.py
Browse files- nanonets-ocr2.py +25 -3
nanonets-ocr2.py
CHANGED
|
@@ -220,6 +220,8 @@ def main(
|
|
| 220 |
shuffle: bool = False,
|
| 221 |
seed: int = 42,
|
| 222 |
verbose: bool = False,
|
|
|
|
|
|
|
| 223 |
):
|
| 224 |
"""Process images from HF dataset through Nanonets-OCR2-3B model."""
|
| 225 |
|
|
@@ -346,8 +348,17 @@ def main(
|
|
| 346 |
|
| 347 |
# Push to hub
|
| 348 |
logger.info(f"Pushing to {output_dataset}")
|
| 349 |
-
dataset.push_to_hub(output_dataset, private=private, token=HF_TOKEN)
|
| 350 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
# Calculate processing time
|
| 352 |
end_time = datetime.now()
|
| 353 |
processing_duration = end_time - start_time
|
|
@@ -515,7 +526,16 @@ Examples:
|
|
| 515 |
action="store_true",
|
| 516 |
help="Log resolved package versions after processing (useful for pinning deps)",
|
| 517 |
)
|
| 518 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 519 |
args = parser.parse_args()
|
| 520 |
|
| 521 |
main(
|
|
@@ -534,4 +554,6 @@ Examples:
|
|
| 534 |
shuffle=args.shuffle,
|
| 535 |
seed=args.seed,
|
| 536 |
verbose=args.verbose,
|
|
|
|
|
|
|
| 537 |
)
|
|
|
|
| 220 |
shuffle: bool = False,
|
| 221 |
seed: int = 42,
|
| 222 |
verbose: bool = False,
|
| 223 |
+
config: str = None,
|
| 224 |
+
create_pr: bool = False,
|
| 225 |
):
|
| 226 |
"""Process images from HF dataset through Nanonets-OCR2-3B model."""
|
| 227 |
|
|
|
|
| 348 |
|
| 349 |
# Push to hub
|
| 350 |
logger.info(f"Pushing to {output_dataset}")
|
| 351 |
+
# dataset.push_to_hub(output_dataset, private=private, token=HF_TOKEN)
|
| 352 |
+
dataset.push_to_hub(
|
| 353 |
+
output_dataset,
|
| 354 |
+
private=private,
|
| 355 |
+
token=HF_TOKEN,
|
| 356 |
+
**({"config_name": config} if config else {}),
|
| 357 |
+
create_pr=create_pr,
|
| 358 |
+
commit_message=f"Add {model} OCR results ({len(dataset)} samples)"
|
| 359 |
+
+ (f" [{config}]" if config else ""),
|
| 360 |
+
)
|
| 361 |
+
|
| 362 |
# Calculate processing time
|
| 363 |
end_time = datetime.now()
|
| 364 |
processing_duration = end_time - start_time
|
|
|
|
| 526 |
action="store_true",
|
| 527 |
help="Log resolved package versions after processing (useful for pinning deps)",
|
| 528 |
)
|
| 529 |
+
parser.add_argument(
|
| 530 |
+
"--config",
|
| 531 |
+
help="Config/subset name when pushing to Hub (for benchmarking multiple models in one repo)",
|
| 532 |
+
)
|
| 533 |
+
parser.add_argument(
|
| 534 |
+
"--create-pr",
|
| 535 |
+
action="store_true",
|
| 536 |
+
help="Create a pull request instead of pushing directly (for parallel benchmarking)",
|
| 537 |
+
)
|
| 538 |
+
|
| 539 |
args = parser.parse_args()
|
| 540 |
|
| 541 |
main(
|
|
|
|
| 554 |
shuffle=args.shuffle,
|
| 555 |
seed=args.seed,
|
| 556 |
verbose=args.verbose,
|
| 557 |
+
config=args.config,
|
| 558 |
+
create_pr=args.create_pr,
|
| 559 |
)
|