Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova committed Nov 29, 2024
1 parent 3a02a52 commit 293e378
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,14 +554,12 @@ function default_merge_input_ids_with_image_features({
input_ids,
attention_mask,
}) {
console.log('input_ids', input_ids)
const image_tokens = input_ids.tolist().map(ids =>
ids.reduce((acc, x, idx) => {
if (x == image_token_id) acc.push(idx);
return acc;
}, [])
);
console.log('image_tokens', image_tokens)
const n_image_tokens = image_tokens.reduce((acc, x) => acc + x.length, 0);
const n_image_features = image_features.dims[0];
if (n_image_tokens !== n_image_features) {
Expand Down Expand Up @@ -617,15 +615,11 @@ async function imageTextToTextForward(self, {

if (!inputs_embeds) {
// 1. Extract the input embeddings
console.log('before encode_text');
inputs_embeds = await self.encode_text({ input_ids, ...kwargs });
console.log('after encode_text', inputs_embeds.dims);

// 2. Possibly, merge text and images
if (pixel_values && input_ids.dims[1] !== 1) {
console.log('before encode_image');
const image_features = await self.encode_image({ pixel_values, ...kwargs });
console.log('after encode_image');

({ inputs_embeds, attention_mask } = self._merge_input_ids_with_image_features({
image_features,
Expand Down

0 comments on commit 293e378

Please sign in to comment.