parinzee commited on
Commit
c2024bb
·
verified ·
1 Parent(s): 5ebe62e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +7 -3
README.md CHANGED
@@ -82,9 +82,13 @@ def prepare_inputs(text, has_image=False, device='cuda'):
82
  tokenize=False
83
  )
84
 
85
- text_chunks = [tokenizer(chunk).input_ids for chunk in inputs_formatted.split('<|image|>')]
86
- input_ids = torch.tensor(text_chunks[0] + [-200] + text_chunks[1][1:], dtype=torch.long).unsqueeze(0).to(device)
87
- attention_mask = torch.ones_like(input_ids).to(device)
 
 
 
 
88
 
89
  return input_ids, attention_mask
90
 
 
82
  tokenize=False
83
  )
84
 
85
+ if has_image:
86
+ text_chunks = [tokenizer(chunk).input_ids for chunk in inputs_formatted.split('<|image|>')]
87
+ input_ids = torch.tensor(text_chunks[0] + [-200] + text_chunks[1][1:], dtype=torch.long).unsqueeze(0).to(device)
88
+ attention_mask = torch.ones_like(input_ids).to(device)
89
+ else:
90
+ input_ids = torch.tensor(tokenizer(inputs_formatted).input_ids, dtype=torch.long).unsqueeze(0).to(device)
91
+ attention_mask = torch.ones_like(input_ids).to(device)
92
 
93
  return input_ids, attention_mask
94