1- name : CI (PyTorch 1.12.1, TorchVision 0.13.1)
1+ name : CI with uv
22on :
33 push :
44 branches : [main]
55 paths-ignore :
6- - ' **.md'
7- - ' **.ipynb'
8- - ' **.cff'
6+ - " **.md"
7+ - " **.ipynb"
8+ - " **.cff"
99
1010 pull_request :
1111 branches : [main]
1212 paths-ignore :
13- - ' **.md'
14- - ' **.ipynb'
15- - ' **.cff'
13+ - " **.md"
14+ - " **.ipynb"
15+ - " **.cff"
16+
17+ schedule :
18+ - cron : " 0 0 * * *" # Runs at 00:00 UTC every day
19+
20+ workflow_dispatch : # allow running sync via github ui button
1621
1722jobs :
18- build :
23+ ci :
1924 runs-on : ubuntu-latest
2025 strategy :
2126 matrix :
22- operating-system : [ubuntu-latest, windows-latest, macos-latest]
23- python-version : [3.8, 3.9, '3.10']
24- fail-fast : false
25-
27+ python-version : ["3.8", "3.9", "3.10", "3.11", "3.12"]
2628 steps :
27- - name : Checkout
28- uses : actions/checkout@v4
29-
30- - name : Set up Python
31- uses : actions/setup-python@v5
29+ - uses : actions/checkout@v4
30+ - name : Setup uv python package manager
31+ uses : astral-sh/setup-uv@v5
3232 with :
3333 python-version : ${{ matrix.python-version }}
34-
35- - name : Restore Ubuntu cache
36- uses : actions/cache@v4
37- if : matrix.operating-system == 'ubuntu-latest'
38- with :
39- path : ~/.cache/pip
40- key : ${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/setup.py')}}
41- restore-keys : ${{ matrix.os }}-${{ matrix.python-version }}-
42-
43- - name : Restore MacOS cache
44- uses : actions/cache@v4
45- if : matrix.operating-system == 'macos-latest'
46- with :
47- path : ~/Library/Caches/pip
48- key : ${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/setup.py')}}
49- restore-keys : ${{ matrix.os }}-${{ matrix.python-version }}-
50-
51- - name : Restore Windows cache
34+ enable-cache : true
35+ prune-cache : false
36+ # For python 3.8 and 3.9, it does no suffice to install opencv-python-headless
37+ # https://itsmycode.com/importerror-libgl-so-1-cannot-open-shared-object-file-no-such-file-or-directory/
38+ - name : Cache apt packages
5239 uses : actions/cache@v4
53- if : matrix.operating-system == 'windows-latest'
40+ if : ${{ env.ACT }}
5441 with :
55- path : ~\AppData\Local\pip\Cache
56- key : ${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/setup.py')}}
57- restore-keys : ${{ matrix.os }}-${{ matrix.python-version }}-
58-
59- - name : Update pip
60- run : python -m pip install --upgrade pip
61-
62- - name : Lint with flake8, black and isort
63- run : |
64- pip install -e .[dev]
65- # stop the build if there are Python syntax errors or undefined names
66- python -m scripts.run_code_style check
67-
68- # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
69- flake8 . --exit-zero --max-complexity=10 --max-line-length=127
70-
71- - name : Install core dependencies
72- run : >
73- pip install -r requirements.txt
74-
75- - name : Install PyTorch(1.13.1) and TorchVision(0.14.1) on Linux and Windows
76- if : >
77- matrix.operating-system == 'ubuntu-latest' ||
78- matrix.operating-system == 'windows-latest'
79- run : >
80- pip install torch==1.13.1+cpu torchvision==0.14.1+cpu
81- -f https://download.pytorch.org/whl/torch_stable.html
82-
83- - name : Install PyTorch on MacOS
84- if : matrix.operating-system == 'macos-latest'
85- run : pip install torch==1.13.1 torchvision==0.14.1
86-
87- - name : Install MMDetection(3.0.0) with MMCV(2.0.0)
42+ path : /var/cache/apt
43+ key : apt-cache
44+ - name : Install libgl
45+ run : sudo apt-get update && sudo apt-get install -y libgl1
46+ - name : Setup dependencies
47+ run : uv sync
48+ - name : Install sahi from PyPI
49+ if : github.event_name == 'schedule'
8850 run : |
89- pip install mmengine==0.7.3
90- pip install mmcv==2.0.0 -f https://download.openmmlab.com/mmcv/dist/cpu/torch1.13.0/index.html
91- pip install mmdet==3.0.0
92-
93- - name : Install YOLOv5(7.0.13)
94- run : >
95- pip install yolov5==7.0.13
96-
97- - name : Install DeepSparse
98- run : >
99- pip install deepsparse
100-
101- - name : Install Transformers(4.35.0)
102- run : >
103- pip install transformers==4.35.0
104-
105- - name : Install pycocotools(2.0.7)
106- run : >
107- pip install pycocotools==2.0.7
108-
109- - name : Install ultralytics(8.3.50)
110- run : >
111- pip install ultralytics==8.3.50
112-
113- - name : Unittest for SAHI+YOLO11/RTDETR/MMDET/HuggingFace/Torchvision on all platforms
51+ rm -fr sahi
52+ uv pip install --force-reinstall sahi
53+ uv pip show sahi
54+ source .venv/bin/activate
55+ python -c "import sahi; print(sahi.__version__)"
56+ - name : Test with python ${{ matrix.python-version }}
11457 run : |
115- python -m unittest
116-
117- - name : Install SAHI package from local setup.py
118- run : >
119- pip install -e .
120-
58+ source .venv/bin/activate
59+ pytest --capture=no
12160 - name : Test SAHI CLI
12261 run : |
123- # help
124- sahi --help
125- # predict mmdet
126- sahi predict --source tests/data/ --novisual --model_path tests/data/models/mmdet/yolox/yolox_tiny_8x8_300e_coco_20211124_171234-b4047906.pth --model_config_path tests/data/models/mmdet/yolox/yolox_tiny_8xb8-300e_coco.py --image_size 320
127- sahi predict --source tests/data/coco_utils/terrain1.jpg --export_pickle --export_crop --model_path tests/data/models/mmdet/yolox/yolox_tiny_8x8_300e_coco_20211124_171234-b4047906.pth --model_config_path tests/data/models/mmdet/yolox/yolox_tiny_8xb8-300e_coco.py --image_size 320
128- sahi predict --source tests/data/coco_utils/ --novisual --dataset_json_path tests/data/coco_utils/combined_coco.json --model_path tests/data/models/mmdet/yolox/yolox_tiny_8x8_300e_coco_20211124_171234-b4047906.pth --model_config_path tests/data/models/mmdet/yolox/yolox_tiny_8xb8-300e_coco.py --image_size 320
129- # predict yolov5
62+ source .venv/bin/activate
63+ set -e
13064 sahi predict --no_sliced_prediction --model_type yolov5 --source tests/data/coco_utils/terrain1.jpg --novisual --model_path tests/data/models/yolov5/yolov5s6.pt --image_size 320
13165 sahi predict --model_type yolov5 --source tests/data/ --novisual --model_path tests/data/models/yolov5/yolov5s6.pt --image_size 320
13266 sahi predict --model_type yolov5 --source tests/data/coco_utils/terrain1.jpg --export_pickle --export_crop --model_path tests/data/models/yolov5/yolov5s6.pt --image_size 320
@@ -137,3 +71,11 @@ jobs:
13771 sahi coco evaluate --dataset_json_path tests/data/coco_evaluate/dataset.json --result_json_path tests/data/coco_evaluate/result.json
13872 # coco analyse
13973 sahi coco analyse --dataset_json_path tests/data/coco_evaluate/dataset.json --result_json_path tests/data/coco_evaluate/result.json --out_dir tests/data/coco_evaluate/
74+ - name : Test SAHI CLI with MMCV
75+ if : matrix.python-version == '3.8' || matrix.python-version == '3.9' || matrix.python-version == '3.10'
76+ run : |
77+ source .venv/bin/activate
78+ set -e
79+ sahi predict --model_type mmdet --source tests/data/ --novisual --model_path tests/data/models/mmdet/yolox/yolox_tiny_8x8_300e_coco_20211124_171234-b4047906.pth --model_config_path tests/data/models/mmdet/yolox/yolox_tiny_8xb8-300e_coco.py --image_size 320
80+ sahi predict --model_type mmdet --source tests/data/coco_utils/terrain1.jpg --export_pickle --export_crop --model_path tests/data/models/mmdet/yolox/yolox_tiny_8x8_300e_coco_20211124_171234-b4047906.pth --model_config_path tests/data/models/mmdet/yolox/yolox_tiny_8xb8-300e_coco.py --image_size 320
81+ sahi predict --model_type mmdet --source tests/data/coco_utils/ --novisual --dataset_json_path tests/data/coco_utils/combined_coco.json --model_path tests/data/models/mmdet/yolox/yolox_tiny_8x8_300e_coco_20211124_171234-b4047906.pth --model_config_path tests/data/models/mmdet/yolox/yolox_tiny_8xb8-300e_coco.py --image_size 320
0 commit comments