tonhowtf/omniget · error
o modelo não serve para remover fundo
Error message
o modelo {model_id} não serve para remover fundo What it means
A lookup failure in `run_blocking`: `params_for(model_id)` returned None, so the given model_id is not a registered background-removal model. The tool only supports a fixed set of model ids, and any other string is rejected before a session is created.
Solutions
- Use one of the model ids supported by `params_for` (check its match arms/keys in this file)
- Validate the model_id in the UI/CLI layer against the same list before calling `run`
- If a new model was added, register it in `params_for` with its size and normalization params
- Log or surface the list of valid model ids in the error to make the typo obvious
Example fix
// before run(&opts, "isnet-general-use-v2")?; // id not registered // after let valid = params_for_keys(); // e.g. ["u2net", "isnet-general-use"] assert!(valid.contains(&"isnet-general-use")); run(&opts, "isnet-general-use")?;
Defensive patterns
Strategy: validation
Validate before calling
let supported = ["u2net", "isnet-general-use", "isnet-anime"];
if !supported.contains(&model_id) {
return Err(anyhow!("model_id '{model_id}' inválido; use um de: {supported:?}"));
} Type guard
fn is_valid_model_id(id: &str) -> bool {
params_for(id).is_some()
} Prevention
- Derive UI dropdown options from the same source as params_for
- Add a unit test asserting every exposed model_id has params
- Include the list of valid ids in the error message for easier debugging
When it happens
Trigger: Calling `run_blocking` (via `run`) with a model_id string that is not one of the keys returned by `params_for` — e.g. a typo, a model id from another tool (super-resolution, upscaling), or a user-supplied id passed through unvalidated from the UI.
Common situations: Frontend sending a model dropdown value that was renamed; config file or CLI flag holding an old model id after a rename; passing an arbitrary downloaded model filename as model_id.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- nenhuma operação escolhida
- saída do modelo com formato inesperado
- No valid cookies found in file (expected Netscape format)
- Extension playlist is
- escolha a pasta de destino para organizar
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/8e6caff3ecf7c968.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/img_bg.rs:410
let h = shape[shape.len() - 2].max(0) as u32;
let w = shape[shape.len() - 1].max(0) as u32;
let small = mask_from_raw(raw, w, h)?;
let (ow, oh) = (img.width(), img.height());
Ok(image::imageops::resize(
&small,
ow,
oh,
FilterType::Lanczos3,
))
}
fn run_blocking(
opts: &BgOptions,
model_id: &str,
progress: &ProgressFn,
) -> anyhow::Result<BgResult> {
let params = *params_for(model_id)
.ok_or_else(|| anyhow!("o modelo {model_id} não serve para remover fundo"))?;
let files = collect_inputs(&opts.inputs, &opts.input_dir);
if files.is_empty() {
return Err(anyhow!("escolha ao menos uma imagem"));
}
let background = parse_hex_color(&opts.background)?;
let ext = resolve_format(&opts.format, background.is_some(), opts.mask_only);
let mut session = super::onnx::session_for(model_id)?;
let total = files.len() as u64;
let mut items: Vec<BgItem> = Vec::with_capacity(files.len());
let mut failed = 0usize;
for (i, path) in files.iter().enumerate() {
super::report(
progress,
TOOL_ID,
"progress",
i as u64,View on GitHub (pinned to 8600b91f42)