mirror of
https://github.com/THU-MIG/yolov10.git
synced 2025-05-23 13:34:23 +08:00
Add inference API to CI (#3132)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
9e859c949e
commit
095b856e75
17
.github/workflows/ci.yaml
vendored
17
.github/workflows/ci.yaml
vendored
@ -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…
x
Reference in New Issue
Block a user