Firearm Detection YOLOv8n
A high-performance YOLOv8-nano model specifically trained for Leaf(Tulsi) detection in images and videos. This model achieves exceptional accuracy with 89.0% [email protected] and is optimized for real-time inference applications (for research purposes) in agricultural environments.
Model Overview
This model was trained on a comprehensive Tulsi leaf dataset (sourced from Roboflow Universe) containing approximately 4,000 high-quality images. It was trained for an object detection task specifically on Tulsi leaves. However, it seems to be predicting every leaf as Tulsi, possibly because it has primarily learned the general texture and shape characteristics of leaves rather than the distinct features of Tulsi leaves.
Key Features:
- High accuracy: 89.0% [email protected], 60.2% [email protected].
- Optimized for real-time inference.
- Moderate performance across different lighting and background conditions.
Performance Metrics
The model demonstrates exceptional performance on the validation dataset after 100 epochs of training:
Metric | Value |
---|---|
[email protected] | 0.890 |
[email protected] | 0.602 |
Precision | 0.864 |
Recall | 0.824 |
F1-Score | 0.84 |
Training Results
Training and Validation Curves
The training progression over 100 epochs shows consistent improvement across all metrics:
The graphs demonstrate:
- Loss Reduction: Steady decrease in box_loss, cls_loss, and dfl_loss
- Metric Improvement: Consistent increase in precision, recall, mAP50, and mAP50-95
- Convergence: Stable performance indicating optimal training completion
Dataset Distribution
The dataset contains 6,800 gun instances across 7,068 training images, with balanced spatial distribution and varied object sizes for robust detection capabilities.
Model Performance Analysis
Confusion Matrix
The confusion matrices show:
- True Positives: 1,537 correctly identified guns (86% accuracy)
- False Negatives: 249 missed detections (14% miss rate)
- False Positives: 324 background misclassifications
- Strong Performance: High precision with minimal false positive rate
Performance Curves
Precision-Recall Curve![]() |
Precision-Confidence Curve![]() |
Recall-Confidence Curve![]() |
F1-Confidence Curve![]() |
These curves demonstrate optimal performance at confidence threshold 0.4, balancing precision and recall for practical deployment.
Inferencing instructions
pip install ultralytics huggingface_hub
# Download weights
!wget
from PIL import Image
from ultralytics import YOLO
# Load a pretrained YOLO11n model
model = YOLO("best.pt")
# Open an image using PIL
source = Image.open("image_path.jpg")
results=model(source, conf=0.01) # adjust based on req.
# Process results list
for result in results:
boxes = result.boxes # Boxes object for bounding box outputs
# masks = result.masks # Masks object for segmentation masks outputs # None for detection
# keypoints = result.keypoints # Keypoints object for pose outputs # None for detection
probs = result.probs # Probs object for classification outputs # None for detection
result.show() # display to screen
# result.save(filename="result.jpg") # save to disk if needed
# Human-readable format for drawn annotations
for i, row in enumerate(boxes.data):
x1, y1, x2, y2, conf, cls_idx = row.tolist() # CPU floats
cls_idx = int(cls_idx)
conf = float(conf)
name = model.names[cls_idx] if hasattr(model, 'names') else str(cls_idx)
print(f"Box {i}: {name} {conf:.2f} | x1={int(x1)} y1={int(y1)} x2={int(x2)} y2={int(y2)}")
Model Architecture
- Base Model: YOLOv8-nano (yolov8n.pt)
- Input Size: 640x640 pixels
- Classes: Tulsi (Leaf)
- Parameters: ~3.2M
- Model Size: ~6.2MB
- Inference Speed: ~4ms per image (GPU)
Training Configuration
- Epochs: 50
- Batch Size: 16 (batch_size=4, grad_accum_steps=4)
- Image Size: 640x640
- Optimizer: AdamW
- Learning Rate: 0.01 (initial)
Limitations and Considerations
Technical Limitations:
- Performance may degrade with image quality, lighting, and occlusion.
- False positives possible with objects resembling firearms (toys, tools)
Recommended Usage:
- Use appropriate confidence thresholds based on requirements
- Regular model evaluation and updates for optimal performance
License
This model is released under the Apache 2.0 License. See the LICENSE file for details.
Disclaimer: This model is provided for research purposes only. The predictions can not be used to solve real world descisions.
Model tree for LeafNet75/Leaf-Detect-YOLOv8
Base model
Ultralytics/YOLOv8