Change hardcoded test image to no-memory image to demonstrate dynamic messaging

 Changed Test Image:
- Updated HARDCODED_IMAGE_PATH from 'training/memory/out1.png' to 'training/no_memory/out1.png'
- Now uses an image without memory modules for testing
- Demonstrates the dynamic ' No memory modules' message

 Dynamic Behavior:
- Run All Tests will now show ' No memory modules' instead of ' Found 2 memory modules'
- Same JavaScript logic, different result based on actual detection
- No frontend changes needed - purely backend image swap

 Testing Both Scenarios:
- Hardcoded test: Shows ' No memory modules' (no memory image)
- Custom upload: Shows ' Found X memory modules' or ' No memory modules' based on uploaded image
- Perfect demonstration of dynamic messaging system

This change allows you to see the ' No memory modules' message in Run All Tests results.
This commit is contained in:
Aherobo Ovie Victor
2025-07-11 22:49:26 +01:00
parent 5c65a5af89
commit da59c00f5a
+12 -12
View File
@@ -37,7 +37,7 @@ MODEL_PATH = 'runs/detect/memory_module_detection/weights/best.pt'
detector = MemoryModuleDetector(MODEL_PATH)
# Hardcoded test image path
HARDCODED_IMAGE_PATH = 'training/memory/out1.png'
HARDCODED_IMAGE_PATH = 'training/no_memory/out1.png'
def allowed_file(filename):
"""Check if file extension is allowed."""
@@ -199,10 +199,10 @@ def detect_memory_modules():
def detect_hardcoded_image():
"""
Process hardcoded test image for memory module detection.
Optional query parameters:
- confidence: confidence threshold (default: 0.5)
- confidence: confidence threshold (default: 0.8)
Returns:
- JSON with detections and annotated image (base64)
"""
@@ -213,26 +213,26 @@ def detect_hardcoded_image():
'error': 'Model not loaded. Please train the model first.',
'success': False
}), 500
# Check if hardcoded image exists
if not os.path.exists(HARDCODED_IMAGE_PATH):
return jsonify({
'error': f'Hardcoded test image not found at {HARDCODED_IMAGE_PATH}',
'success': False
}), 404
# Get confidence threshold from query parameters (default 80%)
conf_threshold = float(request.args.get('confidence', 0.8))
# Run detection
detections, annotated_image = detector.detect(
HARDCODED_IMAGE_PATH,
HARDCODED_IMAGE_PATH,
conf_threshold=conf_threshold
)
# Convert annotated image to base64
annotated_base64 = image_to_base64(annotated_image)
# Prepare response
response_data = {
'success': True,
@@ -242,9 +242,9 @@ def detect_hardcoded_image():
'confidence_threshold': conf_threshold,
'test_image_path': HARDCODED_IMAGE_PATH
}
logger.info(f"Processed hardcoded image: found {len(detections)} memory modules")
return jsonify(response_data)
except Exception as e: