Merge pull request #31 from MythEclipse/main
fix(ci): download model files from HF root path to correct subdirs
This commit is contained in:
@@ -65,22 +65,41 @@ jobs:
|
||||
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)
|
||||
os.makedirs('best_model', exist_ok=True)
|
||||
import os, shutil
|
||||
repo = 'MythEclipse2737/zeavis-edu-corn-leaf-classifier'
|
||||
token = os.environ['HF_TOKEN']
|
||||
base = os.path.abspath('.')
|
||||
|
||||
# ONNX (for Rust inference service)
|
||||
path = hf_hub_download(repo_id=repo, filename='model/model.onnx', token=token, local_dir='.')
|
||||
print(f'ONNX: {path}')
|
||||
# Files sit at root of HF repo → copy to correct subdirs
|
||||
# model.onnx goes to model/ for Docker COPY
|
||||
os.makedirs(os.path.join(base, 'model'), exist_ok=True)
|
||||
os.makedirs(os.path.join(base, 'best_model'), exist_ok=True)
|
||||
|
||||
# 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')
|
||||
# ONNX → model/model.onnx (Docker expects this path)
|
||||
p = hf_hub_download(repo_id=repo, filename='model.onnx', token=token)
|
||||
shutil.copy2(p, os.path.join(base, 'model', 'model.onnx'))
|
||||
print('model/model.onnx OK')
|
||||
|
||||
# TFLite (optional, for edge)
|
||||
p = hf_hub_download(repo_id=repo, filename='model.tflite', token=token)
|
||||
shutil.copy2(p, os.path.join(base, 'model', 'model.tflite'))
|
||||
print('model/model.tflite OK')
|
||||
|
||||
# Labels
|
||||
p = hf_hub_download(repo_id=repo, filename='labels.json', token=token)
|
||||
shutil.copy2(p, os.path.join(base, 'model', 'labels.json'))
|
||||
print('model/labels.json OK')
|
||||
|
||||
# Keras model + calibration for re-export
|
||||
p = hf_hub_download(repo_id=repo, filename='best_model.keras', token=token)
|
||||
shutil.copy2(p, os.path.join(base, 'best_model', 'best_model.keras'))
|
||||
print('best_model/best_model.keras OK')
|
||||
|
||||
p = hf_hub_download(repo_id=repo, filename='calibration.json', token=token)
|
||||
shutil.copy2(p, os.path.join(base, 'best_model', 'calibration.json'))
|
||||
print('best_model/calibration.json OK')
|
||||
"
|
||||
ls -lh model/model.onnx best_model/best_model.keras 2>/dev/null
|
||||
ls -lh model/model.onnx model/model.tflite model/labels.json best_model/best_model.keras 2>/dev/null
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Log in to GHCR
|
||||
|
||||
Reference in New Issue
Block a user