glenn-jocher pre-commit-ci[bot] commited on
Commit
2373c50
β€’
1 Parent(s): a6e99e4

Update and add benchmarks to ci-testing.yml (#7996)

Browse files

* Update and rename ci-testing.yml to ci.yml

* Update ci.yml

* Update ci.yml

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update and rename ci.yml to ci-tests.yml

* Update ci-tests.yml

* Update ci-tests.yml

* Rename ci-tests.yml to ci-testing.yml

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

Files changed (1) hide show
  1. .github/workflows/ci-testing.yml +76 -52
.github/workflows/ci-testing.yml CHANGED
@@ -1,93 +1,117 @@
1
  # YOLOv5 πŸš€ by Ultralytics, GPL-3.0 license
 
2
 
3
- name: CI CPU testing
4
 
5
- on: # https://help.github.com/en/actions/reference/events-that-trigger-workflows
6
  push:
7
- branches: [ master ]
8
  pull_request:
9
- # The branches below must be a subset of the branches above
10
- branches: [ master ]
11
  schedule:
12
- - cron: '0 0 * * *' # Runs at 00:00 UTC every day
13
 
14
  jobs:
15
- cpu-tests:
16
-
17
  runs-on: ${{ matrix.os }}
18
  strategy:
19
- fail-fast: false
20
  matrix:
21
- os: [ ubuntu-latest, macos-latest, windows-latest ]
22
- python-version: [ 3.9 ]
23
- model: [ 'yolov5n' ] # models to test
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
- # Timeout: https://stackoverflow.com/a/59076067/4521646
26
  timeout-minutes: 60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  steps:
28
  - uses: actions/checkout@v3
29
- - name: Set up Python ${{ matrix.python-version }}
30
- uses: actions/setup-python@v3
31
  with:
32
  python-version: ${{ matrix.python-version }}
33
-
34
- # Note: This uses an internal pip API and may not always work
35
- # https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
36
- - name: Get pip cache
37
  id: pip-cache
38
- run: |
39
- python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)"
40
-
41
  - name: Cache pip
42
  uses: actions/cache@v3
43
  with:
44
  path: ${{ steps.pip-cache.outputs.dir }}
45
  key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('requirements.txt') }}
46
- restore-keys: |
47
- ${{ runner.os }}-${{ matrix.python-version }}-pip-
48
-
49
- # Known Keras 2.7.0 issue: https://github.com/ultralytics/yolov5/pull/5486
50
- - name: Install dependencies
51
  run: |
52
  python -m pip install --upgrade pip
53
- pip install -qr requirements.txt -f https://download.pytorch.org/whl/cpu/torch_stable.html \
54
- onnx tensorflow-cpu # wandb
55
  python --version
56
  pip --version
57
  pip list
 
 
 
 
 
 
 
 
58
  shell: bash
59
-
60
- # - name: W&B login
61
- # run: wandb login 345011b3fb26dc8337fd9b20e53857c1d403f2aa
62
-
63
- # - name: Download data
64
- # run: |
65
- # curl -L -o tmp.zip https://github.com/ultralytics/yolov5/releases/download/v1.0/coco128.zip
66
- # unzip -q tmp.zip -d ../datasets
67
-
68
- - name: Tests workflow
69
  run: |
70
  # export PYTHONPATH="$PWD" # to run '$ python *.py' files in subdirectories
71
  d=cpu # device
72
- weights=runs/train/exp/weights/best.pt
73
-
74
  # Train
75
- python train.py --img 64 --batch 32 --weights ${{ matrix.model }}.pt --cfg ${{ matrix.model }}.yaml --epochs 1 --device $d
76
  # Val
77
- python val.py --img 64 --batch 32 --weights ${{ matrix.model }}.pt --device $d
78
- python val.py --img 64 --batch 32 --weights $weights --device $d
79
  # Detect
80
- python detect.py --weights ${{ matrix.model }}.pt --device $d
81
- python detect.py --weights $weights --device $d
82
  python hubconf.py # hub
83
  # Export
84
- python models/yolo.py --cfg ${{ matrix.model }}.yaml # build PyTorch model
85
- python models/tf.py --weights ${{ matrix.model }}.pt # build TensorFlow model
86
- python export.py --weights ${{ matrix.model }}.pt --img 64 --include torchscript onnx # export
87
  # Python
88
  python - <<EOF
89
  import torch
90
- # model = torch.hub.load('ultralytics/yolov5', 'custom', path=$weights)
 
91
  EOF
92
-
93
- shell: bash
 
1
  # YOLOv5 πŸš€ by Ultralytics, GPL-3.0 license
2
+ # YOLOv5 Continuous Integration (CI) GitHub Actions tests
3
 
4
+ name: YOLOv5 CI
5
 
6
+ on:
7
  push:
8
+ branches: [master]
9
  pull_request:
10
+ branches: [master]
 
11
  schedule:
12
+ - cron: '0 0 * * *' # runs at 00:00 UTC every day
13
 
14
  jobs:
15
+ Benchmarks:
 
16
  runs-on: ${{ matrix.os }}
17
  strategy:
 
18
  matrix:
19
+ os: [ubuntu-latest]
20
+ python-version: [3.9]
21
+ model: [yolov5n]
22
+ steps:
23
+ - uses: actions/checkout@v3
24
+ - uses: actions/setup-python@v3
25
+ with:
26
+ python-version: ${{ matrix.python-version }}
27
+ #- name: Cache pip
28
+ # uses: actions/cache@v3
29
+ # with:
30
+ # path: ~/.cache/pip
31
+ # key: ${{ runner.os }}-Benchmarks-${{ hashFiles('requirements.txt') }}
32
+ # restore-keys: ${{ runner.os }}-Benchmarks-
33
+ - name: Install requirements
34
+ run: |
35
+ python -m pip install --upgrade pip
36
+ pip install -r requirements.txt coremltools onnx onnxruntime openvino-dev tensorflow-cpu --extra-index-url https://download.pytorch.org/whl/cpu
37
+ python --version
38
+ pip --version
39
+ pip list
40
+ - name: Run benchmarks
41
+ run: |
42
+ python utils/benchmarks.py --weights ${{ matrix.model }}.pt --img 320
43
 
44
+ Tests:
45
  timeout-minutes: 60
46
+ runs-on: ${{ matrix.os }}
47
+ strategy:
48
+ fail-fast: false
49
+ matrix:
50
+ os: [ubuntu-latest, macos-latest, windows-latest]
51
+ python-version: [3.9]
52
+ model: [yolov5n]
53
+ include:
54
+ - os: ubuntu-latest
55
+ python-version: '3.7' # '3.6.8' min
56
+ model: yolov5n
57
+ - os: ubuntu-latest
58
+ python-version: '3.8'
59
+ model: yolov5n
60
+ - os: ubuntu-latest
61
+ python-version: '3.10'
62
+ model: yolov5n
63
  steps:
64
  - uses: actions/checkout@v3
65
+ - uses: actions/setup-python@v3
 
66
  with:
67
  python-version: ${{ matrix.python-version }}
68
+ - name: Get cache dir
69
+ # https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
 
 
70
  id: pip-cache
71
+ run: echo "::set-output name=dir::$(pip cache dir)"
 
 
72
  - name: Cache pip
73
  uses: actions/cache@v3
74
  with:
75
  path: ${{ steps.pip-cache.outputs.dir }}
76
  key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('requirements.txt') }}
77
+ restore-keys: ${{ runner.os }}-${{ matrix.python-version }}-pip-
78
+ - name: Install requirements
 
 
 
79
  run: |
80
  python -m pip install --upgrade pip
81
+ pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu
 
82
  python --version
83
  pip --version
84
  pip list
85
+ - name: Check environment
86
+ run: |
87
+ python -c "import utils; utils.notebook_init()"
88
+ echo "RUNNER_OS is $RUNNER_OS"
89
+ echo "GITHUB_EVENT_NAME is $GITHUB_EVENT_NAME"
90
+ echo "GITHUB_WORKFLOW is $GITHUB_WORKFLOW"
91
+ echo "GITHUB_ACTOR is $GITHUB_ACTOR"
92
+ - name: Run tests
93
  shell: bash
 
 
 
 
 
 
 
 
 
 
94
  run: |
95
  # export PYTHONPATH="$PWD" # to run '$ python *.py' files in subdirectories
96
  d=cpu # device
97
+ model=${{ matrix.model }}
98
+ best=runs/train/exp/weights/best.pt
99
  # Train
100
+ python train.py --img 64 --batch 32 --weights $model.pt --cfg $model.yaml --epochs 1 --device $d
101
  # Val
102
+ python val.py --img 64 --batch 32 --weights $model.pt --device $d
103
+ python val.py --img 64 --batch 32 --weights $best --device $d
104
  # Detect
105
+ python detect.py --weights $model.pt --device $d
106
+ python detect.py --weights $best --device $d
107
  python hubconf.py # hub
108
  # Export
109
+ # python models/tf.py --weights $model.pt # build TF model
110
+ python models/yolo.py --cfg $model.yaml # build PyTorch model
111
+ python export.py --weights $model.pt --img 64 --include torchscript # export
112
  # Python
113
  python - <<EOF
114
  import torch
115
+ model = torch.hub.load('.', 'custom', path='$model', source='local')
116
+ print(model('data/images/bus.jpg'))
117
  EOF