Depreate the VarBuilder::from_safetensors function. (#951)

This commit is contained in:
Laurent Mazare
2023-09-24 11:18:17 +01:00
committed by GitHub
parent bcb0ed8f1c
commit 4aeb449017
2 changed files with 8 additions and 5 deletions

View File

@ -21,11 +21,10 @@ pub struct Model {
#[wasm_bindgen]
impl Model {
#[wasm_bindgen(constructor)]
pub fn new(weights: &[u8], use_tiny: bool) -> Result<Model, JsError> {
pub fn new(weights: Vec<u8>, use_tiny: bool) -> Result<Model, JsError> {
console_error_panic_hook::set_once();
let dev = &Device::Cpu;
let weights = safetensors::tensor::SafeTensors::deserialize(weights)?;
let vb = VarBuilder::from_safetensors(vec![weights], DType::F32, dev);
let vb = VarBuilder::from_buffered_safetensors(weights, DType::F32, dev)?;
let sam = if use_tiny {
sam::Sam::new_tiny(vb)? // tiny vit_t
} else {