Upload modeling_minicpmv.py
Browse files- modeling_minicpmv.py +6 -1
modeling_minicpmv.py
CHANGED
@@ -2,6 +2,7 @@ import math
|
|
2 |
from typing import List, Optional
|
3 |
import timm
|
4 |
import torch
|
|
|
5 |
|
6 |
from PIL import Image
|
7 |
from timm.data import IMAGENET_INCEPTION_MEAN, IMAGENET_INCEPTION_STD
|
@@ -521,8 +522,12 @@ class MiniCPMVEmbedding(MiniCPMV): # MiniCPMVEmbedding -> MiniCPMV -> Ultimatel
|
|
521 |
return_dict=True
|
522 |
)
|
523 |
|
|
|
|
|
|
|
|
|
524 |
return BaseModelOutputWithAttentionMask(
|
525 |
-
last_hidden_state=
|
526 |
attention_mask=model_inputs.attention_mask
|
527 |
)
|
528 |
|
|
|
2 |
from typing import List, Optional
|
3 |
import timm
|
4 |
import torch
|
5 |
+
import torch.nn.functional as F
|
6 |
|
7 |
from PIL import Image
|
8 |
from timm.data import IMAGENET_INCEPTION_MEAN, IMAGENET_INCEPTION_STD
|
|
|
522 |
return_dict=True
|
523 |
)
|
524 |
|
525 |
+
last_hidden_state = vlm_outputs.last_hidden_state
|
526 |
+
|
527 |
+
last_hidden_state_normalized = F.normalize(last_hidden_state, dim=1)
|
528 |
+
|
529 |
return BaseModelOutputWithAttentionMask(
|
530 |
+
last_hidden_state=last_hidden_state_normalized,
|
531 |
attention_mask=model_inputs.attention_mask
|
532 |
)
|
533 |
|