-
Notifications
You must be signed in to change notification settings - Fork 0
41 lines (34 loc) · 1.33 KB
/
Copy pathci.yml
File metadata and controls
41 lines (34 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
smoke:
name: Prediction smoke test
runs-on: ubuntu-latest
steps:
- name: Check out repository (with Git LFS weights)
uses: actions/checkout@v4
with:
lfs: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
- name: Install dependencies
run: pip install -r requirements.txt
- name: Predict on the bundled sample image
working-directory: classifier
run: |
# env.sh adds the repo root to PYTHONPATH and exports TF_USE_LEGACY_KERAS=1
. ./env.sh
export TF_CPP_MIN_LOG_LEVEL=3
out=$(python predict_cls.py --in_path ../sample_image/monarch_jpeg_q20.png --comp_type jpeg_paper)
echo "$out"
# The sample is JPEG quality 20, so the prediction must be close to 20.
echo "$out" | grep -q "predicted quality" || { echo "::error::no prediction output"; exit 1; }
q=$(echo "$out" | sed -n 's/.*predicted quality \([0-9.]*\).*/\1/p' | tail -1)
python -c "import sys; q=float('$q'); print('parsed quality:', q); sys.exit(0 if 18.0 <= q <= 22.0 else 1)" \
|| { echo "::error::predicted quality '$q' outside expected range [18, 22]"; exit 1; }