File size: 3,500 Bytes
24bea5e
 
94b2bb6
 
5bab9a2
5414e53
94705a9
5414e53
b53c8ac
94705a9
b161edf
 
94b2bb6
 
a0fa5f5
94b2bb6
 
 
 
 
94705a9
e80a09b
26784af
94b2bb6
 
ff8646c
94b2bb6
a5a1760
5414e53
c8a5899
5414e53
 
94b2bb6
5414e53
 
 
 
 
 
94b2bb6
5414e53
8277033
5414e53
 
 
 
 
94b2bb6
34b859a
5414e53
 
 
 
540ef0d
5414e53
 
 
 
94b2bb6
540ef0d
 
 
ff8646c
 
 
 
7d8e2dd
5414e53
 
a12698f
ff8646c
 
5414e53
94705a9
ff8646c
94705a9
ff8646c
 
94705a9
ff8646c
 
9a3da79
94705a9
c3a93d7
 
ff8646c
94705a9
 
 
ff8646c
94705a9
 
5414e53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

name: CI CPU testing

on: # https://help.github.com/en/actions/reference/events-that-trigger-workflows
  push:
    branches: [ master ]
  pull_request:
    # The branches below must be a subset of the branches above
    branches: [ master ]
  schedule:
    - cron: '0 0 * * *'  # Runs at 00:00 UTC every day

jobs:
  cpu-tests:

    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ ubuntu-latest, macos-latest, windows-latest ]
        python-version: [ 3.9 ]
        model: [ 'yolov5n' ]  # models to test

    # Timeout: https://stackoverflow.com/a/59076067/4521646
    timeout-minutes: 60
    steps:
      - uses: actions/checkout@v3
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v3
        with:
          python-version: ${{ matrix.python-version }}

      # 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
      - name: Get pip cache
        id: pip-cache
        run: |
          python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)"

      - name: Cache pip
        uses: actions/[email protected]
        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-

      # Known Keras 2.7.0 issue: https://github.com/ultralytics/yolov5/pull/5486
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -qr requirements.txt -f https://download.pytorch.org/whl/cpu/torch_stable.html
          pip install -q onnx tensorflow-cpu keras==2.6.0  # wandb  # extras
          python --version
          pip --version
          pip list
        shell: bash

      # - 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 ../datasets

      - name: Tests workflow
        run: |
          # export PYTHONPATH="$PWD"  # to run '$ python *.py' files in subdirectories
          d=cpu  # device
          weights=runs/train/exp/weights/best.pt

          # Train
          python train.py --img 64 --batch 32 --weights ${{ matrix.model }}.pt --cfg ${{ matrix.model }}.yaml --epochs 1 --device $d
          # Val
          python val.py --img 64 --batch 32 --weights ${{ matrix.model }}.pt --device $d
          python val.py --img 64 --batch 32 --weights $weights --device $d
          # Detect
          python detect.py --weights ${{ matrix.model }}.pt --device $d
          python detect.py --weights $weights --device $d
          python hubconf.py  # hub
          # Export
          python models/yolo.py --cfg ${{ matrix.model }}.yaml  # build PyTorch model
          python models/tf.py --weights ${{ matrix.model }}.pt  # build TensorFlow model
          python export.py --weights ${{ matrix.model }}.pt --img 64 --include torchscript onnx  # export
          # Python
          python - <<EOF
          import torch
          # model = torch.hub.load('ultralytics/yolov5', 'custom', path=$weights)
          EOF

        shell: bash