|
|
|
|
|
|
|
|
|
name: YOLOv5 CI
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
pull_request:
|
|
branches: [master]
|
|
schedule:
|
|
- cron: "0 0 * * *"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
Benchmarks:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest]
|
|
python-version: ["3.11"]
|
|
model: [yolov5n]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
- uses: astral-sh/setup-uv@v6
|
|
- name: Install requirements
|
|
run: |
|
|
uv pip install --system -r requirements.txt coremltools openvino-dev tensorflow --extra-index-url https://download.pytorch.org/whl/cpu --index-strategy unsafe-best-match
|
|
yolo checks
|
|
uv pip list
|
|
- name: Benchmark DetectionModel
|
|
run: |
|
|
python benchmarks.py --data coco128.yaml --weights ${{ matrix.model }}.pt --img 320 --hard-fail 0.29
|
|
- name: Benchmark SegmentationModel
|
|
run: |
|
|
python benchmarks.py --data coco128-seg.yaml --weights ${{ matrix.model }}-seg.pt --img 320 --hard-fail 0.22
|
|
- name: Test predictions
|
|
run: |
|
|
python export.py --weights ${{ matrix.model }}-cls.pt --include onnx --img 224
|
|
python detect.py --weights ${{ matrix.model }}.onnx --img 320
|
|
python segment/predict.py --weights ${{ matrix.model }}-seg.onnx --img 320
|
|
python classify/predict.py --weights ${{ matrix.model }}-cls.onnx --img 224
|
|
|
|
Tests:
|
|
timeout-minutes: 60
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, windows-latest, macos-14]
|
|
python-version: ["3.11"]
|
|
model: [yolov5n]
|
|
include:
|
|
- os: ubuntu-latest
|
|
python-version: "3.8"
|
|
model: yolov5n
|
|
torch: "1.8.0"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
- uses: astral-sh/setup-uv@v6
|
|
- name: Install requirements
|
|
run: |
|
|
torch=""
|
|
if [ "${{ matrix.torch }}" == "1.8.0" ]; then
|
|
torch="torch==1.8.0 torchvision==0.9.0"
|
|
fi
|
|
uv pip install --system -r requirements.txt $torch --extra-index-url https://download.pytorch.org/whl/cpu --index-strategy unsafe-best-match
|
|
shell: bash
|
|
- name: Check environment
|
|
run: |
|
|
yolo checks
|
|
pip list
|
|
- name: Test detection
|
|
shell: bash
|
|
run: |
|
|
|
|
m=${{ matrix.model }}
|
|
b=runs/train/exp/weights/best
|
|
python train.py --imgsz 64 --batch 32 --weights $m.pt --cfg $m.yaml --epochs 1 --device cpu
|
|
for d in cpu; do
|
|
for w in $m $b; do
|
|
python val.py --imgsz 64 --batch 32 --weights $w.pt --device $d
|
|
python detect.py --imgsz 64 --weights $w.pt --device $d
|
|
done
|
|
done
|
|
python hubconf.py --model $m
|
|
|
|
python models/yolo.py --cfg $m.yaml
|
|
python export.py --weights $m.pt --img 64 --include torchscript
|
|
python - <<EOF
|
|
import torch
|
|
im = torch.zeros([1, 3, 64, 64])
|
|
for path in '$m', '$b':
|
|
model = torch.hub.load('.', 'custom', path=path, source='local')
|
|
print(model('data/images/bus.jpg'))
|
|
model(im)
|
|
torch.jit.trace(model, [im])
|
|
EOF
|
|
- name: Test segmentation
|
|
shell: bash
|
|
run: |
|
|
m=${{ matrix.model }}-seg
|
|
b=runs/train-seg/exp/weights/best
|
|
python segment/train.py --imgsz 64 --batch 32 --weights $m.pt --cfg $m.yaml --epochs 1 --device cpu
|
|
python segment/train.py --imgsz 64 --batch 32 --weights '' --cfg $m.yaml --epochs 1 --device cpu
|
|
for d in cpu; do
|
|
for w in $m $b; do
|
|
python segment/val.py --imgsz 64 --batch 32 --weights $w.pt --device $d
|
|
python segment/predict.py --imgsz 64 --weights $w.pt --device $d
|
|
python export.py --weights $w.pt --img 64 --include torchscript --device $d
|
|
done
|
|
done
|
|
- name: Test classification
|
|
shell: bash
|
|
run: |
|
|
m=${{ matrix.model }}-cls.pt
|
|
b=runs/train-cls/exp/weights/best.pt
|
|
python classify/train.py --imgsz 32 --model $m --data mnist160 --epochs 1
|
|
python classify/val.py --imgsz 32 --weights $b --data ../datasets/mnist160
|
|
python classify/predict.py --imgsz 32 --weights $b --source ../datasets/mnist160/test/7/60.png
|
|
python classify/predict.py --imgsz 32 --weights $m --source data/images/bus.jpg
|
|
python export.py --weights $b --img 64 --include torchscript
|
|
python - <<EOF
|
|
import torch
|
|
for path in '$m', '$b':
|
|
model = torch.hub.load('.', 'custom', path=path, source='local')
|
|
EOF
|
|
|
|
Summary:
|
|
runs-on: ubuntu-latest
|
|
needs: [Benchmarks, Tests]
|
|
if: always()
|
|
steps:
|
|
- name: Check for failure and notify
|
|
if: (needs.Benchmarks.result == 'failure' || needs.Tests.result == 'failure' || needs.Benchmarks.result == 'cancelled' || needs.Tests.result == 'cancelled') && github.repository == 'ultralytics/yolov5' && (github.event_name == 'schedule' || github.event_name == 'push') && github.run_attempt == '1'
|
|
uses: slackapi/[email protected]
|
|
with:
|
|
webhook-type: incoming-webhook
|
|
webhook: ${{ secrets.SLACK_WEBHOOK_URL_YOLO }}
|
|
payload: |
|
|
text: "<!channel> GitHub Actions error for ${{ github.workflow }} ❌\n\n\n*Repository:* https://github.com/${{ github.repository }}\n*Action:* https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\n*Author:* ${{ github.actor }}\n*Event:* ${{ github.event_name }}\n"
|
|
|