Skip to content

Commit

Permalink
Blessed version :)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentMazare committed Sep 30, 2024
1 parent b503749 commit abe2d16
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions candle-examples/examples/pixtral/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ impl TextGeneration {
let image_embeds = self.model.vision_tower.forward(&self.image)?;
let image_embeds = self.model.multi_modal_projector.forward(&image_embeds)?;
println!("generated image embeddings {image_embeds:?}");
let image_embeds = image_embeds.to_dtype(self.model.dtype)?;
for &t in tokens.iter() {
if let Some(t) = self.tokenizer.next_token(t)? {
print!("{t}")
Expand Down Expand Up @@ -279,7 +278,7 @@ fn main() -> Result<()> {

let device = candle_examples::device(args.cpu)?;
let dtype = if device.supports_bf16() && !args.vision_only {

Check failure on line 280 in candle-examples/examples/pixtral/main.rs

View workflow job for this annotation

GitHub Actions / Clippy

this `if` has identical blocks
DType::BF16
DType::F32
} else {
DType::F32
};
Expand All @@ -303,10 +302,7 @@ fn main() -> Result<()> {
&[0.26862954, 0.261_302_6, 0.275_777_1],
)?
};
let image = image
.to_device(&device)?
.to_dtype(DType::F32)?
.unsqueeze(0)?;
let image = image.to_device(&device)?.to_dtype(dtype)?.unsqueeze(0)?;
println!("loaded image with shape {:?}", image);
let vb = unsafe { VarBuilder::from_mmaped_safetensors(&filenames, dtype, &device)? };

Expand Down

0 comments on commit abe2d16

Please sign in to comment.