Update ci-testing.yml (#1981)

This commit is contained in:
Glenn Jocher 2022-10-16 11:55:23 +02:00 committed by GitHub
parent 9219f135d5
commit dd838e2586
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,93 +1,99 @@
# YOLOv3 🚀 by Ultralytics, GPL-3.0 license # YOLOv3 🚀 by Ultralytics, GPL-3.0 license
# YOLOv3 Continuous Integration (CI) GitHub Actions tests
name: CI CPU testing name: YOLOv3 CI
on: # https://help.github.com/en/actions/reference/events-that-trigger-workflows on:
push: push:
branches: [ master ] branches: [ master ]
pull_request: pull_request:
# The branches below must be a subset of the branches above
branches: [ master ] branches: [ master ]
schedule: schedule:
- cron: '0 0 * * *' # Runs at 00:00 UTC every day - cron: '0 0 * * *' # runs at 00:00 UTC every day
jobs: jobs:
cpu-tests: Tests:
timeout-minutes: 60
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ ubuntu-latest, windows-latest ] os: [ ubuntu-latest, windows-latest ] # macos-latest bug https://github.com/ultralytics/yolov5/pull/9049
python-version: [ 3.9 ] python-version: [ '3.10' ]
model: [ 'yolov3-tiny' ] # models to test model: [ yolov3-tiny ]
include:
# Timeout: https://stackoverflow.com/a/59076067/4521646 - os: ubuntu-latest
timeout-minutes: 50 python-version: '3.7' # '3.6.8' min
model: yolov3-tiny
- os: ubuntu-latest
python-version: '3.8'
model: yolov3-tiny
- os: ubuntu-latest
python-version: '3.9'
model: yolov3-tiny
- os: ubuntu-latest
python-version: '3.8' # torch 1.7.0 requires python >=3.6, <=3.8
model: yolov3-tiny
torch: '1.7.0' # min torch version CI https://pypi.org/project/torchvision/
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4
uses: actions/setup-python@v4
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
- name: Get cache dir
# Note: This uses an internal pip API and may not always work # https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
- name: Get pip cache
id: pip-cache id: pip-cache
run: | run: echo "::set-output name=dir::$(pip cache dir)"
python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)"
- name: Cache pip - name: Cache pip
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: ${{ steps.pip-cache.outputs.dir }} path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('requirements.txt') }} key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: | restore-keys: ${{ runner.os }}-${{ matrix.python-version }}-pip-
${{ runner.os }}-${{ matrix.python-version }}-pip- - name: Install requirements
# Known Keras 2.7.0 issue: https://github.com/ultralytics/yolov5/pull/5486
- name: Install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip wheel
pip install -qr requirements.txt -f https://download.pytorch.org/whl/cpu/torch_stable.html if [ "${{ matrix.torch }}" == "1.7.0" ]; then
pip install -r requirements.txt torch==1.7.0 torchvision==0.8.1 --extra-index-url https://download.pytorch.org/whl/cpu
else
pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu
fi
shell: bash # for Windows compatibility
- name: Check environment
run: |
python -c "import utils; utils.notebook_init()"
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 python --version
pip --version pip --version
pip list pip list
shell: bash - name: Test detection
shell: bash # for Windows compatibility
# - name: W&B login
# run: wandb login 345011b3fb26dc8337fd9b20e53857c1d403f2aa
- name: Download data
run: |
# curl -L -o tmp.zip https://github.com/ultralytics/yolov5/releases/download/v1.0/coco128.zip
# unzip -q tmp.zip -d ../
# rm tmp.zip
- name: Tests workflow
run: | run: |
# export PYTHONPATH="$PWD" # to run '$ python *.py' files in subdirectories # export PYTHONPATH="$PWD" # to run '$ python *.py' files in subdirectories
di=cpu # device m=${{ matrix.model }} # official weights
b=runs/train/exp/weights/best # best.pt checkpoint
# Train python train.py --imgsz 64 --batch 32 --weights $m.pt --cfg $m.yaml --epochs 1 --device cpu # train
python train.py --img 64 --batch 32 --weights ${{ matrix.model }}.pt --cfg ${{ matrix.model }}.yaml --epochs 1 --device $di for d in cpu; do # devices
# Val for w in $m $b; do # weights
python val.py --img 64 --batch 32 --weights ${{ matrix.model }}.pt --device $di python val.py --imgsz 64 --batch 32 --weights $w.pt --device $d # val
python val.py --img 64 --batch 32 --weights runs/train/exp/weights/last.pt --device $di python detect.py --imgsz 64 --weights $w.pt --device $d # detect
# Detect done
python detect.py --weights ${{ matrix.model }}.pt --device $di done
python detect.py --weights runs/train/exp/weights/last.pt --device $di python hubconf.py --model $m # hub
python hubconf.py # hub # python models/tf.py --weights $m.pt # build TF model
# Export python models/yolo.py --cfg $m.yaml # build PyTorch model
python models/yolo.py --cfg ${{ matrix.model }}.yaml # build PyTorch model python export.py --weights $m.pt --img 64 --include torchscript # export
# python models/tf.py --weights ${{ matrix.model }}.pt # build TensorFlow model (YOLOv3 not supported)
python export.py --img 64 --batch 1 --weights runs/train/exp/weights/last.pt --include torchscript # export
# Python
python - <<EOF python - <<EOF
import torch import torch
# Known issue, urllib.error.HTTPError: HTTP Error 403: rate limit exceeded, will be resolved in torch==1.10.0 im = torch.zeros([1, 3, 64, 64])
# model = torch.hub.load('ultralytics/yolov3', 'custom', path='runs/train/exp/weights/last.pt') for path in '$m', '$b':
model = torch.hub.load('.', 'custom', path=path, source='local')
print(model('data/images/bus.jpg'))
model(im) # warmup, build grids for trace
torch.jit.trace(model, [im])
EOF EOF
shell: bash