| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #!/bin/bash
- # Test script for subfolder model scanning
- # This script creates a test directory structure and verifies that subfolder models are detected
- set -e
- TEST_BASE="/tmp/sd_test_models"
- TEST_CHECKPOINTS="$TEST_BASE/checkpoints"
- echo "Setting up test environment..."
- # Clean up previous test
- rm -rf "$TEST_BASE"
- # Create test directory structure
- mkdir -p "$TEST_CHECKPOINTS/subfolder1"
- mkdir -p "$TEST_CHECKPOINTS/subfolder2/deep"
- mkdir -p "$TEST_CHECKPOINTS/subfolder2/nested"
- # Create dummy model files
- touch "$TEST_CHECKPOINTS/model1.safetensors"
- touch "$TEST_CHECKPOINTS/subfolder1/model2.safetensors"
- touch "$TEST_CHECKPOINTS/subfolder2/model3.safetensors"
- touch "$TEST_CHECKPOINTS/subfolder2/deep/model4.safetensors"
- touch "$TEST_CHECKPOINTS/subfolder2/nested/model5.safetensors"
- # Create other model types
- mkdir -p "$TEST_BASE/loras"
- touch "$TEST_BASE/loras/lora1.safetensors"
- mkdir -p "$TEST_BASE/loras/subfolder"
- touch "$TEST_BASE/loras/subfolder/lora2.safetensors"
- echo "Test directory structure created:"
- echo "- $TEST_CHECKPOINTS/model1.safetensors"
- echo "- $TEST_CHECKPOINTS/subfolder1/model2.safetensors"
- echo "- $TEST_CHECKPOINTS/subfolder2/model3.safetensors"
- echo "- $TEST_CHECKPOINTS/subfolder2/deep/model4.safetensors"
- echo "- $TEST_CHECKPOINTS/subfolder2/nested/model5.safetensors"
- echo "- $TEST_BASE/loras/lora1.safetensors"
- echo "- $TEST_BASE/loras/subfolder/lora2.safetensors"
- echo ""
- echo "Running model scanning test..."
- # Run the server with test directory
- cd /data/stable-diffusion.cpp-rest/build
- timeout 10s ./stable-diffusion-rest-server \
- --models-dir "$TEST_BASE" \
- --checkpoints "$TEST_CHECKPOINTS" \
- --lora-dir "$TEST_BASE/loras" \
- --host 127.0.0.1 \
- --port 0 \
- --verbose || true
- echo ""
- echo "Test completed. Check the output above to verify that subfolder models were detected."
- echo ""
- echo "Expected models to be found:"
- echo "- model1.safetensors"
- echo "- subfolder1/model2.safetensors"
- echo "- subfolder2/model3.safetensors"
- echo "- subfolder2/deep/model4.safetensors"
- echo "- subfolder2/nested/model5.safetensors"
- echo "- loras/lora1.safetensors"
- echo "- loras/subfolder/lora2.safetensors"
- # Cleanup
- rm -rf "$TEST_BASE"
|