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.

120 lines
4.2KB

  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. - name: Run tests
  89. shell: bash
  90. run: |
  91. # export PYTHONPATH="$PWD" # to run '$ python *.py' files in subdirectories
  92. d=cpu # device
  93. model=${{ matrix.model }}
  94. best=runs/train/exp/weights/best.pt
  95. # Train
  96. python train.py --img 64 --batch 32 --weights $model.pt --cfg $model.yaml --epochs 1 --device $d
  97. # Val
  98. python val.py --img 64 --batch 32 --weights $model.pt --device $d
  99. python val.py --img 64 --batch 32 --weights $best --device $d
  100. # Detect
  101. python detect.py --weights $model.pt --device $d
  102. python detect.py --weights $best --device $d
  103. python hubconf.py # hub
  104. # Export
  105. # python models/tf.py --weights $model.pt # build TF model
  106. python models/yolo.py --cfg $model.yaml # build PyTorch model
  107. python export.py --weights $model.pt --img 64 --include torchscript # export
  108. # Python
  109. python - <<EOF
  110. import torch
  111. model = torch.hub.load('.', 'custom', path='$model', source='local')
  112. print(model('data/images/bus.jpg'))
  113. model = torch.hub.load('.', 'custom', path='$best', source='local')
  114. print(model('data/images/bus.jpg'))
  115. EOF