fit@hcmus.edu.vn - Introduction to Machine Learning Course
1. Nguyễn Anh Tường - 220120412
2. Nguyễn Đình Trí - 22020384
3. Vũ Hoàng Nhật Trường - 22120398
4. Phạm Tuấn Vương - 22120446
5. Lê Quốc Vương - 22120445
Một hệ thống AI thông minh kết hợp nhận diện biển báo giao thông và chatbot tư vấn luật giao thông Việt Nam.
Dự án này là một hệ thống hoàn chỉnh bao gồm:
- AI Traffic Sign Detection: Nhận diện biển báo giao thông sử dụng YOLOv8
- Intelligent Chatbot: Tư vấn luật giao thông thông minh
- Modern Web UI: Giao diện Streamlit hiện đại và thân thiện
- Knowledge Base: Cơ sở dữ liệu biển báo giao thông Việt Nam
- Phát hiện và phân loại biển báo trong hình ảnh
- Hỗ trợ nhiều định dạng ảnh (JPG, PNG, JPEG)
- Hiển thị độ tin cậy và thông tin chi tiết
- Tích hợp cơ sở dữ liệu biển báo Việt Nam
- Trả lời câu hỏi về biển báo và luật giao thông
- Xử lý cả tin nhắn văn bản và hình ảnh
- Hiệu ứng typing indicator động
- Streaming response cho trải nghiệm mượt mà
- Thiết kế responsive và hiện đại
- Animations và hiệu ứng tương tác
- Hỗ trợ đa ngôn ngữ (Tiếng Việt)
- Component tái sử dụng và module hóa
cv_platebot/
├── dev/ # Core development modules
│ ├── core/ # Core functionality
│ │ ├── chatbot/ # Chatbot components
│ │ │ ├── KB.json # Knowledge Base (417 biển báo)
│ │ │ ├── TrafficBotResponder.py # Main chatbot logic
│ │ │ └── test_images/ # Test images
│ │ ├── model/ # AI model components
│ │ │ └── model_loader.py # Model loading utilities
│ │ └── server.py # Backend server
│ ├── train_model/ # Model training
│ │ ├── YOLO_training.ipynb # Training notebooks
│ │ ├── weights/ # Trained model weights
│ │ └── test_images/ # Training test images
│ └── utils/ # Utility functions
│ ├── authenticator.py # Authentication
│ └── downloader.py # File download utilities
├── streamlit-traffic-sign-ui/ # Frontend application
│ ├── src/ # Source code
│ │ ├── components/ # Reusable components
│ │ │ ├── typing_indicator.py # Typing animations
│ │ │ ├── results_display.py # Results display
│ │ │ └── chat_widget.py # Chat components
│ │ ├── pages/ # Application pages
│ │ │ ├── chatbot_page.py # Main chatbot interface
│ │ │ └── image_detection.py # Image detection page
│ │ └── homepage.py # Main application entry
│ ├── assets/ # Static assets
│ ├── data/ # Data storage
│ └── requirements.txt # Dependencies
└── README.md # This file
- Python 3.8+
- Windows/Linux/macOS
- GPU (tùy chọn, để tăng tốc AI)
cd streamlit-traffic-sign-ui
pip install -r requirements.txt# CPU version
pip install torch torchvision torchaudio
# GPU version (CUDA)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118pip install ultralyticsstreamlit run .\streamlit-traffic-sign-ui\src\homepage.py - Đặt file weights YOLOv8 trong
dev/train_model/weights/ - Mặc định sử dụng
best.pt
- File
dev/core/chatbot/KB.jsonchứa 417 biển báo giao thông - Có thể cập nhật và mở rộng dễ dàng
# Trong config.py
MODEL_PATH = "dev/train_model/weights/best.pt"
KB_PATH = "dev/core/chatbot/KB.json"
DATA_DIR = "streamlit-traffic-sign-ui/data"- Vào trang "Image Detection"
- Tải lên hình ảnh biển báo
- Nhấn "Detect Traffic Signs"
- Xem kết quả chi tiết
- Vào trang "Chatbot"
- Nhập câu hỏi về biển báo/luật giao thông
- Hoặc tải lên hình ảnh kèm câu hỏi
- Nhận phản hồi thông minh
- Chức năng: Xử lý logic chatbot chính
- Tính năng:
- Xử lý tin nhắn văn bản
- Phân tích hình ảnh với YOLO
- Tra cứu Knowledge Base
- Tạo response thông minh
- Chức năng: Tải và quản lý model YOLO
- Tính năng:
- Lazy loading model
- Caching để tối ưu performance
- Error handling
- Chức năng: Hiển thị kết quả detection
- Tính năng:
- Tabbed interface
- Detailed info từ KB
- Confidence scores
- Visual feedback
{
"W.224": {
"code": "W.224",
"name": "Đường người đi bộ cắt ngang",
"meaning": "Báo trước sắp tới phần đường dành cho người đi bộ sang qua đường",
"action": "Giảm tốc độ, nhường ưu tiên cho người đi bộ...",
"penalty": "Không có mức xử phạt riêng",
"shape": "Hình tam giác với nền màu vàng, viền đỏ..."
}
}- 417 biển báo: Đầy đủ theo tiêu chuẩn Việt Nam
- 6 loại chính: Cảnh báo, cấm, hiệu lệnh, chỉ dẫn, phụ trợ, tạm thời
- Thông tin chi tiết: Mã số, tên, ý nghĩa, hành động, phạt, hình dạng
- Thư mục
dev/core/chatbot/test_images/chứa 10 hình ảnh test - Có thể sử dụng nút "Test with Sample Image"
- Base Model: YOLOv8n/s/m (tùy chọn)
- Training: Custom dataset biển báo Việt Nam
- Performance: Real-time detection
- Accuracy: 85%+ trên test set
- Dataset preparation
- Annotation (YOLO format)
- Model training với custom config
- Validation và testing
- Export weights
streamlit run src/homepage.py --server.port 8501docker build -t traffic-sign-app .
docker run -p 8501:8501 traffic-sign-app- Streamlit Cloud
- Detection Speed: ~50ms per image
- Chatbot Response: ~1-2s
- UI Rendering: <100ms
- Memory Usage: ~500MB
- Model quantization
- Image preprocessing
- Caching strategies
- Lazy loading
- Modular Design: Components tái sử dụng
- Clean Architecture: Separation of concerns
- Type Hints: Better code documentation
- Error Handling: Robust error management
- Code Style: PEP 8 compliant
- Documentation: Comprehensive docstrings
- Testing: Unit và integration tests
- Version Control: Git workflow
git clone <repository>
cd cv_platebot
pip install -r requirements.txt
pip install -e .- Fork the repository
- Create feature branch
- Make changes với tests
- Submit pull request
- Model not found: Kiểm tra đường dẫn weights
- Import errors: Cài đặt dependencies đầy đủ
- Memory issues: Giảm batch size
- Performance slow: Sử dụng GPU
streamlit run src/homepage.py --logger.level=debugThis project is licensed under the MIT License - see the LICENSE file for details.
- YOLOv8: Ultralytics team
- Streamlit: Amazing web framework
- OpenCV: Computer vision library
- Vietnamese Traffic Laws: Bộ Giao thông Vận tải
Được xây dựng cho cộng đồng giao thông Việt Nam