An intelligent object detection platform based on Flask and YOLOv8, providing a clean and beautiful user interface with powerful AI recognition capabilities.
- π― Smart Detection: High-precision object detection based on YOLOv8 model
- π Web Interface: Modern responsive user interface
- π Multi-language: Automatic language detection (Chinese/English)
- π Drag & Drop: Support drag-and-drop files and click upload
- π Results Display: Real-time display of detection results and confidence statistics
- πΌοΈ Visualization: Comparative display of original and annotated result images
- π Image Zoom: Click to enlarge images for detailed viewing
- π± Mobile Friendly: Support for mobile and tablet device access
YOLO Inspector main interface showcasing modern design and intuitive operation workflow
- Left Operation Panel: Model selection, image upload, language switching
- Right Results Display: Side-by-side comparison of original and detection results
- Smart Statistics Cards: Detected objects count, max confidence, average confidence
- Detailed Detection List: Shows all detected object categories and confidence scores
- Image Zoom Function: Click images to view full-screen high-resolution details
- Responsive Design: Optimized for both desktop and mobile devices
- Python 3.8+
- 8GB+ RAM recommended
- GPU support (optional but recommended)
cd radar-vision-identify-ai/vision-detect-check# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activatepip install -r requirements.txtEnsure the model/best.pt file exists and is accessible. This is the trained YOLOv8 model file.
Fastest solution:
python quick_fix.pyComplete fix script:
python fix_torch_compatibility.pyMethod 1: Use smart startup script (recommended)
python run.pyMethod 2: Direct startup
python app.pyOpen browser and visit: http://localhost:5800
- Method 1: Click "Select Image" button to choose file
- Method 2: Directly drag image files to upload area
- System automatically processes uploaded images
- Displays comparison between original and detection result images
- Shows statistics like number of detected objects, confidence levels
- Lists all detected object categories and confidence scores
- System automatically detects browser language
- Manual switching via language buttons in top-right corner
- Direct access:
/enfor English,/zhfor Chinese
- Image formats: JPG, PNG, GIF, BMP, TIFF
- File size: Maximum 16MB
POST /upload
Content-Type: multipart/form-data
Parameters:
- file: Image file
Response:
{
"success": true,
"filename": "uploaded_filename",
"detections": [
{
"bbox": [x1, y1, x2, y2],
"confidence": 0.95,
"class_id": 0,
"class_name": "person"
}
],
"num_detections": 1,
"original_image": "/uploads/filename.jpg",
"result_image": "/results/result_filename.jpg"
}
GET /model_info
Response:
{
"model_loaded": true,
"model_path": "model/best.pt",
"classes": {
"0": "person",
"1": "car",
...
},
"model_type": "YOLO"
}
GET / # Auto-detect language
GET /en # Force English
GET /zh # Force Chinese
vision-detect-check/
βββ app.py # Flask main application
βββ requirements.txt # Dependencies list
βββ README.md # English project documentation (default)
βββ README_ZH.md # Chinese project documentation
βββ run.py # Smart startup script
βββ model/ # Model files directory
β βββ best.pt # YOLOv8 model file
βββ templates/ # HTML templates
β βββ index.html # Chinese homepage template
β βββ index_en.html # English homepage template
βββ ui/ # Interface screenshots
β βββ page.png # Main interface screenshot
βββ uploads/ # Upload storage (auto-created)
βββ results/ # Result images storage (auto-created)
βββ Dockerfile # Docker configuration
βββ docker-compose.yml # Docker Compose configuration
βββ deploy.sh # Deployment script
- Model path:
model/best.pt - Supported formats: PyTorch (.pt), ONNX (.onnx)
- Default port: 5800
- Maximum file size: 16MB
- Debug mode: Enabled by default in development
You can modify the following configurations in app.py:
# File size limit
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB
# Model path
MODEL_PATH = 'model/best.pt'
# Allowed file types
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif', 'bmp', 'tiff'}# Build image
docker build -t yolo-inspector .
# Run container
docker run -p 5800:5800 yolo-inspector# Start service
docker-compose up -d
# Stop service
docker-compose down# Make executable
chmod +x deploy.sh
# Deploy
./deploy.sh build
./deploy.sh start-
ultralytics.utils module error
Problem: See "No module named 'ultralytics.utils'" or similar errors
Solution:
Quick fix (recommended):
python quick_fix.py
Manual fix:
pip uninstall ultralytics -y pip install --no-cache-dir ultralytics>=8.0.196 -
Model loading failure (PyTorch 2.6+ compatibility issues)
Problem: If you see errors like "Weights only load failed" or "WeightsUnpickler error", this is a PyTorch 2.6+ compatibility issue.
Solution:
Method 1: Use complete fix script (recommended)
python fix_torch_compatibility.py
Method 2: Manual PyTorch downgrade
pip uninstall torch torchvision -y pip install "torch>=2.0.0,<2.6.0" "torchvision>=0.15.0,<0.20.0"
Method 3: Code auto-fix included
- Latest app.py includes compatibility fix code
- Run application directly
-
Other model loading issues
- Check if
model/best.ptfile exists - Confirm ultralytics package is installed correctly
- Check Python version compatibility
- Check if
-
Dependency installation failure
- Upgrade pip:
pip install --upgrade pip - Use mirror source:
pip install -r requirements.txt -i https://pypi.douban.com/simple/
- Upgrade pip:
-
GPU related issues
- CPU mode: Automatically uses CPU for inference
- GPU mode: Ensure CUDA environment is configured correctly
-
Port occupied
- Modify port number in app.py:
app.run(port=5801)
- Modify port number in app.py:
-
GPU Acceleration
# Install GPU version PyTorch pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118 -
Model Optimization
- Use TensorRT to optimize model
- Convert to ONNX format to improve inference speed
- Add video file recognition support
- Integrate more pre-trained models
- Add user authentication system
- Implement recognition result database storage
load_model(): Model loading functiondetect_objects(): Core object detection functionupload_file(): File upload processing routemodel_info(): Model information query route- Language detection and routing logic
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License. See LICENSE file for details.
If you encounter issues or have suggestions, please contact us through:
- Create an Issue to report problems
- Submit a Pull Request to contribute code
- Send email for technical questions
Note: Please ensure you have the right to use the provided YOLOv8 model files and comply with relevant license requirements.
