DongfuJiang commited on
Commit
a5a9bfc
1 Parent(s): df7a5b3
Files changed (1) hide show
  1. app_regression.py +4 -5
app_regression.py CHANGED
@@ -15,10 +15,9 @@ from typing import List
15
 
16
 
17
  processor = AutoProcessor.from_pretrained("Mantis-VL/mantis-8b-idefics2-video-eval-20k-mantis-2epoch_4096_regression")
18
- model = Idefics2ForSequenceClassification.from_pretrained("Mantis-VL/mantis-8b-idefics2-video-eval-20k-mantis-2epoch_4096_regression", torch_dtype=torch.bfloat16)
19
- model.eval()
20
 
21
- MAX_NUM_FRAMES = 8
22
  conv_template = conv_templates["idefics_2"]
23
 
24
  with open("./examples/all_subsets.json", 'r') as f:
@@ -92,9 +91,9 @@ def score(prompt:str, images:List[Image.Image]):
92
 
93
  flatten_images = [Image.open(x) if isinstance(x, str) else x for x in flatten_images]
94
  inputs = processor(text=prompt, images=flatten_images, return_tensors="pt")
95
- print(processor.tokenizer.decode(inputs["input_ids"][0], skip_special_tokens=False))
96
  inputs = {k: v.to(model.device) for k, v in inputs.items()}
97
- outputs = model(**inputs)
 
98
 
99
  logits = outputs.logits
100
  num_aspects = logits.shape[-1]
 
15
 
16
 
17
  processor = AutoProcessor.from_pretrained("Mantis-VL/mantis-8b-idefics2-video-eval-20k-mantis-2epoch_4096_regression")
18
+ model = Idefics2ForSequenceClassification.from_pretrained("Mantis-VL/mantis-8b-idefics2-video-eval-20k-mantis-2epoch_4096_regression", torch_dtype=torch.bfloat16).eval()
 
19
 
20
+ MAX_NUM_FRAMES = 16
21
  conv_template = conv_templates["idefics_2"]
22
 
23
  with open("./examples/all_subsets.json", 'r') as f:
 
91
 
92
  flatten_images = [Image.open(x) if isinstance(x, str) else x for x in flatten_images]
93
  inputs = processor(text=prompt, images=flatten_images, return_tensors="pt")
 
94
  inputs = {k: v.to(model.device) for k, v in inputs.items()}
95
+ with torch.no_grad():
96
+ outputs = model(**inputs)
97
 
98
  logits = outputs.logits
99
  num_aspects = logits.shape[-1]