🚀 熱成像相機人體檢測
本項目提供了一個基於熱成像圖像的人體檢測模型,可用於偽彩色和灰度熱成像圖像。模型最初針對人體檢測進行了微調,也可進一步微調以檢測其他物體。
🚀 快速開始
部署模型
要部署此模型,請使用以下代碼:
安裝依賴
$ python -m pip install ultralytics supervision huggingface_hub
Python代碼
from huggingface_hub import hf_hub_download
from ultralytics import YOLO
from supervision import Detections
import cv
model_path = hf_hub_download(
repo_id = "pitangent-ds/YOLOv8-human-detection-thermal",
filename = "model.pt"
)
model = YOLO(model_path)
def inference(image_path):
cv_image = cv.imread(image_path, cv2.IMREAD_ANYCOLOR)
model_output = model(cv_image, conf=0.6, verbose=False)
detections = Detections.from_ultralytics(model_output[0])
return detections
✨ 主要特性
- 多圖像類型支持:支持偽彩色和灰度熱成像圖像。
- 可擴展性:模型最初針對人體檢測進行微調,也可進一步微調以檢測其他物體。
📦 安裝指南
安裝所需的依賴庫:
$ python -m pip install ultralytics supervision huggingface_hub
💻 使用示例
基礎用法
from huggingface_hub import hf_hub_download
from ultralytics import YOLO
from supervision import Detections
import cv
model_path = hf_hub_download(
repo_id = "pitangent-ds/YOLOv8-human-detection-thermal",
filename = "model.pt"
)
model = YOLO(model_path)
def inference(image_path):
cv_image = cv.imread(image_path, cv2.IMREAD_ANYCOLOR)
model_output = model(cv_image, conf=0.6, verbose=False)
detections = Detections.from_ultralytics(model_output[0])
return detections
📚 詳細文檔
訓練代碼
from ultralytics import YOLO
import torch
model = YOLO("yolov8n.pt")
hyperparams = {
"batch": 32,
"epochs": 30,
"imgsz": [640, 480],
"optimizer": "AdamW",
"cos_lr": True,
"lr0": 3e-5,
"warmup_epochs": 10
}
model.train(
device = 'cuda' if torch.cuda.is_available() else 'cpu',
data = "data.yaml",
**hyperparams
)
依賴庫
python: 3.10.13
ultralytics: 8.0.206
torch: "2.1.0+cu118"
roboflow: 1.1.9
📄 許可證
本項目採用AGPL-3.0許可證。