Rename OneVision* -> CoVisco* classes and unify config field to covisco_encoder_cfg (weights unchanged)
Browse files- config.json +1 -1
- covisco_model.py +10 -10
- covisco_vit.py +37 -37
- load_covisco.py +1 -1
config.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
| 7 |
},
|
| 8 |
"model_name": "CoVisco-L-14",
|
| 9 |
"description": "CoVisco vision encoder (Stage 1): a unified image/video ViT-L/14 distilled from SigLIP2 and Qwen3-VL-Embedding teachers.",
|
| 10 |
-
"
|
| 11 |
"output_dim": 1024,
|
| 12 |
"hidden_size": 1024,
|
| 13 |
"intermediate_size": 4096,
|
|
|
|
| 7 |
},
|
| 8 |
"model_name": "CoVisco-L-14",
|
| 9 |
"description": "CoVisco vision encoder (Stage 1): a unified image/video ViT-L/14 distilled from SigLIP2 and Qwen3-VL-Embedding teachers.",
|
| 10 |
+
"covisco_encoder_cfg": {
|
| 11 |
"output_dim": 1024,
|
| 12 |
"hidden_size": 1024,
|
| 13 |
"intermediate_size": 4096,
|
covisco_model.py
CHANGED
|
@@ -25,10 +25,10 @@ from transformers.modeling_utils import PreTrainedModel
|
|
| 25 |
# as a HuggingFace dynamic module loaded via trust_remote_code (relative import,
|
| 26 |
# which is what the auto_map in config.json resolves to).
|
| 27 |
try: # package / trust_remote_code context
|
| 28 |
-
from .covisco_vit import
|
| 29 |
from .reconstruction_decoder import ReconstructionDecoder
|
| 30 |
except ImportError: # flat script context
|
| 31 |
-
from covisco_vit import
|
| 32 |
from reconstruction_decoder import ReconstructionDecoder
|
| 33 |
|
| 34 |
|
|
@@ -36,8 +36,8 @@ class CoViscoConfig(PretrainedConfig):
|
|
| 36 |
"""Config for :class:`CoViscoModel`.
|
| 37 |
|
| 38 |
Keeps the released ``config.json`` layout unchanged: three nested dicts
|
| 39 |
-
(``
|
| 40 |
-
rebuilds an ``
|
| 41 |
reads head dims / logit inits from ``covisco_cfg``.
|
| 42 |
"""
|
| 43 |
|
|
@@ -45,13 +45,13 @@ class CoViscoConfig(PretrainedConfig):
|
|
| 45 |
|
| 46 |
def __init__(
|
| 47 |
self,
|
| 48 |
-
|
| 49 |
covisco_cfg=None,
|
| 50 |
preprocess_cfg=None,
|
| 51 |
**kwargs,
|
| 52 |
):
|
| 53 |
super().__init__(**kwargs)
|
| 54 |
-
self.
|
| 55 |
self.covisco_cfg = covisco_cfg or {}
|
| 56 |
self.preprocess_cfg = preprocess_cfg or {}
|
| 57 |
|
|
@@ -83,7 +83,7 @@ class CoViscoModel(PreTrainedModel):
|
|
| 83 |
``AutoModel.from_pretrained(dir, trust_remote_code=True)``.
|
| 84 |
|
| 85 |
All architecture args come from a :class:`CoViscoConfig`:
|
| 86 |
-
* ``config.
|
| 87 |
* ``config.covisco_cfg`` -> head dims, reconstruction flag, logit inits
|
| 88 |
"""
|
| 89 |
|
|
@@ -91,19 +91,19 @@ class CoViscoModel(PreTrainedModel):
|
|
| 91 |
base_model_prefix = "covisco"
|
| 92 |
main_input_name = "pixel_values"
|
| 93 |
supports_gradient_checkpointing = True
|
| 94 |
-
_no_split_modules = ["
|
| 95 |
|
| 96 |
def __init__(self, config: CoViscoConfig):
|
| 97 |
super().__init__(config)
|
| 98 |
|
| 99 |
-
onevision_config =
|
| 100 |
ccfg = config.covisco_cfg
|
| 101 |
|
| 102 |
self.hidden_size = onevision_config.hidden_size
|
| 103 |
self.num_query_per_seg = onevision_config.num_query_per_seg
|
| 104 |
|
| 105 |
# 1. OneVision Encoder (trainable)
|
| 106 |
-
self.encoder =
|
| 107 |
# Create a visual attribute for compatibility with factory code
|
| 108 |
self.visual = self.encoder
|
| 109 |
|
|
|
|
| 25 |
# as a HuggingFace dynamic module loaded via trust_remote_code (relative import,
|
| 26 |
# which is what the auto_map in config.json resolves to).
|
| 27 |
try: # package / trust_remote_code context
|
| 28 |
+
from .covisco_vit import CoViscoEncoderModel, CoViscoEncoderConfig
|
| 29 |
from .reconstruction_decoder import ReconstructionDecoder
|
| 30 |
except ImportError: # flat script context
|
| 31 |
+
from covisco_vit import CoViscoEncoderModel, CoViscoEncoderConfig
|
| 32 |
from reconstruction_decoder import ReconstructionDecoder
|
| 33 |
|
| 34 |
|
|
|
|
| 36 |
"""Config for :class:`CoViscoModel`.
|
| 37 |
|
| 38 |
Keeps the released ``config.json`` layout unchanged: three nested dicts
|
| 39 |
+
(``covisco_encoder_cfg``, ``covisco_cfg``, ``preprocess_cfg``). The model
|
| 40 |
+
rebuilds an ``CoViscoEncoderConfig`` from ``covisco_encoder_cfg`` and
|
| 41 |
reads head dims / logit inits from ``covisco_cfg``.
|
| 42 |
"""
|
| 43 |
|
|
|
|
| 45 |
|
| 46 |
def __init__(
|
| 47 |
self,
|
| 48 |
+
covisco_encoder_cfg=None,
|
| 49 |
covisco_cfg=None,
|
| 50 |
preprocess_cfg=None,
|
| 51 |
**kwargs,
|
| 52 |
):
|
| 53 |
super().__init__(**kwargs)
|
| 54 |
+
self.covisco_encoder_cfg = covisco_encoder_cfg or {}
|
| 55 |
self.covisco_cfg = covisco_cfg or {}
|
| 56 |
self.preprocess_cfg = preprocess_cfg or {}
|
| 57 |
|
|
|
|
| 83 |
``AutoModel.from_pretrained(dir, trust_remote_code=True)``.
|
| 84 |
|
| 85 |
All architecture args come from a :class:`CoViscoConfig`:
|
| 86 |
+
* ``config.covisco_encoder_cfg`` -> CoViscoEncoderConfig for the encoder
|
| 87 |
* ``config.covisco_cfg`` -> head dims, reconstruction flag, logit inits
|
| 88 |
"""
|
| 89 |
|
|
|
|
| 91 |
base_model_prefix = "covisco"
|
| 92 |
main_input_name = "pixel_values"
|
| 93 |
supports_gradient_checkpointing = True
|
| 94 |
+
_no_split_modules = ["CoViscoEncoderEncoderLayer"]
|
| 95 |
|
| 96 |
def __init__(self, config: CoViscoConfig):
|
| 97 |
super().__init__(config)
|
| 98 |
|
| 99 |
+
onevision_config = CoViscoEncoderConfig(**config.covisco_encoder_cfg)
|
| 100 |
ccfg = config.covisco_cfg
|
| 101 |
|
| 102 |
self.hidden_size = onevision_config.hidden_size
|
| 103 |
self.num_query_per_seg = onevision_config.num_query_per_seg
|
| 104 |
|
| 105 |
# 1. OneVision Encoder (trainable)
|
| 106 |
+
self.encoder = CoViscoEncoderModel(onevision_config)
|
| 107 |
# Create a visual attribute for compatibility with factory code
|
| 108 |
self.visual = self.encoder
|
| 109 |
|
covisco_vit.py
CHANGED
|
@@ -13,7 +13,7 @@ from transformers.utils import (
|
|
| 13 |
replace_return_docstrings,
|
| 14 |
)
|
| 15 |
|
| 16 |
-
# from .
|
| 17 |
|
| 18 |
from transformers.configuration_utils import PretrainedConfig
|
| 19 |
from transformers.utils import logging
|
|
@@ -22,9 +22,9 @@ from random import randint
|
|
| 22 |
logger = logging.get_logger(__name__)
|
| 23 |
|
| 24 |
|
| 25 |
-
class
|
| 26 |
r"""
|
| 27 |
-
This is the configuration class to store the configuration of a [`
|
| 28 |
OneVision Encoder model according to the specified arguments, defining the model architecture. Instantiating a configuration
|
| 29 |
with the defaults will yield a similar configuration to that of the OneVision Encoder architecture.
|
| 30 |
|
|
@@ -64,21 +64,21 @@ class OneVisionEncoderConfig(PretrainedConfig):
|
|
| 64 |
Example:
|
| 65 |
|
| 66 |
```python
|
| 67 |
-
>>> from
|
| 68 |
-
>>> from
|
| 69 |
|
| 70 |
-
>>> # Initializing a
|
| 71 |
-
>>> configuration =
|
| 72 |
|
| 73 |
>>> # Initializing a model (with random weights) from the configuration
|
| 74 |
-
>>> model =
|
| 75 |
|
| 76 |
>>> # Accessing the model configuration
|
| 77 |
>>> configuration = model.config
|
| 78 |
```
|
| 79 |
"""
|
| 80 |
|
| 81 |
-
model_type = "
|
| 82 |
|
| 83 |
def __init__(
|
| 84 |
self,
|
|
@@ -154,7 +154,7 @@ ONEVISION_ENCODER_START_DOCSTRING = r"""
|
|
| 154 |
and behavior.
|
| 155 |
|
| 156 |
Parameters:
|
| 157 |
-
config ([`
|
| 158 |
Initializing with a config file does not load the weights associated with the model, only the
|
| 159 |
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
|
| 160 |
"""
|
|
@@ -222,7 +222,7 @@ class SegmentVideoRotaryEmbeddingSplit2455(nn.Module):
|
|
| 222 |
Adds segment dimension to the existing VideoRotaryEmbeddingSplit466.
|
| 223 |
"""
|
| 224 |
|
| 225 |
-
def __init__(self, config:
|
| 226 |
super().__init__()
|
| 227 |
head_dim = config.hidden_size // config.num_attention_heads
|
| 228 |
base = config.rope_theta
|
|
@@ -319,7 +319,7 @@ class VideoRotaryEmbeddingSplit466(nn.Module):
|
|
| 319 |
3D (T,H,W) Rotary frequency constructor with 4:6:6 split.
|
| 320 |
"""
|
| 321 |
|
| 322 |
-
def __init__(self, config:
|
| 323 |
super().__init__()
|
| 324 |
head_dim = config.hidden_size // config.num_attention_heads
|
| 325 |
base = config.rope_theta
|
|
@@ -404,7 +404,7 @@ class Siglip2MultiheadAttentionPoolingHead(nn.Module):
|
|
| 404 |
Multi-Head Attention Pooling with a learned probe (PMA-style).
|
| 405 |
"""
|
| 406 |
|
| 407 |
-
def __init__(self, config:
|
| 408 |
super().__init__()
|
| 409 |
self.embed_dim = config.hidden_size
|
| 410 |
self.probe = nn.Parameter(torch.randn(1, 1, config.hidden_size))
|
|
@@ -442,8 +442,8 @@ def extract_patches(x, p):
|
|
| 442 |
return patches
|
| 443 |
|
| 444 |
|
| 445 |
-
class
|
| 446 |
-
def __init__(self, config:
|
| 447 |
super().__init__()
|
| 448 |
self.config = config
|
| 449 |
self.embed_dim = config.hidden_size
|
|
@@ -479,10 +479,10 @@ class OneVisionEncoderEmbeddings(nn.Module):
|
|
| 479 |
return embeddings
|
| 480 |
|
| 481 |
|
| 482 |
-
class
|
| 483 |
"""Multi-headed attention with RoPE support"""
|
| 484 |
|
| 485 |
-
def __init__(self, config:
|
| 486 |
super().__init__()
|
| 487 |
self.config = config
|
| 488 |
self.embed_dim = config.hidden_size
|
|
@@ -556,14 +556,14 @@ class OneVisionEncoderAttention(nn.Module):
|
|
| 556 |
return attn_output, attn_weights if output_attentions else None
|
| 557 |
|
| 558 |
|
| 559 |
-
class
|
| 560 |
"""
|
| 561 |
Multi-headed attention with RoPE support using Flash Attention 2.
|
| 562 |
-
This module implements the same attention mechanism as
|
| 563 |
Flash Attention for improved performance and memory efficiency.
|
| 564 |
"""
|
| 565 |
|
| 566 |
-
def __init__(self, config:
|
| 567 |
super().__init__()
|
| 568 |
self.config = config
|
| 569 |
self.embed_dim = config.hidden_size
|
|
@@ -624,7 +624,7 @@ class OneVisionEncoderFlashAttention2(nn.Module):
|
|
| 624 |
# value_states = torch.cat((context_kv_cache[1], value_states), dim=1)
|
| 625 |
# Flash Attention forward pass
|
| 626 |
if not _flash_attn_available:
|
| 627 |
-
raise ImportError("flash_attn is not installed. Please install it to use
|
| 628 |
|
| 629 |
attn_output = flash_attn_func(
|
| 630 |
query_states,
|
|
@@ -646,13 +646,13 @@ class OneVisionEncoderFlashAttention2(nn.Module):
|
|
| 646 |
|
| 647 |
|
| 648 |
ONEVISION_ENCODER_ATTENTION_CLASSES = {
|
| 649 |
-
"eager":
|
| 650 |
-
"flash_attention_2":
|
| 651 |
}
|
| 652 |
|
| 653 |
|
| 654 |
-
class
|
| 655 |
-
def __init__(self, config:
|
| 656 |
super().__init__()
|
| 657 |
self.embed_dim = config.hidden_size
|
| 658 |
self.num_query_per_seg=config.num_query_per_seg
|
|
@@ -748,11 +748,11 @@ class OneVisionEncoderEncoderLayer(nn.Module):
|
|
| 748 |
return outputs
|
| 749 |
|
| 750 |
|
| 751 |
-
class
|
| 752 |
-
def __init__(self, config:
|
| 753 |
super().__init__()
|
| 754 |
self.config = config
|
| 755 |
-
self.layers = nn.ModuleList([
|
| 756 |
|
| 757 |
def forward(
|
| 758 |
self,
|
|
@@ -805,11 +805,11 @@ class OneVisionEncoderEncoder(nn.Module):
|
|
| 805 |
"The bare OneVision Encoder Model outputting raw hidden-states without any specific head on top.",
|
| 806 |
ONEVISION_ENCODER_START_DOCSTRING,
|
| 807 |
)
|
| 808 |
-
class
|
| 809 |
-
config_class =
|
| 810 |
-
base_model_prefix = "
|
| 811 |
supports_gradient_checkpointing = True
|
| 812 |
-
_no_split_modules = ["
|
| 813 |
_supports_flash_attn_2 = True
|
| 814 |
|
| 815 |
def _init_weights(self, module):
|
|
@@ -834,14 +834,14 @@ class OneVisionEncoderPreTrainedModel(PreTrainedModel):
|
|
| 834 |
"OneVision Encoder Model with a vision transformer encoder.",
|
| 835 |
ONEVISION_ENCODER_START_DOCSTRING,
|
| 836 |
)
|
| 837 |
-
class
|
| 838 |
-
def __init__(self, config:
|
| 839 |
super().__init__(config)
|
| 840 |
self.config = config
|
| 841 |
self.segment_t_size=config.segment_t_size
|
| 842 |
-
self.embeddings =
|
| 843 |
self.layernorm_pre = get_norm_layer(config)
|
| 844 |
-
self.encoder =
|
| 845 |
self.video_rope = SegmentVideoRotaryEmbeddingSplit2455(config)
|
| 846 |
self.query_tokens=nn.Parameter(0.05*torch.randn(1,1,config.num_query_per_seg,self.config.hidden_size))
|
| 847 |
self.num_query_per_seg=config.num_query_per_seg
|
|
@@ -985,7 +985,7 @@ class OneVisionEncoderModel(OneVisionEncoderPreTrainedModel):
|
|
| 985 |
return pixel_values, freqs_visible
|
| 986 |
|
| 987 |
@add_start_docstrings_to_model_forward(ONEVISION_ENCODER_INPUTS_DOCSTRING)
|
| 988 |
-
@replace_return_docstrings(output_type=BaseModelOutputWithPooling, config_class=
|
| 989 |
def forward(
|
| 990 |
self,
|
| 991 |
pixel_values: torch.Tensor,
|
|
|
|
| 13 |
replace_return_docstrings,
|
| 14 |
)
|
| 15 |
|
| 16 |
+
# from .configuration_covisco_encoder import CoViscoEncoderConfig
|
| 17 |
|
| 18 |
from transformers.configuration_utils import PretrainedConfig
|
| 19 |
from transformers.utils import logging
|
|
|
|
| 22 |
logger = logging.get_logger(__name__)
|
| 23 |
|
| 24 |
|
| 25 |
+
class CoViscoEncoderConfig(PretrainedConfig):
|
| 26 |
r"""
|
| 27 |
+
This is the configuration class to store the configuration of a [`CoViscoEncoderModel`]. It is used to instantiate a
|
| 28 |
OneVision Encoder model according to the specified arguments, defining the model architecture. Instantiating a configuration
|
| 29 |
with the defaults will yield a similar configuration to that of the OneVision Encoder architecture.
|
| 30 |
|
|
|
|
| 64 |
Example:
|
| 65 |
|
| 66 |
```python
|
| 67 |
+
>>> from configuration_covisco_encoder import CoViscoEncoderConfig
|
| 68 |
+
>>> from modeling_covisco_encoder import CoViscoEncoderModel
|
| 69 |
|
| 70 |
+
>>> # Initializing a CoViscoEncoder configuration
|
| 71 |
+
>>> configuration = CoViscoEncoderConfig()
|
| 72 |
|
| 73 |
>>> # Initializing a model (with random weights) from the configuration
|
| 74 |
+
>>> model = CoViscoEncoderModel(configuration)
|
| 75 |
|
| 76 |
>>> # Accessing the model configuration
|
| 77 |
>>> configuration = model.config
|
| 78 |
```
|
| 79 |
"""
|
| 80 |
|
| 81 |
+
model_type = "covisco_encoder"
|
| 82 |
|
| 83 |
def __init__(
|
| 84 |
self,
|
|
|
|
| 154 |
and behavior.
|
| 155 |
|
| 156 |
Parameters:
|
| 157 |
+
config ([`CoViscoEncoderConfig`]): Model configuration class with all the parameters of the model.
|
| 158 |
Initializing with a config file does not load the weights associated with the model, only the
|
| 159 |
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
|
| 160 |
"""
|
|
|
|
| 222 |
Adds segment dimension to the existing VideoRotaryEmbeddingSplit466.
|
| 223 |
"""
|
| 224 |
|
| 225 |
+
def __init__(self, config: CoViscoEncoderConfig):
|
| 226 |
super().__init__()
|
| 227 |
head_dim = config.hidden_size // config.num_attention_heads
|
| 228 |
base = config.rope_theta
|
|
|
|
| 319 |
3D (T,H,W) Rotary frequency constructor with 4:6:6 split.
|
| 320 |
"""
|
| 321 |
|
| 322 |
+
def __init__(self, config: CoViscoEncoderConfig):
|
| 323 |
super().__init__()
|
| 324 |
head_dim = config.hidden_size // config.num_attention_heads
|
| 325 |
base = config.rope_theta
|
|
|
|
| 404 |
Multi-Head Attention Pooling with a learned probe (PMA-style).
|
| 405 |
"""
|
| 406 |
|
| 407 |
+
def __init__(self, config: CoViscoEncoderConfig):
|
| 408 |
super().__init__()
|
| 409 |
self.embed_dim = config.hidden_size
|
| 410 |
self.probe = nn.Parameter(torch.randn(1, 1, config.hidden_size))
|
|
|
|
| 442 |
return patches
|
| 443 |
|
| 444 |
|
| 445 |
+
class CoViscoEncoderEmbeddings(nn.Module):
|
| 446 |
+
def __init__(self, config: CoViscoEncoderConfig):
|
| 447 |
super().__init__()
|
| 448 |
self.config = config
|
| 449 |
self.embed_dim = config.hidden_size
|
|
|
|
| 479 |
return embeddings
|
| 480 |
|
| 481 |
|
| 482 |
+
class CoViscoEncoderAttention(nn.Module):
|
| 483 |
"""Multi-headed attention with RoPE support"""
|
| 484 |
|
| 485 |
+
def __init__(self, config: CoViscoEncoderConfig):
|
| 486 |
super().__init__()
|
| 487 |
self.config = config
|
| 488 |
self.embed_dim = config.hidden_size
|
|
|
|
| 556 |
return attn_output, attn_weights if output_attentions else None
|
| 557 |
|
| 558 |
|
| 559 |
+
class CoViscoEncoderFlashAttention2(nn.Module):
|
| 560 |
"""
|
| 561 |
Multi-headed attention with RoPE support using Flash Attention 2.
|
| 562 |
+
This module implements the same attention mechanism as CoViscoEncoderAttention but uses
|
| 563 |
Flash Attention for improved performance and memory efficiency.
|
| 564 |
"""
|
| 565 |
|
| 566 |
+
def __init__(self, config: CoViscoEncoderConfig):
|
| 567 |
super().__init__()
|
| 568 |
self.config = config
|
| 569 |
self.embed_dim = config.hidden_size
|
|
|
|
| 624 |
# value_states = torch.cat((context_kv_cache[1], value_states), dim=1)
|
| 625 |
# Flash Attention forward pass
|
| 626 |
if not _flash_attn_available:
|
| 627 |
+
raise ImportError("flash_attn is not installed. Please install it to use CoViscoEncoderFlashAttention2.")
|
| 628 |
|
| 629 |
attn_output = flash_attn_func(
|
| 630 |
query_states,
|
|
|
|
| 646 |
|
| 647 |
|
| 648 |
ONEVISION_ENCODER_ATTENTION_CLASSES = {
|
| 649 |
+
"eager": CoViscoEncoderAttention,
|
| 650 |
+
"flash_attention_2": CoViscoEncoderFlashAttention2,
|
| 651 |
}
|
| 652 |
|
| 653 |
|
| 654 |
+
class CoViscoEncoderEncoderLayer(nn.Module):
|
| 655 |
+
def __init__(self, config: CoViscoEncoderConfig):
|
| 656 |
super().__init__()
|
| 657 |
self.embed_dim = config.hidden_size
|
| 658 |
self.num_query_per_seg=config.num_query_per_seg
|
|
|
|
| 748 |
return outputs
|
| 749 |
|
| 750 |
|
| 751 |
+
class CoViscoEncoderEncoder(nn.Module):
|
| 752 |
+
def __init__(self, config: CoViscoEncoderConfig):
|
| 753 |
super().__init__()
|
| 754 |
self.config = config
|
| 755 |
+
self.layers = nn.ModuleList([CoViscoEncoderEncoderLayer(config) for _ in range(config.num_hidden_layers)])
|
| 756 |
|
| 757 |
def forward(
|
| 758 |
self,
|
|
|
|
| 805 |
"The bare OneVision Encoder Model outputting raw hidden-states without any specific head on top.",
|
| 806 |
ONEVISION_ENCODER_START_DOCSTRING,
|
| 807 |
)
|
| 808 |
+
class CoViscoEncoderPreTrainedModel(PreTrainedModel):
|
| 809 |
+
config_class = CoViscoEncoderConfig
|
| 810 |
+
base_model_prefix = "covisco_encoder"
|
| 811 |
supports_gradient_checkpointing = True
|
| 812 |
+
_no_split_modules = ["CoViscoEncoderEncoderLayer"]
|
| 813 |
_supports_flash_attn_2 = True
|
| 814 |
|
| 815 |
def _init_weights(self, module):
|
|
|
|
| 834 |
"OneVision Encoder Model with a vision transformer encoder.",
|
| 835 |
ONEVISION_ENCODER_START_DOCSTRING,
|
| 836 |
)
|
| 837 |
+
class CoViscoEncoderModel(CoViscoEncoderPreTrainedModel):
|
| 838 |
+
def __init__(self, config: CoViscoEncoderConfig):
|
| 839 |
super().__init__(config)
|
| 840 |
self.config = config
|
| 841 |
self.segment_t_size=config.segment_t_size
|
| 842 |
+
self.embeddings = CoViscoEncoderEmbeddings(config)
|
| 843 |
self.layernorm_pre = get_norm_layer(config)
|
| 844 |
+
self.encoder = CoViscoEncoderEncoder(config)
|
| 845 |
self.video_rope = SegmentVideoRotaryEmbeddingSplit2455(config)
|
| 846 |
self.query_tokens=nn.Parameter(0.05*torch.randn(1,1,config.num_query_per_seg,self.config.hidden_size))
|
| 847 |
self.num_query_per_seg=config.num_query_per_seg
|
|
|
|
| 985 |
return pixel_values, freqs_visible
|
| 986 |
|
| 987 |
@add_start_docstrings_to_model_forward(ONEVISION_ENCODER_INPUTS_DOCSTRING)
|
| 988 |
+
@replace_return_docstrings(output_type=BaseModelOutputWithPooling, config_class=CoViscoEncoderConfig)
|
| 989 |
def forward(
|
| 990 |
self,
|
| 991 |
pixel_values: torch.Tensor,
|
load_covisco.py
CHANGED
|
@@ -18,7 +18,7 @@ from PIL import Image
|
|
| 18 |
from torchvision import transforms
|
| 19 |
from torchvision.transforms import InterpolationMode
|
| 20 |
|
| 21 |
-
from covisco_vit import
|
| 22 |
try: # package / trust_remote_code context
|
| 23 |
from .covisco_model import CoViscoModel
|
| 24 |
except ImportError: # flat script context
|
|
|
|
| 18 |
from torchvision import transforms
|
| 19 |
from torchvision.transforms import InterpolationMode
|
| 20 |
|
| 21 |
+
from covisco_vit import CoViscoEncoderConfig # noqa: F401 (kept for back-compat)
|
| 22 |
try: # package / trust_remote_code context
|
| 23 |
from .covisco_model import CoViscoModel
|
| 24 |
except ImportError: # flat script context
|