diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-13 13:48:05 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-13 13:48:05 +0100 |
| commit | 2b3261eae270fd6ddc711680970b8707345f0656 (patch) | |
| tree | 6bfe4082868fd6e0355e8f878ce6f3a3b83b3ea6 /scripts | |
| parent | 493bb2125d1f51c0d56b0f87638a3ec23b8afd3d (diff) | |
Add --export-only option to train_cnn_v2_full.sh
Allows exporting weights from a checkpoint without training or validation.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/train_cnn_v2_full.sh | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/scripts/train_cnn_v2_full.sh b/scripts/train_cnn_v2_full.sh index 5a4e55e..99c104a 100755 --- a/scripts/train_cnn_v2_full.sh +++ b/scripts/train_cnn_v2_full.sh @@ -7,12 +7,14 @@ # (none) Run complete pipeline: train → export → build → validate # --validate Validate only (skip training, use existing weights) # --validate CHECKPOINT Validate with specific checkpoint file +# --export-only CHECKPOINT Export weights only (skip training, build, validation) # --help Show this help message # # Examples: # ./train_cnn_v2_full.sh # ./train_cnn_v2_full.sh --validate # ./train_cnn_v2_full.sh --validate checkpoints/checkpoint_epoch_50.pth +# ./train_cnn_v2_full.sh --export-only checkpoints/checkpoint_epoch_100.pth set -e @@ -22,13 +24,22 @@ cd "$PROJECT_ROOT" # Parse arguments VALIDATE_ONLY=false VALIDATE_CHECKPOINT="" +EXPORT_ONLY=false +EXPORT_CHECKPOINT="" if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then head -20 "$0" | grep "^#" | grep -v "^#!/" | sed 's/^# *//' exit 0 fi -if [ "$1" = "--validate" ]; then +if [ "$1" = "--export-only" ]; then + EXPORT_ONLY=true + if [ -z "$2" ]; then + echo "Error: --export-only requires a checkpoint file argument" + exit 1 + fi + EXPORT_CHECKPOINT="$2" +elif [ "$1" = "--validate" ]; then VALIDATE_ONLY=true if [ -n "$2" ]; then VALIDATE_CHECKPOINT="$2" @@ -56,6 +67,31 @@ DETECTOR="harris" KERNEL_SIZES="3,3,3" # Comma-separated per-layer kernel sizes NUM_LAYERS=3 +# Handle export-only mode +if [ "$EXPORT_ONLY" = true ]; then + echo "=== CNN v2 Export Weights Only ===" + echo "Checkpoint: $EXPORT_CHECKPOINT" + echo "" + + if [ ! -f "$EXPORT_CHECKPOINT" ]; then + echo "Error: Checkpoint file not found: $EXPORT_CHECKPOINT" + exit 1 + fi + + python3 training/export_cnn_v2_weights.py "$EXPORT_CHECKPOINT" \ + --output-weights workspaces/main/weights/cnn_v2_weights.bin + + if [ $? -ne 0 ]; then + echo "Error: Export failed" + exit 1 + fi + + echo "" + echo "=== Export Complete ===" + echo "Output: workspaces/main/weights/cnn_v2_weights.bin" + exit 0 +fi + if [ "$VALIDATE_ONLY" = true ]; then echo "=== CNN v2 Validation Only ===" echo "Skipping training, using existing weights" |
