DongfuJiang commited on
Commit
03b5d97
1 Parent(s): 2fe2ee4
Files changed (1) hide show
  1. app_regression.py +11 -12
app_regression.py CHANGED
@@ -14,8 +14,8 @@ from models.conversation import conv_templates
14
  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).eval()
19
 
20
  MAX_NUM_FRAMES = 24
21
  conv_template = conv_templates["idefics_2"]
@@ -64,14 +64,13 @@ all the frames of video are as follows:
64
  """
65
 
66
 
67
- aspect_mapping={
68
- 1:"visual quality",
69
- 2:"object consistency",
70
- 3:"dynamic degree",
71
- 4:"motion smoothness",
72
- 5:'text-to-video alignment',
73
- 6:'factual consistency',
74
- }
75
 
76
 
77
  @spaces.GPU(duration=60)
@@ -97,11 +96,11 @@ def score(prompt:str, images:List[Image.Image]):
97
 
98
  logits = outputs.logits
99
  num_aspects = logits.shape[-1]
100
- aspects = [aspect_mapping[i+1] for i in range(num_aspects)]
101
 
102
  aspect_scores = {}
103
  for i, aspect in enumerate(aspects):
104
- aspect_scores[aspect] = logits[0, i].item()
105
  return aspect_scores
106
 
107
 
 
14
  from typing import List
15
 
16
 
17
+ processor = AutoProcessor.from_pretrained("Mantis-VL/mantis-8b-idefics2-video-eval-40k-mantis-2epoch_4096_regression")
18
+ model = Idefics2ForSequenceClassification.from_pretrained("Mantis-VL/mantis-8b-idefics2-video-eval-40k-mantis-2epoch_4096_regression", torch_dtype=torch.bfloat16).eval()
19
 
20
  MAX_NUM_FRAMES = 24
21
  conv_template = conv_templates["idefics_2"]
 
64
  """
65
 
66
 
67
+ aspect_mapping= [
68
+ "visual quality",
69
+ "temporal consistency",
70
+ "dynamic degree",
71
+ "text-to-video alignment",
72
+ "factual consistency",
73
+ ]
 
74
 
75
 
76
  @spaces.GPU(duration=60)
 
96
 
97
  logits = outputs.logits
98
  num_aspects = logits.shape[-1]
99
+ aspects = [aspect_mapping[i] for i in range(num_aspects)]
100
 
101
  aspect_scores = {}
102
  for i, aspect in enumerate(aspects):
103
+ aspect_scores[aspect] = round(logits[0, i].item(), 2)
104
  return aspect_scores
105
 
106