Skip to content

Commit

Permalink
It works
Browse files Browse the repository at this point in the history
  • Loading branch information
EricLBuehler committed Jun 7, 2024
1 parent 14e3f2f commit ced3cab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion mistralrs-core/src/vision_models/phi3_inputs_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,15 @@ impl ImagePreProcessor for Phi3InputsProcessor {

let hd_image = Self::hd_transform(image, config.num_crops.expect("Need `num_crops`"));

let transforms_hd2 = Transforms {
input: &ToTensor,
inner_transforms: &[],
};

// (3,h,w)
let hd_image2 = hd_image.apply(transforms_hd2, device)?;
dbg!(hd_image2);

// Both hd and global have a normalization
// Transforms for the HD image
let transforms_hd = Transforms {
Expand All @@ -394,7 +403,7 @@ impl ImagePreProcessor for Phi3InputsProcessor {

// Resize with bicubic interpolation
// (3,336,336)
let global_image = hd_image.unsqueeze(0)?.interpolate2d(336, 336)?.squeeze(0)?;
let global_image = hd_image.unsqueeze(0)?.interpolate2d(336, 336)?;

let (_, h, w) = hd_image.dims3()?;
let num_image_tokens = ((h as f32 / 336. * w as f32 / 336. + 1.) * 144.
Expand Down
2 changes: 1 addition & 1 deletion mistralrs-vision/src/transforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl ToTensor {
)
}
let row = Tensor::cat(&row_accum, 0)?;
accum.push(row.reshape((row.dim(1)?, ()))?.unsqueeze(1)?);
accum.push(row.t()?.unsqueeze(1)?);
}
let t = Tensor::cat(&accum, 1)?.to_device(device)?;
// Rescale to between 0 and 1
Expand Down

0 comments on commit ced3cab

Please sign in to comment.