update fmt
This commit is contained in:
@@ -42,7 +42,6 @@ pub struct GlmOcrRopeParameters {
|
||||
pub rope_theta: f32,
|
||||
}
|
||||
|
||||
|
||||
/// Text decoder configuration for GLM-OCR.
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize, Default)]
|
||||
pub struct GlmOcrTextConfig {
|
||||
|
||||
@@ -5,7 +5,6 @@ use aha_openai_dive::v1::resources::chat::{
|
||||
use anyhow::{Result, anyhow};
|
||||
use candle_core::{DType, Device, IndexOp, Tensor};
|
||||
use candle_nn::VarBuilder;
|
||||
use candle_transformers::utils::apply_repeat_penalty;
|
||||
use rocket::async_stream::stream;
|
||||
use rocket::futures::Stream;
|
||||
|
||||
@@ -20,7 +19,10 @@ use crate::{
|
||||
},
|
||||
},
|
||||
tokenizer::TokenizerModel,
|
||||
utils::{build_completion_chunk_response, build_completion_response, extract_user_text, find_type_files, get_device, get_dtype, get_logit_processor, img_utils::extract_image_url},
|
||||
utils::{
|
||||
build_completion_chunk_response, build_completion_response, extract_user_text,
|
||||
find_type_files, get_device, get_dtype, get_logit_processor, img_utils::extract_image_url,
|
||||
},
|
||||
};
|
||||
|
||||
pub struct GlmOcrGenerateModel {
|
||||
@@ -30,7 +32,6 @@ pub struct GlmOcrGenerateModel {
|
||||
model: GlmOcrModel,
|
||||
device: Device,
|
||||
eos_token_ids: Vec<u32>,
|
||||
generation_config: GlmOcrGenerationConfig,
|
||||
model_name: String,
|
||||
image_token_id: u32,
|
||||
image_start_token_id: u32,
|
||||
@@ -64,7 +65,6 @@ impl GlmOcrGenerateModel {
|
||||
model,
|
||||
device,
|
||||
eos_token_ids: generation_config.eos_token_id.clone(),
|
||||
generation_config,
|
||||
model_name: "glm-ocr".to_string(),
|
||||
image_token_id: cfg.image_token_id,
|
||||
image_start_token_id: cfg.image_start_token_id,
|
||||
@@ -254,6 +254,3 @@ impl GenerateModel for GlmOcrGenerateModel {
|
||||
Ok(Box::new(Box::pin(stream)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,9 +10,7 @@ use candle_nn::{
|
||||
use crate::{
|
||||
models::{
|
||||
common::GateUpDownMLP,
|
||||
glm_ocr::config::{
|
||||
GlmOcrConfig, GlmOcrTextConfig, GlmOcrVisionConfig,
|
||||
},
|
||||
glm_ocr::config::{GlmOcrConfig, GlmOcrTextConfig, GlmOcrVisionConfig},
|
||||
},
|
||||
position_embed::rope::{apply_rotary_pos_emb_vision, glm_ocr_apply_rotary_pos_emb},
|
||||
utils::tensor_utils::{prepare_causal_attention_mask, repeat_kv},
|
||||
|
||||
@@ -87,11 +87,7 @@ impl GlmOcrProcessor {
|
||||
)?;
|
||||
|
||||
// Resize image
|
||||
let img = img.resize_exact(
|
||||
target_w,
|
||||
target_h,
|
||||
image::imageops::FilterType::Lanczos3,
|
||||
);
|
||||
let img = img.resize_exact(target_w, target_h, image::imageops::FilterType::Lanczos3);
|
||||
|
||||
let target_h = target_h as usize;
|
||||
let target_w = target_w as usize;
|
||||
@@ -118,7 +114,8 @@ impl GlmOcrProcessor {
|
||||
let grid_h = target_h / self.patch_size;
|
||||
let grid_w = target_w / self.patch_size;
|
||||
let channels = 3;
|
||||
let tensor = tensor.reshape((grid_h, self.patch_size, grid_w, self.patch_size, channels))?;
|
||||
let tensor =
|
||||
tensor.reshape((grid_h, self.patch_size, grid_w, self.patch_size, channels))?;
|
||||
let tensor = tensor.permute((0, 2, 4, 1, 3))?;
|
||||
let num_patches = grid_h * grid_w;
|
||||
let tensor = tensor.reshape((num_patches, channels, self.patch_size, self.patch_size))?;
|
||||
|
||||
+1
-1
@@ -731,7 +731,7 @@ pub fn extract_user_text(mes: &ChatCompletionParameters) -> Result<String> {
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ pub fn video_smart_resize(
|
||||
Ok((h_bar, w_bar))
|
||||
}
|
||||
|
||||
|
||||
// #[allow(unused)]
|
||||
// fn save_file(
|
||||
// frame: &ffmpeg::frame::Video,
|
||||
|
||||
Reference in New Issue
Block a user