tonhowtf/omniget · error
não carreguei o modelo
Error message
não carreguei o modelo {}: {} What it means
session_from_file wraps builder.commit_from_file(path) failure with this message. The ONNX Runtime accepted a session builder but refused to load/commit the model file at the given path. This reports the file path plus the underlying ORT error, so the ORT detail (e.g. 'no such file', 'Protobuf parsing failed') is the real diagnostic.
Solutions
- Verify the file exists and is a complete .onnx file (re-download if size looks truncated)
- Re-export the model with an opset/IR version supported by the bundled ONNX Runtime
- Confirm the path is correct and readable by the process (permissions)
- Update the bundled onnxruntime to a version matching the model's opset
Example fix
// before
let sess = onnx::session_from_file(Path::new(user_path))?; // 'não carreguei o modelo ...'
// after
let p = Path::new(user_path);
if !p.is_file() {
return Err(anyhow!("arquivo de modelo não encontrado: {}", p.display()));
}
let sess = onnx::session_from_file(p).map_err(|e| anyhow!("{e}; verifique se o arquivo é um .onnx válido"))?; Defensive patterns
Strategy: validation
Validate before calling
fn valid_model_file(p: &std::path::Path) -> bool {
use std::io::Read;
let mut f = match std::fs::File::open(p) { Ok(f) => f, Err(_) => return false };
let mut head = [0u8; 4];
f.read_exact(&mut head).is_ok() // basic existence/readability check; full validation needs ORT
&& std::fs::metadata(p).map(|m| m.len() > 0).unwrap_or(false)
} Try / catch
match onnx::session_from_file(&path) {
Err(e) if e.to_string().starts_with("não carreguei o modelo") => {
eprintln!("{e}\nVerifique se o arquivo é um modelo ONNX válido e não está truncado.");
}
other => other?,
} Prevention
- Validate downloaded model files (size/checksum) before use
- Re-download truncated models automatically
- Only accept .onnx files from user file pickers (extension filter + header check)
- Keep bundled onnxruntime version compatible with your models' opsets
When it happens
Trigger: Calling session_from_file (or session_for) with a path that does not exist, points to a corrupt/truncated .onnx file, or contains a graph unsupported by this ONNX Runtime version/opset.
Common situations: Downloaded model file truncated by an interrupted download; user points the app at a non-ONNX file (e.g. .pt or .pb); model exported with a newer opset than the bundled runtime supports.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- não montei o tensor de entrada
- não criei o builder de sessão ONNX
- o ONNX Runtime ainda não está instalado. Instale pela tela…
- não existe build oficial do ONNX Runtime para este sistema…
- não consegui carregar
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/63d271fea0cca70d.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/onnx.rs:291
crate::core::onnxrt::init()?;
session_from_file(&path)
}
/// Sessão a partir de um arquivo qualquer — útil para modelo que o usuário
/// aponta e para os testes.
pub fn session_from_file(path: &std::path::Path) -> anyhow::Result<ort::session::Session> {
use ort::session::builder::GraphOptimizationLevel;
let mut builder = ort::session::Session::builder()
.map_err(|e| anyhow!("não criei o builder de sessão ONNX: {e}"))?
// Builds mínimos do ONNX Runtime não têm otimização de grafo; nesse
// caso o `ort` devolve o próprio builder de volta, então seguimos.
.with_optimization_level(GraphOptimizationLevel::Level3)
.unwrap_or_else(|e| e.recover())
.with_intra_threads(intra_threads())
.unwrap_or_else(|e| e.recover());
builder
.commit_from_file(path)
.map_err(|e| anyhow!("não carreguei o modelo {}: {}", path.display(), e))
}
#[cfg(test)]
mod tests {
use super::*;
/// Release de onde todo modelo desta rodada sai. Fica no teste porque é
/// invariante a conferir, não valor a montar URL em tempo de execução.
const REMBG_BASE: &str = "https://github.com/danielgatis/rembg/releases/download/v0.0.0";
#[test]
fn o_catalogo_tem_id_unico_sha256_e_tamanho() {
assert!(!CATALOG.is_empty());
let mut ids: Vec<&str> = CATALOG.iter().map(|m| m.id).collect();
ids.sort_unstable();
let antes = ids.len();
ids.dedup();
assert_eq!(antes, ids.len(), "id de modelo repetido");View on GitHub (pinned to 8600b91f42)