Skip to content

Fix Replicate README badge rendering and apply Codex review fixes #149

Fix Replicate README badge rendering and apply Codex review fixes

Fix Replicate README badge rendering and apply Codex review fixes #149

Workflow file for this run

# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
name: Push YOLO to Replicate
permissions:
contents: read
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
build_test_push:
name: Build, Test & Push Model
runs-on: ubuntu-latest
env:
# Job-level so the composite retry action (Sync metadata) reliably inherits it.
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
strategy:
fail-fast: false
matrix:
model: [yolo11n, yolov8s-worldv2, yoloe11s, yolo26/detect, yolo26/seg, yolo26/sem, yolo26/cls, yolo26/pose, yolo26/obb]
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: 3.12
- name: Setup uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
uses: ultralytics/actions/retry@main
with:
run: uv pip install --system ultralytics --extra-index-url https://download.pytorch.org/whl/cpu
- name: Setup Cog
uses: replicate/setup-cog@v2
with:
token: ${{ secrets.REPLICATE_API_TOKEN }}
- name: Download model weights
uses: ultralytics/actions/retry@main
with:
run: python ${{ matrix.model }}/download.py
- name: Build model image
uses: ultralytics/actions/retry@main
with:
run: cd ${{ matrix.model }} && cog build
- name: Test model
working-directory: ${{ matrix.model }}
# `cog predict` exits 0 even when the prediction raises, so capture output and fail on a traceback.
run: |
set -o pipefail
cog predict -i image=@"$GITHUB_WORKSPACE/assets/bus.jpg" -i conf=0.25 -i iou=0.45 -i return_json=true 2>&1 | tee predict.log
if grep -q "Traceback (most recent call last)" predict.log; then
echo "::error::cog predict raised an exception (see log above)"
exit 1
fi
- name: Sync Replicate model metadata
# Creates the model if missing (so `cog push` succeeds) and syncs description/readme/links/cover.
if: github.ref == 'refs/heads/main'
uses: ultralytics/actions/retry@main
with:
run: python replicate_metadata.py --dir "${{ matrix.model }}"
- name: Push to Replicate
if: github.ref == 'refs/heads/main'
uses: ultralytics/actions/retry@main
with:
run: cd ${{ matrix.model }} && cog push