一键导入
model-distribution
Handle ONNX model distribution via Git LFS, GitHub Releases, and runtime downloading in Hope:RE
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Handle ONNX model distribution via Git LFS, GitHub Releases, and runtime downloading in Hope:RE
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | model-distribution |
| description | Handle ONNX model distribution via Git LFS, GitHub Releases, and runtime downloading in Hope:RE |
When working with ONNX model distribution in Hope:RE, follow these conventions:
Developer workflow:
src-models/notebooks/ (train in Colab)
-> src-models/models/*.onnx (export)
-> git lfs track (via .gitattributes)
-> git push (LFS pointers go to repo, binaries to LFS storage)
-> publish.yml CI (uploads .onnx files to GitHub Release as assets)
User workflow:
App launch -> check_models_status command
-> Models missing? -> Settings page shows download buttons
-> download_model command -> streams from GitHub Release
-> Stored in app_data_dir/models/
-> protect_image resolves models from this directory
.gitattributes tracks ONNX models:
src-models/models/*.onnx filter=lfs diff=lfs merge=lfs -text
Three models (~350MB each):
noise_algorithm.onnxglaze_algorithm.onnxnightshade_algorithm.onnxpublish.yml)The upload-models job runs after the publish-tauri job:
lfs: true and run git lfs pullsrc-tauri/tauri.conf.json.onnx files are real binaries (not LFS pointers)gh release upload "$TAG" src-models/models/*.onnx --clobberValidation check:
for f in src-models/models/*.onnx; do
if head -c 40 "$f" | grep -q "version https://git-lfs"; then
echo "::error::$f is an LFS pointer, not a real binary"
exit 1
fi
done
Download URL pattern:
https://github.com/HopeArtOrg/hope-re/releases/download/{version}/{model_name}
Version comes from env!("CARGO_PKG_VERSION") (compile-time from Cargo.toml).
#[tauri::command]
pub async fn check_models_status(app: AppHandle) -> Result<ModelsCheckResult, String>
Returns per-model status (exists, size_bytes) and all_ready flag. A model "exists" only if the file is present and larger than 1024 bytes (to reject empty/corrupt files).
#[tauri::command]
pub async fn download_model(app: AppHandle, model_name: String) -> Result<String, String>
Streaming download with:
reqwest client with 10-redirect limit.onnx.tmp) renamed to final path on completionmodel-download-progress#[derive(Debug, Clone, Serialize)]
struct DownloadProgress {
model_name: String,
downloaded_bytes: u64,
total_bytes: u64,
progress_percent: f64,
}
Event name: "model-download-progress", emitted via let _ = app.emit(...).
When protect_image needs a model, resolution order is:
app_data_dir/models/{model_name} (from runtime download)resource_dir/{model_name} or resource_dir/models/{model_name}CARGO_MANIFEST_DIR/../src-models/models/{model_name}Before loading any model, check if the file is a Git LFS pointer:
fn is_git_lfs_pointer(bytes: &[u8]) -> bool {
bytes.starts_with(b"version https://git-lfs.github.com/spec/")
}
If detected, return a descriptive error telling the user to run git lfs pull.
Models are stored in the platform-specific app data directory:
| Platform | Path |
|---|---|
| Windows | C:\Users\{user}\AppData\Roaming\{app}\models\ |
| macOS | ~/Library/Application Support/{app}/models/ |
| Linux | ~/.local/share/{app}/models/ |
reqwest = { version = "0.12", features = ["stream"] }
futures-util = "0.3"
tokio = { version = "1", features = ["fs", "io-util"] }
MODELS array before downloadinglet _ = app.emit(...) for non-critical progress emissionsCARGO_PKG_VERSION for release consistencyPrimary skill for the Hope:RE AI art protection desktop application. Covers project overview, Zen design language, key conventions, and common workflows.
UI/UX design intelligence for web and mobile. Includes 50+ styles, 161 color palettes, 57 font pairings, 161 product types, 99 UX guidelines, and 25 chart types across 10 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui, and HTML/CSS). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, and check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, and mobile app. Elements: button, modal, navbar, sidebar, card, table, form, and chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, and flat design. Topics: color systems, accessibility, animation, layout, typography, font pairing, spacing, interaction states, shadow, and gradient. Integrations: shadcn/ui MCP for component search and examples.
Convert JAX/Python ML models to ONNX format following the Hope:RE notebook pipeline for Google Colab
Load and run ONNX models in the Rust Tauri backend using the ort crate with platform-specific execution providers
Implement the SPSA-PGD adversarial perturbation pipeline for image protection in Rust
Create a new Svelte 5 component following Hope:RE conventions with runes, Tailwind CSS, and proper barrel exports