Download scripts/finalize_training.py from Amitkumar001/Logo_watermark_detection: direct link, hf CLI and curl.
- Browser
- Download file 661 Bytes
-
https://huggingface.co/Amitkumar001/Logo_watermark_detection/resolve/main/scripts/finalize_training.py
- Command line
-
hf download hf://Amitkumar001/Logo_watermark_detection/scripts/finalize_training.py
-
curl -L -o finalize_training.py https://huggingface.co/Amitkumar001/Logo_watermark_detection/resolve/main/scripts/finalize_training.py
661 Bytes
| import shutil | |
| import os | |
| from pathlib import Path | |
| def finalize(): | |
| # Find the latest run | |
| runs_dir = Path("runs/detect/runs") | |
| if not runs_dir.exists(): | |
| print("No runs found.") | |
| return | |
| latest_run = sorted(list(runs_dir.glob("logo_watermark*")), key=os.path.getmtime)[-1] | |
| best_pt = latest_run / "weights" / "best.pt" | |
| if best_pt.exists(): | |
| dst = Path("models/best.pt") | |
| dst.parent.mkdir(parents=True, exist_ok=True) | |
| shutil.copy(best_pt, dst) | |
| print(f"Successfully copied {best_pt} to {dst}") | |
| else: | |
| print(f"Could not find {best_pt}") | |
| if __name__ == "__main__": | |
| finalize() | |