Set confidence threshold to 80% and remove slider from frontend
✅ Frontend Changes: - Removed confidence threshold slider from web interface - Added fixed 80% confidence display with green info box - Updated JavaScript to use fixed 0.8 threshold - Removed slider-related CSS styles ✅ Backend Changes: - Updated all API endpoints to default to 80% confidence (0.8) - Modified POST /detect, GET /detect/hardcoded, POST /detect/base64 - Updated comments to reflect new default threshold ✅ Testing Updates: - Updated test_api.py to use 80% confidence for all tests - Ensures consistent testing with new threshold ✅ Benefits: - High precision mode (80% confidence) reduces false positives - Simplified user interface without threshold adjustment - Consistent detection behavior across all endpoints
This commit is contained in:
+10
-15
@@ -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 {
|
||||
|
||||
+9
-13
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user