From 58d3feb8a0c06230e13785f83d2a390bad2f87a1 Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Fri, 12 Jun 2026 15:59:50 +0000 Subject: [PATCH] fix(ml): fix cbam_block, cardinality, Lambda serialization + update CI download to include best_model.keras MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - save_model.py: fix cbam_block channels dtype (x.shape[-1] not tf.shape) - save_model.py: match notebook architecture (Resizing + GaussianNoise) - save_model.py: load weights H5 instead of .keras (Lambda serialization safe) - notebook: add output_shape to Lambda layers for Keras 3 compatibility - notebook: fix n_bins NameError in temperature scaling plot - notebook: fix cardinality fallback (or 100 → if card > 0 else 100) - deploy.yml: download best_model.keras + calibration.json from HF - HF repo: MythEclipse2737/zeavis-edu-corn-leaf-classifier Co-Authored-By: Claude --- .github/workflows/deploy.yml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9150c5a..816eebc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -62,20 +62,25 @@ jobs: echo "HF_TOKEN is set (length: ${#HF_TOKEN})" echo "::endgroup::" - echo "::group::Download model.onnx" + echo "::group::Download model files from Hugging Face" python -c " from huggingface_hub import hf_hub_download import os os.makedirs('model', exist_ok=True) - path = hf_hub_download( - repo_id='MythEclipse2737/corn-leaf-disease-classifier', - filename='model/model.onnx', - token=os.environ['HF_TOKEN'], - local_dir='.', - ) - print(f'Downloaded: {path}') + os.makedirs('best_model', exist_ok=True) + repo = 'MythEclipse2737/zeavis-edu-corn-leaf-classifier' + token = os.environ['HF_TOKEN'] + + # ONNX (for Rust inference service) + path = hf_hub_download(repo_id=repo, filename='model/model.onnx', token=token, local_dir='.') + print(f'ONNX: {path}') + + # best_model.keras + calibration (for re-export if needed) + hf_hub_download(repo_id=repo, filename='best_model.keras', token=token, local_dir='.') + hf_hub_download(repo_id=repo, filename='calibration.json', token=token, local_dir='.') + print(f'best_model.keras and calibration.json downloaded') " - ls -lh model/model.onnx + ls -lh model/model.onnx best_model/best_model.keras 2>/dev/null echo "::endgroup::" - name: Log in to GHCR