mirror of
https://github.com/huggingface/candle.git
synced 2025-06-20 20:09:50 +00:00
[Wasm] BLIP Example (#1183)
* blip wasm start * fix dependency issue, move token stream here * vanilla js worker * roll back vscode * spell
This commit is contained in:
@ -2,8 +2,9 @@ use super::blip_text;
|
||||
use super::with_tracing::{conv2d, linear, Conv2d, Linear};
|
||||
use candle::{Module, Result, Tensor, D};
|
||||
use candle_nn::{layer_norm, Conv2dConfig, LayerNorm, VarBuilder};
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct VisionConfig {
|
||||
pub hidden_size: usize,
|
||||
pub intermediate_size: usize,
|
||||
@ -16,7 +17,7 @@ pub struct VisionConfig {
|
||||
pub layer_norm_eps: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Config {
|
||||
pub text_config: blip_text::Config,
|
||||
pub vision_config: VisionConfig,
|
||||
@ -299,4 +300,8 @@ impl BlipForConditionalGeneration {
|
||||
pub fn text_decoder(&mut self) -> &mut blip_text::TextLMHeadModel {
|
||||
&mut self.text_decoder
|
||||
}
|
||||
|
||||
pub fn reset_kv_cache(&mut self) {
|
||||
self.text_decoder.reset_kv_cache();
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
use super::with_tracing::{linear, Embedding, Linear};
|
||||
use candle::{Module, Result, Tensor, D};
|
||||
use candle_nn::{layer_norm, LayerNorm, VarBuilder};
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Config {
|
||||
pub vocab_size: usize,
|
||||
pub hidden_size: usize,
|
||||
|
@ -255,4 +255,7 @@ impl BlipForConditionalGeneration {
|
||||
pub fn text_decoder(&mut self) -> &mut blip_text::TextLMHeadModel {
|
||||
&mut self.text_decoder
|
||||
}
|
||||
pub fn reset_kv_cache(&mut self) {
|
||||
self.text_decoder.reset_kv_cache();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user