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:
Laurent Mazare
2023-09-23 21:26:03 +01:00
committed by GitHub
parent 890d069092
commit bb3471ea31
14 changed files with 31 additions and 84 deletions

View File

@ -73,9 +73,7 @@ fn main() -> Result<()> {
))
.get("model.safetensors")?,
};
let model = unsafe { candle::safetensors::MmapedFile::new(model)? };
let model = model.deserialize()?;
let vb = VarBuilder::from_safetensors(vec![model], DTYPE, &device);
let vb = unsafe { VarBuilder::from_mmaped_safetensors(&[model], DTYPE, &device)? };
let config = GenConfig::small();
let mut model = MusicgenForConditionalGeneration::load(vb, config)?;