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.
159 lines
6.8 KiB
159 lines
6.8 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]
|
|
schedule:
|
|
- cron: '0 0 * * *' # runs at 00:00 UTC every day
|
|
|
|
jobs:
|
|
Benchmarks:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
python-version: ['3.10'] # requires python<=3.9
|
|
model: [yolov8n]
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-python@v4
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
#- name: Cache pip
|
|
# uses: actions/cache@v3
|
|
# with:
|
|
# path: ~/.cache/pip
|
|
# key: ${{ runner.os }}-Benchmarks-${{ hashFiles('requirements.txt') }}
|
|
# restore-keys: ${{ runner.os }}-Benchmarks-
|
|
- name: Install requirements
|
|
run: |
|
|
python -m pip install --upgrade pip wheel
|
|
pip install -e . coremltools openvino-dev tensorflow-cpu paddlepaddle x2paddle --extra-index-url https://download.pytorch.org/whl/cpu
|
|
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 run_benchmarks
|
|
run_benchmarks(model='yolov8n.pt', imgsz=160, half=False, hard_fail=False)
|
|
- name: Benchmark SegmentationModel
|
|
shell: python
|
|
run: |
|
|
from ultralytics.yolo.utils.benchmarks import run_benchmarks
|
|
run_benchmarks(model='yolov8n-seg.pt', imgsz=160, half=False, hard_fail=False)
|
|
- name: Benchmark ClassificationModel
|
|
shell: python
|
|
run: |
|
|
from ultralytics.yolo.utils.benchmarks import run_benchmarks
|
|
run_benchmarks(model='yolov8n-cls.pt', imgsz=160, half=False, hard_fail=False)
|
|
|
|
Tests:
|
|
timeout-minutes: 60
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest]
|
|
python-version: ['3.10']
|
|
model: [yolov8n]
|
|
torch: [latest]
|
|
include:
|
|
- os: ubuntu-latest
|
|
python-version: '3.7' # '3.6.8' min
|
|
model: yolov8n
|
|
- 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 }}
|
|
- name: Get cache dir
|
|
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
|
|
id: pip-cache
|
|
run: echo "::set-output name=dir::$(pip cache dir)"
|
|
- name: Cache pip
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ${{ steps.pip-cache.outputs.dir }}
|
|
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('requirements.txt') }}
|
|
restore-keys: ${{ runner.os }}-${{ matrix.python-version }}-pip-
|
|
- name: Install requirements
|
|
run: |
|
|
python -m pip install --upgrade pip wheel
|
|
if [ "${{ matrix.torch }}" == "1.8.0" ]; then
|
|
pip install -e '.[export]' torch==1.8.0 torchvision==0.9.0 pytest --extra-index-url https://download.pytorch.org/whl/cpu
|
|
else
|
|
pip install -e '.[export]' pytest --extra-index-url https://download.pytorch.org/whl/cpu
|
|
fi
|
|
shell: bash # for Windows compatibility
|
|
- 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 pip package
|
|
shell: python
|
|
env:
|
|
APIKEY: ${{ secrets.ULTRALYTICS_HUB_APIKEY }}
|
|
run: |
|
|
import os
|
|
import ultralytics
|
|
from ultralytics import hub, yolo
|
|
key = os.environ['APIKEY']
|
|
print(ultralytics.__version__)
|
|
ultralytics.checks()
|
|
# ultralytics.reset_model(key) # reset trained model
|
|
# ultralytics.start(key) # train model
|
|
- name: Test detection
|
|
shell: bash # for Windows compatibility
|
|
run: |
|
|
yolo task=detect mode=train data=coco8.yaml model=yolov8n.yaml epochs=1 imgsz=32
|
|
yolo task=detect mode=train data=coco8.yaml model=yolov8n.pt epochs=1 imgsz=32
|
|
yolo task=detect mode=val data=coco8.yaml model=runs/detect/train/weights/last.pt imgsz=32
|
|
yolo task=detect mode=predict model=runs/detect/train/weights/last.pt imgsz=32 source=ultralytics/assets/bus.jpg
|
|
yolo mode=export model=runs/detect/train/weights/last.pt imgsz=32 format=torchscript
|
|
- name: Test segmentation
|
|
shell: bash # for Windows compatibility
|
|
run: |
|
|
yolo task=segment mode=train data=coco8-seg.yaml model=yolov8n-seg.yaml epochs=1 imgsz=32
|
|
yolo task=segment mode=train data=coco8-seg.yaml model=yolov8n-seg.pt epochs=1 imgsz=32
|
|
yolo task=segment mode=val data=coco8-seg.yaml model=runs/segment/train/weights/last.pt imgsz=32
|
|
yolo task=segment mode=predict model=runs/segment/train/weights/last.pt imgsz=32 source=ultralytics/assets/bus.jpg
|
|
yolo mode=export model=runs/segment/train/weights/last.pt imgsz=32 format=torchscript
|
|
- name: Test classification
|
|
shell: bash # for Windows compatibility
|
|
run: |
|
|
yolo task=classify mode=train data=imagenet10 model=yolov8n-cls.yaml epochs=1 imgsz=32
|
|
yolo task=classify mode=train data=imagenet10 model=yolov8n-cls.pt epochs=1 imgsz=32
|
|
yolo task=classify mode=val data=imagenet10 model=runs/classify/train/weights/last.pt imgsz=32
|
|
yolo task=classify mode=predict model=runs/classify/train/weights/last.pt imgsz=32 source=ultralytics/assets/bus.jpg
|
|
yolo mode=export model=runs/classify/train/weights/last.pt imgsz=32 format=torchscript
|
|
- name: Pytest tests
|
|
shell: bash # for Windows compatibility
|
|
run: pytest tests
|