Adding external data file support for ONNX models (#104)

This commit is contained in:
Jamjamjon
2025-05-28 17:23:33 +08:00
committed by GitHub
parent cfb92105ee
commit 370437b67a
2 changed files with 14 additions and 1 deletions

View File

@ -5,7 +5,7 @@ use usls::{models::GroundingDINO, Annotator, Config, DataLoader};
/// Example /// Example
struct Args { struct Args {
/// dtype /// dtype
#[argh(option, default = "String::from(\"fp16\")")] #[argh(option, default = "String::from(\"q8\")")]
dtype: String, dtype: String,
/// device /// device

View File

@ -72,6 +72,19 @@ impl ORTConfig {
let stem = try_fetch_file_stem(&self.file)?; let stem = try_fetch_file_stem(&self.file)?;
self.spec = format!("{}/{}", name, stem); self.spec = format!("{}/{}", name, stem);
self.file = Hub::default().try_fetch(&format!("{}/{}", name, self.file))?; self.file = Hub::default().try_fetch(&format!("{}/{}", name, self.file))?;
// try fetch external data file if it exists
match Hub::default().try_fetch(&format!("{}_data", self.file)) {
Ok(external_data_file) => {
log::debug!(
"Successfully fetched external data file: {}",
external_data_file
);
}
Err(_) => {
log::debug!("No external data file found for model {}", self.file);
}
}
} }
} }
} }