rklb_materials_deploy / test_local.sh
gphua1's picture
Deploy complete RKLB defect detection system with models and examples
5fb17cc
#!/bin/bash
# Quick Local Testing Script
echo "πŸ” Defect Detection - Local Testing"
echo "===================================="
# Check if model exists
if [ -f "models/best_model_bf16.pth" ]; then
echo "βœ… Found best_model_bf16.pth (BF16 optimized)"
elif [ -f "models/best_model.pth" ]; then
echo "βœ… Found best_model.pth"
elif [ -f "models/toy_model.pth" ]; then
echo "⚠️ Using toy_model.pth (train full model for better results)"
else
echo "❌ No model found! Train first with: python3 train.py"
exit 1
fi
echo ""
echo "Choose testing method:"
echo "1) Web UI (Streamlit) - Best for visual testing"
echo "2) API Server - Best for integration testing"
echo "3) CLI Test - Quick command line test"
echo "4) Test on sample images"
read -p "Enter choice [1-4]: " choice
case $choice in
1)
echo "🌐 Starting Web UI..."
echo " Open browser to http://localhost:8501"
python3 app.py --mode web
;;
2)
echo "πŸ”Œ Starting API Server..."
echo " API docs: http://localhost:8000/docs"
echo " Web UI: http://localhost:8000/interface"
python3 app.py --mode api
;;
3)
echo "πŸ’» CLI Test Mode"
read -p "Enter image path: " img_path
python3 app.py --mode cli --image "$img_path"
;;
4)
echo "πŸ“Έ Testing on sample images..."
if [ -d "data/defect_dataset/test" ]; then
# Test on first few images
for img in data/defect_dataset/test/normal/*.PNG data/defect_dataset/test/defective/*.PNG; do
[ -f "$img" ] || continue
echo "Testing: $img"
python3 app.py --mode cli --image "$img"
# Only test first 2 of each type
count=$((count + 1))
[ $count -ge 4 ] && break
done
else
echo "No test data found. Using CLI mode instead."
python3 app.py --mode cli --help
fi
;;
*)
echo "Invalid choice"
exit 1
;;
esac