Skip to content

Commit

Permalink
Merge branch 'main' into oneshot-refac-initialize_model_from_path
Browse files Browse the repository at this point in the history
  • Loading branch information
horheynm authored Jan 30, 2025
2 parents 83eeb09 + 317c10c commit b319df1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/multimodal_vision/pixtral_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@

# Oneshot arguments
DATASET_ID = "flickr30k"
DATASET_SPLIT = {"calibration": "test[:512]"}
NUM_CALIBRATION_SAMPLES = 512
DATASET_SPLIT = {"calibration": f"test[:{NUM_CALIBRATION_SAMPLES}]"}
MAX_SEQUENCE_LENGTH = 2048


# Define a oneshot data collator for multimodal inputs.
# NOTE: for transformers<4.48.0, please squeeze the first dimension of `pixel_values`
# by appending `[0]` to the end of line 32
def data_collator(batch):
assert len(batch) == 1
return {
"input_ids": torch.LongTensor(batch[0]["input_ids"]),
"attention_mask": torch.tensor(batch[0]["attention_mask"]),
"pixel_values": torch.tensor(batch[0]["pixel_values"])[0],
"pixel_values": torch.tensor(batch[0]["pixel_values"]),
}


Expand Down

0 comments on commit b319df1

Please sign in to comment.