Nguyễn Quốc Việt commited on
Commit
2ecdae9
·
verified ·
1 Parent(s): e5bcf26

Add/Update QUICK_START.md

Browse files
Files changed (1) hide show
  1. QUICK_START.md +152 -0
QUICK_START.md ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Quick Start Guide - Testing the Model
2
+
3
+ This guide will help you quickly test the Highway Vehicle Detection model on new data.
4
+
5
+ ## Prerequisites
6
+
7
+ 1. **Install Python dependencies:**
8
+ ```bash
9
+ pip install -r requirements.txt
10
+ ```
11
+
12
+ 2. **Download/clone the repository** from Hugging Face:
13
+ ```bash
14
+ git clone https://huggingface.co/bichuche0705/highway-vehicle-detection-code
15
+ cd highway-vehicle-detection-code
16
+ ```
17
+
18
+ Or download manually from: https://huggingface.co/bichuche0705/highway-vehicle-detection-code
19
+
20
+ ## Model Files Location
21
+
22
+ The trained models are located at:
23
+ - **Best model (recommended)**: `training_runs/yolov8m_stage2_improved/weights/best.pt`
24
+ - **Alternative location**: `models/yolov8m_stage2_improved_best.pt`
25
+ - **Stage 1 model**: `training_runs/yolov8m_stage1_smart/weights/best.pt`
26
+
27
+ ## Method 1: Simple Test Script (Recommended for Quick Testing)
28
+
29
+ Use the `test_model.py` script for easy testing:
30
+
31
+ ### Test on an Image:
32
+ ```bash
33
+ python test_model.py your_image.jpg
34
+ ```
35
+
36
+ The script will:
37
+ - Automatically find the model
38
+ - Detect vehicles in the image
39
+ - Save the result as `your_image_result.jpg`
40
+
41
+ ### Test on a Video:
42
+ ```bash
43
+ python test_model.py your_video.mp4 --video
44
+ ```
45
+
46
+ With custom output:
47
+ ```bash
48
+ python test_model.py your_video.mp4 --video --output output_video.mp4
49
+ ```
50
+
51
+ ## Method 2: Using example_usage.py
52
+
53
+ ```python
54
+ from example_usage import detect_vehicles, process_video
55
+
56
+ # For images
57
+ detect_vehicles("test_image.jpg", model_path="models/yolov8m_stage2_improved_best.pt")
58
+
59
+ # For videos
60
+ process_video("test_video.mp4", output_path="output.mp4")
61
+ ```
62
+
63
+ ## Method 3: Using main.py (Full Application)
64
+
65
+ The `main.py` script provides advanced features like vehicle counting and tracking:
66
+
67
+ ```bash
68
+ # Basic usage (auto-detects first .mp4 in directory)
69
+ python main.py --model training_runs/yolov8m_stage2_improved/weights/best.pt
70
+
71
+ # With specific video
72
+ python main.py --model training_runs/yolov8m_stage2_improved/weights/best.pt --video your_video.mp4
73
+
74
+ # Save output video
75
+ python main.py --model training_runs/yolov8m_stage2_improved/weights/best.pt --video input.mp4 --output output.mp4
76
+ ```
77
+
78
+ **Important**: You need to specify the `--model` path because the default path in `main.py` might not match the repository structure.
79
+
80
+ ## Method 4: Direct Python Code
81
+
82
+ ```python
83
+ from ultralytics import YOLO
84
+
85
+ # Load model
86
+ model = YOLO('training_runs/yolov8m_stage2_improved/weights/best.pt')
87
+
88
+ # Test on image
89
+ results = model('your_image.jpg')
90
+ results[0].show() # Display results
91
+ results[0].save('output.jpg') # Save results
92
+
93
+ # Test on video
94
+ results = model('your_video.mp4', save=True)
95
+ # Output saved to: runs/detect/predict/
96
+ ```
97
+
98
+ ## Detected Vehicle Classes
99
+
100
+ The model detects 8 vehicle types:
101
+ 1. **auto** - Three-wheelers
102
+ 2. **bus** - Public transport vehicles
103
+ 3. **car** - Passenger cars
104
+ 4. **lcv** - Light Commercial Vehicles
105
+ 5. **motorcycle** - Two-wheelers
106
+ 6. **multiaxle** - Multi-axle heavy vehicles
107
+ 7. **tractor** - Agricultural/construction vehicles
108
+ 8. **truck** - Heavy vehicles
109
+
110
+ ## Troubleshooting
111
+
112
+ ### Model Not Found Error
113
+
114
+ If you get "Model file not found":
115
+ 1. Make sure you've downloaded/cloned the repository completely
116
+ 2. Check that the model file exists at one of these paths:
117
+ - `training_runs/yolov8m_stage2_improved/weights/best.pt`
118
+ - `models/yolov8m_stage2_improved_best.pt`
119
+
120
+ ### Import Errors
121
+
122
+ If you get import errors:
123
+ ```bash
124
+ pip install ultralytics opencv-python numpy torch torchvision
125
+ ```
126
+
127
+ Or install all requirements:
128
+ ```bash
129
+ pip install -r requirements.txt
130
+ ```
131
+
132
+ ### CUDA/GPU Issues
133
+
134
+ If you have CUDA available, PyTorch will use it automatically. For CPU-only:
135
+ - The model will run but will be slower
136
+ - No additional setup needed
137
+
138
+ ## Example Output
139
+
140
+ When running the model, you should see:
141
+ - Bounding boxes around detected vehicles
142
+ - Class labels (auto, bus, car, etc.)
143
+ - Confidence scores
144
+ - Output saved to files
145
+
146
+ ## Need Help?
147
+
148
+ Check the repository README.md for more detailed documentation, or review the code comments in:
149
+ - `main.py` - Full application with counting
150
+ - `example_usage.py` - Simple examples
151
+ - `test_model.py` - Quick test script
152
+