From 095b856e75299a6a84c53ae90598ca02e81fb191 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 11 Jun 2023 19:47:01 +0200 Subject: [PATCH] Add inference API to CI (#3132) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/ci.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5e9e07a..32ceff2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -56,6 +56,23 @@ jobs: hub.reset_model(model_id) model = YOLO('https://hub.ultralytics.com/models/' + model_id) model.train() + - name: Test HUB inference API + shell: python + env: + API_KEY: ${{ secrets.ULTRALYTICS_HUB_API_KEY }} + MODEL_ID: ${{ secrets.ULTRALYTICS_HUB_MODEL_ID }} + run: | + import os + import requests + import json + api_key, model_id = os.environ['API_KEY'], os.environ['MODEL_ID'] + url = f"https://api.ultralytics.com/v1/predict/{model_id}" + headers = {"x-api-key": api_key} + data = {"size": 320, "confidence": 0.25, "iou": 0.45} + with open("ultralytics/assets/zidane.jpg", "rb") as f: + response = requests.post(url, headers=headers, data=data, files={"image": f}) + assert response.status_code == 200, f'Status code {response.status_code}, Reason {response.reason}' + print(json.dumps(response.json(), indent=2)) Benchmarks: runs-on: ${{ matrix.os }}