Add inference API to CI (#3132)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
single_channel
Glenn Jocher 2 years ago committed by GitHub
parent 9e859c949e
commit 095b856e75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 }}

Loading…
Cancel
Save