143 lines
3.6 KiB
Markdown
143 lines
3.6 KiB
Markdown
# Memory Module Detection System
|
|
|
|
A computer vision system for detecting memory modules in images and videos using YOLO object detection.
|
|
|
|
## Features
|
|
|
|
- **Image Detection**: Upload images to detect memory modules
|
|
- **Video Processing**: Process video files frame-by-frame
|
|
- **Bounding Box Visualization**: See detected objects with confidence scores
|
|
- **Detailed Analytics**: Get detection statistics and metrics
|
|
- **REST API**: Fully documented API endpoints
|
|
- **Web Interface**: User-friendly browser interface
|
|
|
|
## Requirements
|
|
|
|
- Python 3.8+
|
|
- CUDA-enabled GPU (recommended for best performance)
|
|
- Docker (optional)
|
|
|
|
## Installation
|
|
|
|
### 1. Clone the repository
|
|
```bash
|
|
git clone https://github.com/yourusername/memory-detection.git
|
|
cd memory-detection
|
|
```
|
|
|
|
### 2. Set up Python environment
|
|
```bash
|
|
python -m venv venv
|
|
source venv/bin/activate # Linux/MacOS
|
|
venv\Scripts\activate # Windows
|
|
```
|
|
|
|
### 3. Install dependencies
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
### 4. Download YOLO model
|
|
Place your `.pt` model file in the `models/` directory and update `config.py` with the correct path.
|
|
|
|
## Configuration
|
|
|
|
Edit `config.py` to customize:
|
|
|
|
- Model paths
|
|
- Confidence thresholds
|
|
- File size limits
|
|
- Server host/port settings
|
|
|
|
## Running the Application
|
|
|
|
### Development Mode
|
|
```bash
|
|
python backend/app.py
|
|
```
|
|
|
|
### Production Mode (with Gunicorn)
|
|
```bash
|
|
gunicorn --bind 0.0.0.0:5000 backend.app:app
|
|
```
|
|
|
|
### Docker
|
|
```bash
|
|
docker build -t memory-detection .
|
|
docker run -p 5000:5000 memory-detection
|
|
```
|
|
|
|
## API Documentation
|
|
|
|
### Endpoints
|
|
|
|
| Endpoint | Method | Description |
|
|
|----------|--------|-------------|
|
|
| `/` | GET | Web interface |
|
|
| `/api/health` | GET | Service health check |
|
|
| `/api/v1/detect` | POST | Detect memory modules in image |
|
|
| `/api/v1/detect/video` | POST | Process video for detections |
|
|
| `/api/v1/results/<filename>` | GET | Retrieve result images |
|
|
|
|
### Example Requests
|
|
|
|
**Image Detection**:
|
|
```bash
|
|
curl -X POST -F "image=@test.jpg" http://localhost:5000/api/v1/detect
|
|
```
|
|
|
|
**Video Processing**:
|
|
```bash
|
|
curl -X POST -F "video=@test.mp4" -F "fps=2" -F "max_frames=100" http://localhost:5000/api/v1/detect/video
|
|
```
|
|
|
|
## Web Interface
|
|
|
|
Access the web interface at `http://localhost:5000`:
|
|
|
|
1. **Upload Images**:
|
|
- Supported formats: JPG, PNG
|
|
- Max file size: 10MB (configurable)
|
|
|
|
2. **Process Videos**:
|
|
- Supported formats: MP4, AVI, MOV
|
|
- Adjustable FPS and frame limits
|
|
- Detailed frame-by-frame results
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
memory-detection/
|
|
├── backend/ # Core application
|
|
│ ├── app.py # Flask application
|
|
│ ├── config.py # Configuration
|
|
│ ├── detector.py # YOLO detection logic
|
|
│ ├── exceptions.py # Custom exceptions
|
|
│ ├── utils.py # Helper functions
|
|
│ ├── video_processor.py # Video handling
|
|
│ └── templates/ # Frontend templates
|
|
│ └── index.html # Web interface
|
|
├── models/ # YOLO model files
|
|
├── uploads/ # Temporary upload storage
|
|
├── results/ # Detection result images
|
|
├── tests/ # Unit tests
|
|
├── requirements.txt # Python dependencies
|
|
└── README.md
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
**Common Issues**:
|
|
|
|
1. **Model not loading**:
|
|
- Verify model path in `config.py`
|
|
- Check file permissions
|
|
|
|
2. **CUDA errors**:
|
|
- Ensure compatible CUDA version is installed
|
|
- Try CPU-only mode by modifying detector.py
|
|
|
|
3. **File upload issues**:
|
|
- Check `MAX_FILE_SIZE` in config
|
|
- Verify file extensions are allowed
|