File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,52 +13,33 @@ jobs:
1313 build_test_push :
1414 name : Build, Test & Push Model
1515 runs-on : ubuntu-latest
16+ strategy :
17+ matrix :
18+ model : [yolo11n]
1619 steps :
17- # - name: Cleanup disk space
18- # uses: ultralytics/actions/cleanup-disk@main
19-
2020 - name : Checkout
2121 uses : actions/checkout@v4
22-
2322 - name : Setup Python
2423 uses : actions/setup-python@v5
2524 with :
2625 python-version : 3.12
27-
2826 - name : Setup uv
2927 uses : astral-sh/setup-uv@v6
30-
3128 - name : Install dependencies
3229 run : uv pip install --system ultralytics --extra-index-url https://download.pytorch.org/whl/cpu
33-
3430 - name : Setup Cog
3531 uses : replicate/setup-cog@v2
3632 with :
3733 token : ${{ secrets.REPLICATE_API_TOKEN }}
38-
3934 - name : Download YOLO11n weights
40- run : |
41- python << 'EOF'
42- from ultralytics import YOLO
43- model = YOLO('yolo11n.pt')
44- EOF
45- ls -la yolo11n*
46- mv yolo11n.pt yolo11n/
47- echo "Files in yolo11n directory:"
48- ls -la yolo11n/
49-
35+ run : python ${{ matrix.model }}/download.py
5036 - name : Build model image
51- run : |
52- cd yolo11n
53- cog build
54-
37+ working-directory : ${{ matrix.model }}
38+ run : cog build
5539 - name : Test model
56- run : |
57- cd yolo11n
58- cog predict -i image=@../assets/bus.jpg -i conf=0.25 -i iou=0.45
59-
40+ working-directory : ${{ matrix.model }}
41+ run : cog predict -i image=@../assets/bus.jpg -i conf=0.25 -i iou=0.45
6042 - name : Push to Replicate
6143 if : github.ref == 'refs/heads/main'
62- run : |
63- cd yolo11n
64- cog push
44+ working-directory : ${{ matrix.model }}
45+ run : cog push
Original file line number Diff line number Diff line change 99 - " ffmpeg"
1010 python_packages :
1111 - " ultralytics>=8.3.0"
12- - " torch==2.3.1"
13- - " torchvision"
14- - " numpy>=1.24.0"
15- - " opencv-python"
16- - " pillow"
1712
1813predict : predict.py:Predictor
1914image : r8.im/ultralytics/yolo11n
Original file line number Diff line number Diff line change 1+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2+
3+ from pathlib import Path
4+
5+ from ultralytics import YOLO
6+
7+
8+ def main ():
9+ """Download YOLO11n weights and move to model directory."""
10+ current_dir = Path (__file__ ).parent
11+ YOLO (current_dir / "yolo11n.pt" )
12+
13+ # List files in model directory
14+ print (f"Files in { current_dir .name } directory:" )
15+ for file in sorted (current_dir .iterdir ()):
16+ print (f" { file .stat ().st_size :>10} { file .name } " )
17+
18+
19+ if __name__ == "__main__" :
20+ main ()
Original file line number Diff line number Diff line change 11# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
22
3- import json
43from typing import Optional
4+
5+ from cog import BaseModel , BasePredictor , Input , Path
56from ultralytics import YOLO
6- from cog import BasePredictor , Input , Path , BaseModel
77
88
99class Output (BaseModel ):
@@ -32,9 +32,6 @@ def predict(
3232 result .save (image_path )
3333
3434 if return_json :
35- return Output (
36- image = Path (image_path ),
37- json_str = result .to_json ()
38- )
35+ return Output (image = Path (image_path ), json_str = result .to_json ())
3936 else :
4037 return Output (image = Path (image_path ))
You can’t perform that action at this time.
0 commit comments