You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
195 lines
8.2 KiB
195 lines
8.2 KiB
# Ultralytics YOLO 🚀, GPL-3.0 license |
|
# YOLO Continuous Integration (CI) GitHub Actions tests |
|
|
|
name: Ultralytics CI |
|
|
|
on: |
|
push: |
|
branches: [main] |
|
pull_request: |
|
branches: [main, updates] |
|
schedule: |
|
- cron: '0 0 * * *' # runs at 00:00 UTC every day |
|
|
|
jobs: |
|
HUB: |
|
if: github.repository == 'ultralytics/ultralytics' && (github.event_name == 'schedule' || github.event_name == 'push') |
|
runs-on: ${{ matrix.os }} |
|
strategy: |
|
fail-fast: false |
|
matrix: |
|
os: [ubuntu-latest] |
|
python-version: ['3.10'] |
|
model: [yolov5n] |
|
steps: |
|
- uses: actions/checkout@v3 |
|
- uses: actions/setup-python@v4 |
|
with: |
|
python-version: ${{ matrix.python-version }} |
|
cache: 'pip' # caching pip dependencies |
|
- name: Install requirements |
|
shell: bash # for Windows compatibility |
|
run: | |
|
python -m pip install --upgrade pip wheel |
|
pip install -e . --extra-index-url https://download.pytorch.org/whl/cpu |
|
- name: Check environment |
|
run: | |
|
echo "RUNNER_OS is ${{ runner.os }}" |
|
echo "GITHUB_EVENT_NAME is ${{ github.event_name }}" |
|
echo "GITHUB_WORKFLOW is ${{ github.workflow }}" |
|
echo "GITHUB_ACTOR is ${{ github.actor }}" |
|
echo "GITHUB_REPOSITORY is ${{ github.repository }}" |
|
echo "GITHUB_REPOSITORY_OWNER is ${{ github.repository_owner }}" |
|
python --version |
|
pip --version |
|
pip list |
|
- name: Test HUB training |
|
shell: python |
|
env: |
|
API_KEY: ${{ secrets.ULTRALYTICS_HUB_API_KEY }} |
|
MODEL_ID: ${{ secrets.ULTRALYTICS_HUB_MODEL_ID }} |
|
run: | |
|
import os |
|
from ultralytics import YOLO, hub |
|
api_key, model_id = os.environ['API_KEY'], os.environ['MODEL_ID'] |
|
hub.login(api_key) |
|
hub.reset_model(model_id) |
|
model = YOLO('https://hub.ultralytics.com/models/' + model_id) |
|
model.train() |
|
|
|
Benchmarks: |
|
runs-on: ${{ matrix.os }} |
|
strategy: |
|
fail-fast: false |
|
matrix: |
|
os: [ubuntu-latest] |
|
python-version: ['3.10'] |
|
model: [yolov8n] |
|
steps: |
|
- uses: actions/checkout@v3 |
|
- uses: actions/setup-python@v4 |
|
with: |
|
python-version: ${{ matrix.python-version }} |
|
cache: 'pip' # caching pip dependencies |
|
- name: Install requirements |
|
shell: bash # for Windows compatibility |
|
run: | |
|
python -m pip install --upgrade pip wheel |
|
if [ "${{ matrix.os }}" == "macos-latest" ]; then |
|
pip install -e . coremltools openvino-dev tensorflow-macos tensorflowjs --extra-index-url https://download.pytorch.org/whl/cpu |
|
else |
|
pip install -e . coremltools openvino-dev tensorflow-cpu tensorflowjs --extra-index-url https://download.pytorch.org/whl/cpu |
|
fi |
|
yolo export format=tflite |
|
- name: Check environment |
|
run: | |
|
echo "RUNNER_OS is ${{ runner.os }}" |
|
echo "GITHUB_EVENT_NAME is ${{ github.event_name }}" |
|
echo "GITHUB_WORKFLOW is ${{ github.workflow }}" |
|
echo "GITHUB_ACTOR is ${{ github.actor }}" |
|
echo "GITHUB_REPOSITORY is ${{ github.repository }}" |
|
echo "GITHUB_REPOSITORY_OWNER is ${{ github.repository_owner }}" |
|
python --version |
|
pip --version |
|
pip list |
|
- name: Benchmark DetectionModel |
|
shell: python |
|
run: | |
|
from ultralytics.yolo.utils.benchmarks import benchmark |
|
benchmark(model='${{ matrix.model }}.pt', imgsz=160, half=False, hard_fail=0.20) |
|
- name: Benchmark SegmentationModel |
|
shell: python |
|
run: | |
|
from ultralytics.yolo.utils.benchmarks import benchmark |
|
benchmark(model='${{ matrix.model }}-seg.pt', imgsz=160, half=False, hard_fail=0.14) |
|
- name: Benchmark ClassificationModel |
|
shell: python |
|
run: | |
|
from ultralytics.yolo.utils.benchmarks import benchmark |
|
benchmark(model='${{ matrix.model }}-cls.pt', imgsz=160, half=False, hard_fail=0.61) |
|
- name: Benchmark PoseModel |
|
shell: python |
|
run: | |
|
from ultralytics.yolo.utils.benchmarks import benchmark |
|
benchmark(model='${{ matrix.model }}-pose.pt', imgsz=160, half=False, hard_fail=0.0) |
|
- name: Benchmark Summary |
|
run: | |
|
cat benchmarks.log |
|
echo "$(cat benchmarks.log)" >> $GITHUB_STEP_SUMMARY |
|
|
|
Tests: |
|
timeout-minutes: 60 |
|
runs-on: ${{ matrix.os }} |
|
strategy: |
|
fail-fast: false |
|
matrix: |
|
os: [ubuntu-latest] |
|
python-version: ['3.7', '3.8', '3.9', '3.10'] |
|
model: [yolov8n] |
|
torch: [latest] |
|
include: |
|
- os: ubuntu-latest |
|
python-version: '3.8' # torch 1.7.0 requires python >=3.6, <=3.8 |
|
model: yolov8n |
|
torch: '1.8.0' # min torch version CI https://pypi.org/project/torchvision/ |
|
steps: |
|
- uses: actions/checkout@v3 |
|
- uses: actions/setup-python@v4 |
|
with: |
|
python-version: ${{ matrix.python-version }} |
|
cache: 'pip' # caching pip dependencies |
|
- name: Install requirements |
|
shell: bash # for Windows compatibility |
|
run: | |
|
python -m pip install --upgrade pip wheel |
|
if [ "${{ matrix.torch }}" == "1.8.0" ]; then |
|
pip install -e . torch==1.8.0 torchvision==0.9.0 pytest --extra-index-url https://download.pytorch.org/whl/cpu |
|
else |
|
pip install -e . pytest --extra-index-url https://download.pytorch.org/whl/cpu |
|
fi |
|
- name: Check environment |
|
run: | |
|
echo "RUNNER_OS is ${{ runner.os }}" |
|
echo "GITHUB_EVENT_NAME is ${{ github.event_name }}" |
|
echo "GITHUB_WORKFLOW is ${{ github.workflow }}" |
|
echo "GITHUB_ACTOR is ${{ github.actor }}" |
|
echo "GITHUB_REPOSITORY is ${{ github.repository }}" |
|
echo "GITHUB_REPOSITORY_OWNER is ${{ github.repository_owner }}" |
|
python --version |
|
pip --version |
|
pip list |
|
- name: Test Detect |
|
shell: bash # for Windows compatibility |
|
run: | |
|
yolo detect train data=coco8.yaml model=yolov8n.yaml epochs=1 imgsz=32 |
|
yolo detect train data=coco8.yaml model=yolov8n.pt epochs=1 imgsz=32 |
|
yolo detect val data=coco8.yaml model=runs/detect/train/weights/last.pt imgsz=32 |
|
yolo detect predict model=runs/detect/train/weights/last.pt imgsz=32 source=ultralytics/assets/bus.jpg |
|
yolo export model=runs/detect/train/weights/last.pt imgsz=32 format=torchscript |
|
- name: Test Segment |
|
shell: bash # for Windows compatibility |
|
run: | |
|
yolo segment train data=coco8-seg.yaml model=yolov8n-seg.yaml epochs=1 imgsz=32 |
|
yolo segment train data=coco8-seg.yaml model=yolov8n-seg.pt epochs=1 imgsz=32 |
|
yolo segment val data=coco8-seg.yaml model=runs/segment/train/weights/last.pt imgsz=32 |
|
yolo segment predict model=runs/segment/train/weights/last.pt imgsz=32 source=ultralytics/assets/bus.jpg |
|
yolo export model=runs/segment/train/weights/last.pt imgsz=32 format=torchscript |
|
- name: Test Classify |
|
shell: bash # for Windows compatibility |
|
run: | |
|
yolo classify train data=imagenet10 model=yolov8n-cls.yaml epochs=1 imgsz=32 |
|
yolo classify train data=imagenet10 model=yolov8n-cls.pt epochs=1 imgsz=32 |
|
yolo classify val data=imagenet10 model=runs/classify/train/weights/last.pt imgsz=32 |
|
yolo classify predict model=runs/classify/train/weights/last.pt imgsz=32 source=ultralytics/assets/bus.jpg |
|
yolo export model=runs/classify/train/weights/last.pt imgsz=32 format=torchscript |
|
- name: Test Pose |
|
shell: bash # for Windows compatibility |
|
run: | |
|
yolo pose train data=coco8-pose.yaml model=yolov8n-pose.yaml epochs=1 imgsz=32 |
|
yolo pose train data=coco8-pose.yaml model=yolov8n-pose.pt epochs=1 imgsz=32 |
|
yolo pose val data=coco8-pose.yaml model=runs/pose/train/weights/last.pt imgsz=32 |
|
yolo pose predict model=runs/pose/train/weights/last.pt imgsz=32 source=ultralytics/assets/bus.jpg |
|
yolo export model=runs/pose/train/weights/last.pt imgsz=32 format=torchscript |
|
- name: Pytest tests |
|
shell: bash # for Windows compatibility |
|
run: pytest tests
|
|
|