ci-testing.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
  2. # YOLOv5 Continuous Integration (CI) GitHub Actions tests
  3. name: YOLOv5 CI
  4. on:
  5. push:
  6. branches: [master]
  7. pull_request:
  8. branches: [master]
  9. schedule:
  10. - cron: '0 0 * * *' # runs at 00:00 UTC every day
  11. jobs:
  12. Benchmarks:
  13. runs-on: ${{ matrix.os }}
  14. strategy:
  15. matrix:
  16. os: [ubuntu-latest]
  17. python-version: [3.9]
  18. model: [yolov5n]
  19. steps:
  20. - uses: actions/checkout@v3
  21. - uses: actions/setup-python@v3
  22. with:
  23. python-version: ${{ matrix.python-version }}
  24. #- name: Cache pip
  25. # uses: actions/cache@v3
  26. # with:
  27. # path: ~/.cache/pip
  28. # key: ${{ runner.os }}-Benchmarks-${{ hashFiles('requirements.txt') }}
  29. # restore-keys: ${{ runner.os }}-Benchmarks-
  30. - name: Install requirements
  31. run: |
  32. python -m pip install --upgrade pip
  33. pip install -r requirements.txt coremltools openvino-dev tensorflow-cpu --extra-index-url https://download.pytorch.org/whl/cpu
  34. python --version
  35. pip --version
  36. pip list
  37. - name: Run benchmarks
  38. run: |
  39. python utils/benchmarks.py --weights ${{ matrix.model }}.pt --img 320
  40. Tests:
  41. timeout-minutes: 60
  42. runs-on: ${{ matrix.os }}
  43. strategy:
  44. fail-fast: false
  45. matrix:
  46. os: [ubuntu-latest, macos-latest, windows-latest]
  47. python-version: [3.9]
  48. model: [yolov5n]
  49. include:
  50. - os: ubuntu-latest
  51. python-version: '3.7' # '3.6.8' min
  52. model: yolov5n
  53. - os: ubuntu-latest
  54. python-version: '3.8'
  55. model: yolov5n
  56. - os: ubuntu-latest
  57. python-version: '3.10'
  58. model: yolov5n
  59. steps:
  60. - uses: actions/checkout@v3
  61. - uses: actions/setup-python@v3
  62. with:
  63. python-version: ${{ matrix.python-version }}
  64. - name: Get cache dir
  65. # https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
  66. id: pip-cache
  67. run: echo "::set-output name=dir::$(pip cache dir)"
  68. - name: Cache pip
  69. uses: actions/cache@v3
  70. with:
  71. path: ${{ steps.pip-cache.outputs.dir }}
  72. key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('requirements.txt') }}
  73. restore-keys: ${{ runner.os }}-${{ matrix.python-version }}-pip-
  74. - name: Install requirements
  75. run: |
  76. python -m pip install --upgrade pip
  77. pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu
  78. python --version
  79. pip --version
  80. pip list
  81. - name: Check environment
  82. run: |
  83. python -c "import utils; utils.notebook_init()"
  84. echo "RUNNER_OS is $RUNNER_OS"
  85. echo "GITHUB_EVENT_NAME is $GITHUB_EVENT_NAME"
  86. echo "GITHUB_WORKFLOW is $GITHUB_WORKFLOW"
  87. echo "GITHUB_ACTOR is $GITHUB_ACTOR"
  88. echo "GITHUB_REPOSITORY is $GITHUB_REPOSITORY"
  89. echo "GITHUB_REPOSITORY_OWNER is $GITHUB_REPOSITORY_OWNER"
  90. - name: Run tests
  91. shell: bash
  92. run: |
  93. # export PYTHONPATH="$PWD" # to run '$ python *.py' files in subdirectories
  94. d=cpu # device
  95. model=${{ matrix.model }}
  96. best=runs/train/exp/weights/best.pt
  97. # Train
  98. python train.py --img 64 --batch 32 --weights $model.pt --cfg $model.yaml --epochs 1 --device $d
  99. # Val
  100. python val.py --img 64 --batch 32 --weights $model.pt --device $d
  101. python val.py --img 64 --batch 32 --weights $best --device $d
  102. # Detect
  103. python detect.py --weights $model.pt --device $d
  104. python detect.py --weights $best --device $d
  105. python hubconf.py # hub
  106. # Export
  107. # python models/tf.py --weights $model.pt # build TF model
  108. python models/yolo.py --cfg $model.yaml # build PyTorch model
  109. python export.py --weights $model.pt --img 64 --include torchscript # export
  110. # Python
  111. python - <<EOF
  112. import torch
  113. model = torch.hub.load('.', 'custom', path='$model', source='local')
  114. print(model('data/images/bus.jpg'))
  115. model = torch.hub.load('.', 'custom', path='$best', source='local')
  116. print(model('data/images/bus.jpg'))
  117. EOF