A Streamlit-based web application for automated detection and quantification of nitrite concentration in water samples using computer vision and AI-powered color analysis.
- AI-Powered Analysis: Uses YOLOv8 for object detection (test strips, tubes, color charts).
- Color Extraction: K-means clustering for dominant color detection in test regions.
- Color Matching: LAB color space comparison to reference color chart for accurate nitrite estimation.
- Confidence Scoring: Each result includes a reliability/confidence score.
- Multi-format Support: Accepts JPG, JPEG, PNG, BMP, TIFF images.
- History Tracking: Stores all test results and images in a local SQLite database.
- Interactive Visualization: Shows detections, color analysis, and recommendations.
- Unit Selection: Supports mg/L and ppm units.
- Downloadable Results: Download analyzed images and review previous tests.
- Upload an Image: Provide a photo of your nitrite test strip or water sample.
- Object Detection: The app locates relevant regions (test tube, strip, color chart) using YOLO.
- Color Analysis: Extracts the dominant color from the detected region.
- Color Matching: Compares the detected color to a reference chart using LAB color space.
- Result Output: Displays estimated nitrite concentration, confidence, and health recommendations.
- History: All results and images are saved for future review.
-
Clone the repository:
git clone https://github.com/Dnadithya/nitrate_detection.git cd nitrate_detection -
Install dependencies:
pip install -r requirements.txt
-
Download YOLOv8 weights:
- Place your YOLOv8 weights file (e.g.,
best.pt) in theweights/directory. - If not present, the default YOLOv8n weights will be used.
- Place your YOLOv8 weights file (e.g.,
-
Run the Streamlit app:
streamlit run app.py
-
Open your browser:
Visit http://localhost:8501 to access the app. -
Upload and Analyze:
- Go to "Upload & Test"
- Upload your image and select options
- View results, color analysis, and recommendations
-
Review History:
- Go to "History" to see previous tests and download images
| Nitrite (mg/L) | Interpretation | Recommendation |
|---|---|---|
| 0.0 | Safe | No action needed |
| 0.5 - 1.0 | Low | Monitor regularly |
| 1.0 - 2.0 | Moderate | Take action to reduce levels |
| >2.0 | High | Immediate attention required |
- Framework: Streamlit
- AI Model: YOLOv8 (Ultralytics)
- Color Analysis: LAB color space, K-means clustering
- Database: SQLite (local file:
nitrite.db) - Image Processing: OpenCV, PIL, scikit-learn
