YOLOv8 Red & Green Object Detection Analysis
Published:
YOLOv8 Red & Green Object Detection
π Project Overview
This project uses YOLOv8 to detect and classify two object classes:
- π©
greenbox - π₯
redbox
βοΈ Training Configuration
After running
yolo detect train model=yolov8n.pt data=data.yaml imgsz=320 epochs=10 batch=16 device=0
| Parameter | Value |
|---|---|
| Model | yolov8n |
| Image Size | 320 |
| Epochs | 10 |
| Batch Size | 16 |
| Device | GPU (device=0) |
π Important Output Files
Inside the training folder (runs/detect/train/), the most important files are:
results.pngβ (main training graph)confusion_matrix.pngβPR_curve.pngβF1_curve.pngβweights/best.ptβ
π results.png (Main Graph)
Shows:
- Training & validation loss
- Precision and recall
- mAP50 and mAP50-95
β What to check:
- Loss decreases over time β model is learning
- Validation follows training β no overfitting
- mAP increases β performance improves

Throught the Graph we can analyze
1. TRAINING LOSS ANALYSIS
πΉ train/box_loss
- Decreases from ~0.75 β ~0.53
Smooth and consistent
Interpretation:
Model is improving bounding box localization
πΉ train/cls_loss
- Drops rapidly from ~1.4 β ~0.28
Interpretation: - Model quickly learns to classify
redboxvsgreenbox - Task is relatively easy (distinct colors)
πΉ train/dfl_loss
- Gradual decrease
Interpretation:
- Model is refining bounding box precision
2. Validation Loss Analysis
πΉ val/box_loss
- Smooth decrease
Interpretation:
- Good generalization to unseen validation data
πΉ val/cls_loss
- Spike at early epoch (~3)
- Then decreases steadily
Interpretation:
- Early training instability (normal)
- Model stabilizes afterward
πΉ val/dfl_loss
- Smooth decreasing trend
Interpretation:
- Bounding box quality improves on validation data
π¨ Key Concept: Overfitting Check
| Training Loss | Validation Loss | Meaning |
|---|---|---|
| β | β | β Good (your case) |
| β | β | β Overfitting |
| β | β | β Poor training |
Conclusion:
- No overfitting observed
- Model generalizes well
3. Precision Analysis
- Starts ~0.94
- Drops briefly
- Converges to ~1.0
Interpretation:
- Very few false positives
- Temporary fluctuation is normal
4. Recall Analysis
- Similar behavior to precision
- Ends near 1.0
Interpretation:
- Model detects almost all objects
- Very few missed detections
π 5. mAP Analysis (Most Important Metric)
πΉ mAP50
- Final value β 0.995
Interpretation:
- Nearly perfect detection at IoU = 0.5
πΉ mAP50-95
- Improves from ~0.81 β ~0.93
Interpretation:
- Strong performance under stricter evaluation
- Indicates robust bounding box quality
β οΈ 6. Early Epoch Instability
Observed at epoch ~3:
- Drop in precision, recall, and mAP
Reason:
- Random weight initialization
- Learning adjustment phase
Important:
- This is normal behavior in training
- Focus on overall trend, not individual fluctuations
π 7. Trend vs Raw Values
- Blue line: actual values
- Orange line: smoothed trend
Interpretation:
- Smoothed curve shows true learning behavior
- Model trend is stable and improving
π confusion_matrix.png
Shows classification performance:
| True \ Predicted | greenbox | redbox |
|---|---|---|
| greenbox | β correct | β wrong |
| redbox | β wrong | β correct |
What to check:
- Strong diagonal β good model
- Off-diagonal β classification errors
Below is the confusing matrix we get after the training

β Correct Predictions (Diagonal)
- greenbox β greenbox = 573
- redbox β redbox = 427
π― Interpretation:
- Model correctly classifies almost all objects
- Very strong diagonal β excellent performance
β Errors (Off-Diagonal)
πΉ False Positives (FP)
- 1 background detected as redbox
π Meaning:
- Model detected an object where there is none
πΉ False Negatives (FN)
- 1 greenbox missed (predicted as background)
- 1 redbox missed (predicted as background)
π Meaning:
- Model failed to detect some objects
π Error Summary
| Error Type | Count |
|---|---|
| False Positive | 1 |
| False Negative | 2 |
π Total errors = 3 (very low)
π Performance Interpretation
β Strengths
- Nearly perfect classification between red and green
- Almost no confusion between classes
- Extremely high accuracy
π PR_curve.png (PrecisionβRecall Curve)
Shows tradeoff between precision and recall.
What to check:
- Curve near top-right β excellent model
- Large area under curve β high performance
β 1. PrecisionβRecall (PR) Curve
Purpose:
- Shows overall model performance
- Combines:
- Precision (accuracy)
- Recall (completeness)
Why important:
- Used to compute mAP (main YOLO metric)
- Best indicator of model quality

Result:
- Curve near top-right
- mAP β 0.995
π Conclusion: Excellent model
π 2. PrecisionβConfidence Curve (P Curve)
Purpose:
- Shows how precision changes with confidence threshold
Interpretation:
- Higher confidence β fewer false positives
- Model becomes more strict

Result:
- Precision quickly reaches ~1.0
- Very stable
π Conclusion: Predictions are highly accurate
π 3. RecallβConfidence Curve (R Curve)
Purpose:
- Shows how many objects are detected as threshold changes
Interpretation:
- Higher confidence β more missed detections

Result:
- Recall β 1.0 at low confidence
- Drops sharply after ~0.9
π Conclusion: High confidence may miss objects
π F1_curve.png
Shows best balance between precision and recall.
What to check:
- Peak value β best performance
- Confidence at peak β optimal threshold
π It represents the best balance between Precision and Recall

πΉ Shape:
- F1 is very high (~1.0) across a wide range
- Drops sharply after ~0.9 confidence
πΉ Key point:
- Best F1 β 1.00 at confidence β 0.799
β 1. Excellent Performance
- F1 β 1.0 β almost perfect balance
- Means:
- Very few false positives
- Very few missed detections
π Model is extremely strong
βοΈ 2. Optimal Threshold
- Best confidence β 0.8
π This is the ideal operating point
At this point:
- Precision is high
- Recall is high
- Overall performance is maximized
π§ weights/best.pt
The final trained model.
Use it for inference:
yolo detect predict model=weights/best.pt source=your_image.jpg conf=0.8
1. Detection Output
For example:
yolo detect predict model=best.pt source=test/images/greenbox_0_jpg.rf.b7606581a957e3d3d3b8a36e5a4d82cb.jpg conf=0.8

Model detected:
- 1 object
- Class = greenbox
- Inference time = 12.8 ms
