diff --git a/main.py b/main.py index 2cadd6e..b878140 100644 --- a/main.py +++ b/main.py @@ -71,8 +71,7 @@ def home(): '/': 'GET - Frontend interface or API information', '/api': 'GET - API information (JSON)', '/detect': 'POST - Upload image for memory module detection', - '/detect/hardcoded': 'GET - Process hardcoded test image (with memory)', - '/detect/no-memory': 'GET - Process test image without memory modules', + '/detect/hardcoded': 'GET - Process hardcoded test image', '/detect/base64': 'POST - Process base64 encoded image', '/health': 'GET - Health check' }, @@ -90,8 +89,7 @@ def api_info(): '/': 'GET - Frontend interface or API information', '/api': 'GET - API information (JSON)', '/detect': 'POST - Upload image for memory module detection', - '/detect/hardcoded': 'GET - Process hardcoded test image (with memory)', - '/detect/no-memory': 'GET - Process test image without memory modules', + '/detect/hardcoded': 'GET - Process hardcoded test image', '/detect/base64': 'POST - Process base64 encoded image', '/health': 'GET - Health check' }, @@ -256,67 +254,7 @@ def detect_hardcoded_image(): 'success': False }), 500 -@app.route('/detect/no-memory', methods=['GET']) -def detect_no_memory_image(): - """ - Process hardcoded test image without memory modules for testing. - Optional query parameters: - - confidence: confidence threshold (default: 0.8) - - Returns: - - JSON with detections (should be 0) and annotated image (base64) - """ - try: - # Check if model is loaded - if detector.model is None: - return jsonify({ - 'error': 'Model not loaded. Please train the model first.', - 'success': False - }), 500 - - # Use no-memory test image - no_memory_image_path = 'training/no_memory/out21.png' - - # Check if no-memory image exists - if not os.path.exists(no_memory_image_path): - return jsonify({ - 'error': f'No-memory test image not found at {no_memory_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( - no_memory_image_path, - conf_threshold=conf_threshold - ) - - # Convert annotated image to base64 - annotated_base64 = image_to_base64(annotated_image) - - # Prepare response - response_data = { - 'success': True, - 'detections': detections, - 'num_detections': len(detections), - 'annotated_image': annotated_base64, - 'confidence_threshold': conf_threshold, - 'test_image_path': no_memory_image_path - } - - logger.info(f"Processed no-memory image: found {len(detections)} memory modules") - - return jsonify(response_data) - - except Exception as e: - logger.error(f"Error processing no-memory image: {str(e)}") - return jsonify({ - 'error': f'Error processing no-memory image: {str(e)}', - 'success': False - }), 500 @app.route('/detect/base64', methods=['POST']) def detect_base64_image(): diff --git a/static/script.js b/static/script.js index ea856d4..c104f95 100644 --- a/static/script.js +++ b/static/script.js @@ -396,9 +396,11 @@ async function runAllTests() { const result = await response.json(); testResults.push({ name: 'Image with Memory Modules', - success: result.success && result.num_detections > 0, + success: result.success, message: result.success ? - `✅ Found ${result.num_detections} memory modules` : + (result.num_detections > 0 ? + `✅ Found ${result.num_detections} memory modules` : + `❌ No memory modules`) : `❌ Error: ${result.error}` }); } catch (error) { @@ -409,26 +411,7 @@ async function runAllTests() { }); } - // Test 3: Image without Memory Modules - try { - const response = await fetch(`${API_BASE_URL}/detect/no-memory`); - const result = await response.json(); - testResults.push({ - name: 'Image without Memory Modules', - success: result.success && result.num_detections === 0, - message: result.success ? - `✅ Correctly detected ${result.num_detections} memory modules` : - `❌ Error: ${result.error}` - }); - } catch (error) { - testResults.push({ - name: 'Image without Memory Modules', - success: false, - message: `❌ Error: ${error.message}` - }); - } - - // Test 4: API Information + // Test 3: API Information try { const response = await fetch(`${API_BASE_URL}/api`); const result = await response.json();