visheratin commited on
Commit
b7864ca
1 Parent(s): 418a460

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -49,11 +49,12 @@ def answer_question(image, question, max_crops, num_tokens):
49
  <|im_start|>assistant
50
  """
51
  streamer = TextIteratorStreamer(processor.tokenizer, skip_special_tokens=True)
52
- inputs = processor(prompt, [image], model, max_crops=max_crops, num_tokens=num_tokens)
 
53
  generation_kwargs = {
54
  "input_ids": inputs["input_ids"],
55
  "attention_mask": inputs["attention_mask"],
56
- "image_features": cached_vision_process(image, max_crops, num_tokens),
57
  "streamer": streamer,
58
  "max_length": 1000,
59
  "use_cache": True,
 
49
  <|im_start|>assistant
50
  """
51
  streamer = TextIteratorStreamer(processor.tokenizer, skip_special_tokens=True)
52
+ with torch.inference_mode():
53
+ inputs = processor(prompt, [image], model, max_crops=max_crops, num_tokens=num_tokens)
54
  generation_kwargs = {
55
  "input_ids": inputs["input_ids"],
56
  "attention_mask": inputs["attention_mask"],
57
+ "image_features": inputs["image_features"],
58
  "streamer": streamer,
59
  "max_length": 1000,
60
  "use_cache": True,