mirror of
https://github.com/huggingface/candle.git
synced 2025-06-16 02:38:10 +00:00
Adapt more examples to the updated safetensor api. (#947)
* Simplify the safetensor usage. * Convert more examples. * Move more examples. * Adapt stable-diffusion.
This commit is contained in:
@ -86,9 +86,8 @@ impl Args {
|
||||
let config: Config = serde_json::from_str(&config)?;
|
||||
let tokenizer = Tokenizer::from_file(tokenizer_filename).map_err(E::msg)?;
|
||||
|
||||
let weights = unsafe { candle::safetensors::MmapedFile::new(weights_filename)? };
|
||||
let weights = weights.deserialize()?;
|
||||
let vb = VarBuilder::from_safetensors(vec![weights], DTYPE, &device);
|
||||
let vb =
|
||||
unsafe { VarBuilder::from_mmaped_safetensors(&[weights_filename], DTYPE, &device)? };
|
||||
let model = BertModel::load(vb, &config)?;
|
||||
Ok((model, tokenizer))
|
||||
}
|
||||
|
Reference in New Issue
Block a user