From 370437b67a44bd82f6a07f78ac0e0bada056eb04 Mon Sep 17 00:00:00 2001 From: Jamjamjon <51357717+jamjamjon@users.noreply.github.com> Date: Wed, 28 May 2025 17:23:33 +0800 Subject: [PATCH] Adding external data file support for ONNX models (#104) --- examples/grounding-dino/main.rs | 2 +- src/utils/ort_config.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/grounding-dino/main.rs b/examples/grounding-dino/main.rs index 1099963..1050d95 100644 --- a/examples/grounding-dino/main.rs +++ b/examples/grounding-dino/main.rs @@ -5,7 +5,7 @@ use usls::{models::GroundingDINO, Annotator, Config, DataLoader}; /// Example struct Args { /// dtype - #[argh(option, default = "String::from(\"fp16\")")] + #[argh(option, default = "String::from(\"q8\")")] dtype: String, /// device diff --git a/src/utils/ort_config.rs b/src/utils/ort_config.rs index d1c0715..0a7916d 100644 --- a/src/utils/ort_config.rs +++ b/src/utils/ort_config.rs @@ -72,6 +72,19 @@ impl ORTConfig { let stem = try_fetch_file_stem(&self.file)?; self.spec = format!("{}/{}", name, stem); 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); + } + } } } }