UncleFish commited on
Commit
3c9eaa5
1 Parent(s): c2becfa

update readme

Browse files
Files changed (1) hide show
  1. README.md +5 -4
README.md CHANGED
@@ -17,6 +17,8 @@ BLIP-3 consists of 3 models: a CLIP-like image encoder, a VL connector, and a la
17
 
18
  # How to use
19
 
 
 
20
  ```python
21
  from transformers import AutoModelForVision2Seq, AutoTokenizer, AutoImageProcessor, StoppingCriteria
22
  import torch
@@ -40,9 +42,9 @@ class EosListStoppingCriteria(StoppingCriteria):
40
  return self.eos_sequence in last_ids
41
 
42
  # load models
43
- model_name_or_path = "Salesforce/blip3-phi2-r"
44
  model = AutoModelForVision2Seq.from_pretrained(model_name_or_path, trust_remote_code=True)
45
- tokenizer = AutoTokenizer.from_pretrained("./", trust_remote_code=True, use_fast=True, legacy=False)
46
  image_processor = AutoImageProcessor.from_pretrained(model_name_or_path, trust_remote_code=True)
47
  tokenizer = model.update_special_tokens(tokenizer)
48
 
@@ -57,7 +59,7 @@ prompt = apply_prompt_template(query)
57
  language_inputs = tokenizer([prompt], return_tensors="pt")
58
  inputs.update(language_inputs)
59
  inputs = {name: tensor.cuda() for name, tensor in inputs.items()}
60
- generated_text = model.generate(**inputs, image_size=[img.size],
61
  pad_token_id=tokenizer.pad_token_id,
62
  do_sample=False, max_new_tokens=768, top_p=None, num_beams=1,
63
  stopping_criteria = [EosListStoppingCriteria()],
@@ -76,7 +78,6 @@ Our code and weights are released under the Creative Commons Attribution Non Com
76
  1. If you missing any packages, please consider the followings
77
 
78
  ```
79
- pip install -U "transformers==4.40.0" --upgrade
80
  pip install torch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 --index-url https://download.pytorch.org/whl/cu121
81
  pip install open_clip_torch==2.24.0
82
  pip install einops
 
17
 
18
  # How to use
19
 
20
+ We require use the development version (`"4.41.0.dev0"`) of the `transformers` library. To get it, as of 05/07/2024, one can use `pip uninstall -y transformers && pip install git+https://github.com/huggingface/transformers`.
21
+
22
  ```python
23
  from transformers import AutoModelForVision2Seq, AutoTokenizer, AutoImageProcessor, StoppingCriteria
24
  import torch
 
42
  return self.eos_sequence in last_ids
43
 
44
  # load models
45
+ model_name_or_path = "Salesforce/blip3-phi3-3b-instruct-r-v1"
46
  model = AutoModelForVision2Seq.from_pretrained(model_name_or_path, trust_remote_code=True)
47
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=True, use_fast=True, legacy=False)
48
  image_processor = AutoImageProcessor.from_pretrained(model_name_or_path, trust_remote_code=True)
49
  tokenizer = model.update_special_tokens(tokenizer)
50
 
 
59
  language_inputs = tokenizer([prompt], return_tensors="pt")
60
  inputs.update(language_inputs)
61
  inputs = {name: tensor.cuda() for name, tensor in inputs.items()}
62
+ generated_text = model.generate(**inputs, image_size=[raw_image.size],
63
  pad_token_id=tokenizer.pad_token_id,
64
  do_sample=False, max_new_tokens=768, top_p=None, num_beams=1,
65
  stopping_criteria = [EosListStoppingCriteria()],
 
78
  1. If you missing any packages, please consider the followings
79
 
80
  ```
 
81
  pip install torch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 --index-url https://download.pytorch.org/whl/cu121
82
  pip install open_clip_torch==2.24.0
83
  pip install einops