diff --git a/main.py b/main.py index b5a11b8..d1b7800 100644 --- a/main.py +++ b/main.py @@ -149,8 +149,8 @@ def detect_memory_modules(): 'success': False }), 400 - # Get confidence threshold from form data - conf_threshold = float(request.form.get('confidence', 0.5)) + # Get confidence threshold from form data (default 80%) + conf_threshold = float(request.form.get('confidence', 0.8)) # Save uploaded file temporarily filename = secure_filename(file.filename) @@ -219,8 +219,8 @@ def detect_hardcoded_image(): 'success': False }), 404 - # Get confidence threshold from query parameters - conf_threshold = float(request.args.get('confidence', 0.5)) + # Get confidence threshold from query parameters (default 80%) + conf_threshold = float(request.args.get('confidence', 0.8)) # Run detection detections, annotated_image = detector.detect( @@ -283,8 +283,8 @@ def detect_base64_image(): 'success': False }), 400 - # Get confidence threshold - conf_threshold = float(data.get('confidence', 0.5)) + # Get confidence threshold (default 80%) + conf_threshold = float(data.get('confidence', 0.8)) # Decode base64 image try: diff --git a/requirements.txt b/requirements.txt index f6f5a3b..d5fd903 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ Pillow==10.0.1 # Web Framework Flask==2.3.3 Flask-CORS==4.0.0 +Flask-RESTX==1.3.0 Werkzeug==2.3.7 # Data Processing diff --git a/static/script.js b/static/script.js index 72079c5..1b37ea8 100644 --- a/static/script.js +++ b/static/script.js @@ -17,18 +17,13 @@ function initializeApp() { function setupEventListeners() { // File input change document.getElementById('fileInput').addEventListener('change', handleFileSelect); - + // Drag and drop const uploadArea = document.getElementById('uploadArea'); uploadArea.addEventListener('dragover', handleDragOver); uploadArea.addEventListener('dragleave', handleDragLeave); uploadArea.addEventListener('drop', handleDrop); uploadArea.addEventListener('click', () => document.getElementById('fileInput').click()); - - // Confidence slider - document.getElementById('confidenceSlider').addEventListener('input', function() { - document.getElementById('confidenceValue').textContent = this.value; - }); } async function checkApiStatus() { @@ -143,23 +138,23 @@ async function processUploadedImage() { alert('Please select an image first'); return; } - - const confidence = document.getElementById('confidenceSlider').value; + + const confidence = 0.8; // Fixed 80% threshold showLoading('Processing uploaded image...'); - + try { const formData = new FormData(); formData.append('image', uploadedFile); formData.append('confidence', confidence); - + const response = await fetch(`${API_BASE_URL}/detect`, { method: 'POST', body: formData }); - + const result = await response.json(); hideLoading(); - + if (result.success) { displayResults(result, 'Uploaded Image Detection'); } else { @@ -173,12 +168,12 @@ async function processUploadedImage() { async function testHardcodedImage() { showLoading('Testing hardcoded image...'); - + try { - const response = await fetch(`${API_BASE_URL}/detect/hardcoded?confidence=0.5`); + const response = await fetch(`${API_BASE_URL}/detect/hardcoded?confidence=0.8`); const result = await response.json(); hideLoading(); - + if (result.success) { displayResults(result, 'Hardcoded Image Test'); } else { diff --git a/static/style.css b/static/style.css index 5afa944..d3186a7 100644 --- a/static/style.css +++ b/static/style.css @@ -186,22 +186,18 @@ header p { border-radius: 8px; } -.confidence-control { +.confidence-info { margin-bottom: 15px; + padding: 10px; + background: #e8f5e8; + border-radius: 6px; + border-left: 4px solid #28a745; } -.confidence-control label { - display: block; - margin-bottom: 8px; - font-weight: 500; -} - -.confidence-control input[type="range"] { - width: 100%; - height: 6px; - border-radius: 3px; - background: #ddd; - outline: none; +.confidence-info p { + margin: 0; + color: #155724; + font-size: 0.9rem; } .results-content { diff --git a/templates/index.html b/templates/index.html index 0ab888a..a00ddce 100644 --- a/templates/index.html +++ b/templates/index.html @@ -58,9 +58,8 @@