summaryrefslogtreecommitdiff
path: root/candle-examples/examples/segment-anything/main.rs
diff options
context:
space:
mode:
authorLaurent Mazare <laurent.mazare@gmail.com>2023-09-23 21:26:03 +0100
committerGitHub <noreply@github.com>2023-09-23 21:26:03 +0100
commitbb3471ea31e637fc02106e1431d4126855ea22e1 (patch)
tree8494aec21d5f221e16432efc0865c0633466cb0b /candle-examples/examples/segment-anything/main.rs
parent890d069092a3158838b82f3d8fbdf709c84e8770 (diff)
downloadcandle-bb3471ea31e637fc02106e1431d4126855ea22e1.tar.gz
candle-bb3471ea31e637fc02106e1431d4126855ea22e1.tar.bz2
candle-bb3471ea31e637fc02106e1431d4126855ea22e1.zip
Adapt more examples to the updated safetensor api. (#947)
* Simplify the safetensor usage. * Convert more examples. * Move more examples. * Adapt stable-diffusion.
Diffstat (limited to 'candle-examples/examples/segment-anything/main.rs')
-rw-r--r--candle-examples/examples/segment-anything/main.rs4
1 files changed, 1 insertions, 3 deletions
diff --git a/candle-examples/examples/segment-anything/main.rs b/candle-examples/examples/segment-anything/main.rs
index 3d9898b6..71abe116 100644
--- a/candle-examples/examples/segment-anything/main.rs
+++ b/candle-examples/examples/segment-anything/main.rs
@@ -82,9 +82,7 @@ pub fn main() -> anyhow::Result<()> {
api.get(filename)?
}
};
- let weights = unsafe { candle::safetensors::MmapedFile::new(model)? };
- let weights = weights.deserialize()?;
- let vb = VarBuilder::from_safetensors(vec![weights], DType::F32, &device);
+ let vb = unsafe { VarBuilder::from_mmaped_safetensors(&[model], DType::F32, &device)? };
let sam = if args.use_tiny {
sam::Sam::new_tiny(vb)? // tiny vit_t
} else {