mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-03 12:50:06 +06:00
Add Optional to remaining types (#37808)
More Optional typing Signed-off-by: cyy <cyyever@outlook.com>
This commit is contained in:
parent
1a9188a54e
commit
da4ff2a5f5
@ -19,6 +19,7 @@ import time
|
|||||||
from json import JSONDecodeError
|
from json import JSONDecodeError
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torch.utils.data import DataLoader
|
from torch.utils.data import DataLoader
|
||||||
@ -54,7 +55,7 @@ def eval_data_dir(
|
|||||||
task="summarization",
|
task="summarization",
|
||||||
local_rank=None,
|
local_rank=None,
|
||||||
num_return_sequences=1,
|
num_return_sequences=1,
|
||||||
dataset_kwargs: dict = None,
|
dataset_kwargs: Optional[dict] = None,
|
||||||
prefix="",
|
prefix="",
|
||||||
**generate_kwargs,
|
**generate_kwargs,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
|
@ -74,7 +74,7 @@ class ImgprocModelImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: dict[str, int] = None,
|
size: Optional[dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
@ -159,7 +159,7 @@ class ImgprocModelImageProcessor(BaseImageProcessor):
|
|||||||
image_mean: Optional[Union[float, list[float]]] = None,
|
image_mean: Optional[Union[float, list[float]]] = None,
|
||||||
image_std: Optional[Union[float, list[float]]] = None,
|
image_std: Optional[Union[float, list[float]]] = None,
|
||||||
return_tensors: Optional[Union[str, TensorType]] = None,
|
return_tensors: Optional[Union[str, TensorType]] = None,
|
||||||
do_convert_rgb: bool = None,
|
do_convert_rgb: Optional[bool] = None,
|
||||||
data_format: ChannelDimension = ChannelDimension.FIRST,
|
data_format: ChannelDimension = ChannelDimension.FIRST,
|
||||||
input_data_format: Optional[Union[str, ChannelDimension]] = None,
|
input_data_format: Optional[Union[str, ChannelDimension]] = None,
|
||||||
) -> PIL.Image.Image:
|
) -> PIL.Image.Image:
|
||||||
|
@ -359,7 +359,7 @@ class DynamicCache(Cache):
|
|||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, _distributed_cache_data: Iterable = None) -> None:
|
def __init__(self, _distributed_cache_data: Optional[Iterable] = None) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._seen_tokens = 0 # Used in `generate` to keep tally of how many tokens the cache has seen
|
self._seen_tokens = 0 # Used in `generate` to keep tally of how many tokens the cache has seen
|
||||||
self.key_cache: List[torch.Tensor] = []
|
self.key_cache: List[torch.Tensor] = []
|
||||||
|
@ -512,7 +512,7 @@ def duplicate_module(
|
|||||||
new_model_patterns: ModelPatterns,
|
new_model_patterns: ModelPatterns,
|
||||||
dest_file: Optional[str] = None,
|
dest_file: Optional[str] = None,
|
||||||
add_copied_from: bool = True,
|
add_copied_from: bool = True,
|
||||||
attrs_to_remove: List[str] = None,
|
attrs_to_remove: Optional[List[str]] = None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Create a new module from an existing one and adapting all function and classes names from old patterns to new ones.
|
Create a new module from an existing one and adapting all function and classes names from old patterns to new ones.
|
||||||
|
@ -19,6 +19,7 @@ allow to make our dependency on SentencePiece optional.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from packaging import version
|
from packaging import version
|
||||||
from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, processors
|
from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, processors
|
||||||
@ -326,7 +327,9 @@ class OpenAIGPTConverter(Converter):
|
|||||||
|
|
||||||
|
|
||||||
class GPT2Converter(Converter):
|
class GPT2Converter(Converter):
|
||||||
def converted(self, vocab: dict[str, int] = None, merges: list[tuple[str, str]] = None) -> Tokenizer:
|
def converted(
|
||||||
|
self, vocab: Optional[dict[str, int]] = None, merges: Optional[list[tuple[str, str]]] = None
|
||||||
|
) -> Tokenizer:
|
||||||
if not vocab:
|
if not vocab:
|
||||||
vocab = self.original_tokenizer.encoder
|
vocab = self.original_tokenizer.encoder
|
||||||
if not merges:
|
if not merges:
|
||||||
@ -395,7 +398,9 @@ class HerbertConverter(Converter):
|
|||||||
|
|
||||||
|
|
||||||
class Qwen2Converter(Converter):
|
class Qwen2Converter(Converter):
|
||||||
def converted(self, vocab: dict[str, int] = None, merges: list[tuple[str, str]] = None) -> Tokenizer:
|
def converted(
|
||||||
|
self, vocab: Optional[dict[str, int]] = None, merges: Optional[list[tuple[str, str]]] = None
|
||||||
|
) -> Tokenizer:
|
||||||
if not vocab:
|
if not vocab:
|
||||||
vocab = self.original_tokenizer.encoder
|
vocab = self.original_tokenizer.encoder
|
||||||
if not merges:
|
if not merges:
|
||||||
|
@ -209,7 +209,7 @@ def convert_to_size_dict(
|
|||||||
|
|
||||||
|
|
||||||
def get_size_dict(
|
def get_size_dict(
|
||||||
size: Union[int, Iterable[int], dict[str, int]] = None,
|
size: Optional[Union[int, Iterable[int], dict[str, int]]] = None,
|
||||||
max_size: Optional[int] = None,
|
max_size: Optional[int] = None,
|
||||||
height_width_order: bool = True,
|
height_width_order: bool = True,
|
||||||
default_to_square: bool = True,
|
default_to_square: bool = True,
|
||||||
|
@ -755,7 +755,7 @@ class BaseImageProcessorFast(BaseImageProcessor):
|
|||||||
|
|
||||||
|
|
||||||
class SemanticSegmentationMixin:
|
class SemanticSegmentationMixin:
|
||||||
def post_process_semantic_segmentation(self, outputs, target_sizes: list[tuple] = None):
|
def post_process_semantic_segmentation(self, outputs, target_sizes: Optional[list[tuple]] = None):
|
||||||
"""
|
"""
|
||||||
Converts the output of [`MobileNetV2ForSemanticSegmentation`] into semantic segmentation maps. Only supports PyTorch.
|
Converts the output of [`MobileNetV2ForSemanticSegmentation`] into semantic segmentation maps. Only supports PyTorch.
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ class PeftAdapterMixin:
|
|||||||
max_memory: Optional[str] = None,
|
max_memory: Optional[str] = None,
|
||||||
offload_folder: Optional[str] = None,
|
offload_folder: Optional[str] = None,
|
||||||
offload_index: Optional[int] = None,
|
offload_index: Optional[int] = None,
|
||||||
peft_config: Dict[str, Any] = None,
|
peft_config: Optional[Dict[str, Any]] = None,
|
||||||
adapter_state_dict: Optional[Dict[str, "torch.Tensor"]] = None,
|
adapter_state_dict: Optional[Dict[str, "torch.Tensor"]] = None,
|
||||||
low_cpu_mem_usage: bool = False,
|
low_cpu_mem_usage: bool = False,
|
||||||
is_trainable: bool = False,
|
is_trainable: bool = False,
|
||||||
|
@ -558,7 +558,7 @@ class FlaxAlbertPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
attention_mask=None,
|
attention_mask=None,
|
||||||
token_type_ids=None,
|
token_type_ids=None,
|
||||||
position_ids=None,
|
position_ids=None,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: jax.random.PRNGKey = None,
|
dropout_rng: jax.random.PRNGKey = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
from typing import Dict
|
from typing import Dict, Optional
|
||||||
|
|
||||||
from ...configuration_utils import PretrainedConfig
|
from ...configuration_utils import PretrainedConfig
|
||||||
from ...modeling_rope_utils import rope_config_validation
|
from ...modeling_rope_utils import rope_config_validation
|
||||||
@ -268,7 +268,7 @@ class AriaConfig(PretrainedConfig):
|
|||||||
vision_config=None,
|
vision_config=None,
|
||||||
vision_feature_layer: int = -1,
|
vision_feature_layer: int = -1,
|
||||||
text_config: AriaTextConfig = None,
|
text_config: AriaTextConfig = None,
|
||||||
projector_patch_to_query_dict: Dict = None,
|
projector_patch_to_query_dict: Optional[Dict] = None,
|
||||||
image_token_index: int = 9,
|
image_token_index: int = 9,
|
||||||
initializer_range: float = 0.02,
|
initializer_range: float = 0.02,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
|
@ -124,8 +124,8 @@ class AriaImageProcessor(BaseImageProcessor):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
image_mean: List[float] = None,
|
image_mean: Optional[List[float]] = None,
|
||||||
image_std: List[float] = None,
|
image_std: Optional[List[float]] = None,
|
||||||
max_image_size: int = 980,
|
max_image_size: int = 980,
|
||||||
min_image_size: int = 336,
|
min_image_size: int = 336,
|
||||||
split_resolutions: Optional[List[Tuple[int, int]]] = None,
|
split_resolutions: Optional[List[Tuple[int, int]]] = None,
|
||||||
|
@ -276,7 +276,7 @@ class AriaConfig(PretrainedConfig):
|
|||||||
vision_config=None,
|
vision_config=None,
|
||||||
vision_feature_layer: int = -1,
|
vision_feature_layer: int = -1,
|
||||||
text_config: AriaTextConfig = None,
|
text_config: AriaTextConfig = None,
|
||||||
projector_patch_to_query_dict: Dict = None,
|
projector_patch_to_query_dict: Optional[Dict] = None,
|
||||||
image_token_index: int = 9,
|
image_token_index: int = 9,
|
||||||
initializer_range: float = 0.02,
|
initializer_range: float = 0.02,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
@ -514,8 +514,8 @@ class AriaImageProcessor(BaseImageProcessor):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
image_mean: List[float] = None,
|
image_mean: Optional[List[float]] = None,
|
||||||
image_std: List[float] = None,
|
image_std: Optional[List[float]] = None,
|
||||||
max_image_size: int = 980,
|
max_image_size: int = 980,
|
||||||
min_image_size: int = 336,
|
min_image_size: int = 336,
|
||||||
split_resolutions: Optional[List[Tuple[int, int]]] = None,
|
split_resolutions: Optional[List[Tuple[int, int]]] = None,
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
"""BARK model configuration"""
|
"""BARK model configuration"""
|
||||||
|
|
||||||
from typing import Dict
|
from typing import Dict, Optional
|
||||||
|
|
||||||
from ...configuration_utils import PretrainedConfig
|
from ...configuration_utils import PretrainedConfig
|
||||||
from ...utils import add_start_docstrings, logging
|
from ...utils import add_start_docstrings, logging
|
||||||
@ -243,10 +243,10 @@ class BarkConfig(PretrainedConfig):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
semantic_config: Dict = None,
|
semantic_config: Optional[Dict] = None,
|
||||||
coarse_acoustics_config: Dict = None,
|
coarse_acoustics_config: Optional[Dict] = None,
|
||||||
fine_acoustics_config: Dict = None,
|
fine_acoustics_config: Optional[Dict] = None,
|
||||||
codec_config: Dict = None,
|
codec_config: Optional[Dict] = None,
|
||||||
initializer_range=0.02,
|
initializer_range=0.02,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"""BARK model generation configuration"""
|
"""BARK model generation configuration"""
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
from typing import Dict
|
from typing import Dict, Optional
|
||||||
|
|
||||||
from ...generation.configuration_utils import GenerationConfig
|
from ...generation.configuration_utils import GenerationConfig
|
||||||
from ...utils import logging
|
from ...utils import logging
|
||||||
@ -245,9 +245,9 @@ class BarkGenerationConfig(GenerationConfig):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
semantic_config: Dict = None,
|
semantic_config: Optional[Dict] = None,
|
||||||
coarse_acoustics_config: Dict = None,
|
coarse_acoustics_config: Optional[Dict] = None,
|
||||||
fine_acoustics_config: Dict = None,
|
fine_acoustics_config: Optional[Dict] = None,
|
||||||
sample_rate=24_000,
|
sample_rate=24_000,
|
||||||
codebook_size=1024,
|
codebook_size=1024,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
|
@ -1007,7 +1007,7 @@ class FlaxBartPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: PRNGKey = None,
|
dropout_rng: PRNGKey = None,
|
||||||
):
|
):
|
||||||
r"""
|
r"""
|
||||||
@ -1068,12 +1068,12 @@ class FlaxBartPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
encoder_attention_mask: Optional[jnp.ndarray] = None,
|
encoder_attention_mask: Optional[jnp.ndarray] = None,
|
||||||
decoder_attention_mask: Optional[jnp.ndarray] = None,
|
decoder_attention_mask: Optional[jnp.ndarray] = None,
|
||||||
decoder_position_ids: Optional[jnp.ndarray] = None,
|
decoder_position_ids: Optional[jnp.ndarray] = None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: PRNGKey = None,
|
dropout_rng: PRNGKey = None,
|
||||||
):
|
):
|
||||||
r"""
|
r"""
|
||||||
@ -1186,7 +1186,7 @@ class FlaxBartPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: PRNGKey = None,
|
dropout_rng: PRNGKey = None,
|
||||||
):
|
):
|
||||||
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
||||||
@ -1335,12 +1335,12 @@ class FlaxBartForConditionalGeneration(FlaxBartPreTrainedModel):
|
|||||||
encoder_attention_mask: Optional[jnp.ndarray] = None,
|
encoder_attention_mask: Optional[jnp.ndarray] = None,
|
||||||
decoder_attention_mask: Optional[jnp.ndarray] = None,
|
decoder_attention_mask: Optional[jnp.ndarray] = None,
|
||||||
decoder_position_ids: Optional[jnp.ndarray] = None,
|
decoder_position_ids: Optional[jnp.ndarray] = None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: PRNGKey = None,
|
dropout_rng: PRNGKey = None,
|
||||||
):
|
):
|
||||||
r"""
|
r"""
|
||||||
@ -1807,8 +1807,8 @@ class FlaxBartDecoderPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
dropout_rng: PRNGKey = None,
|
dropout_rng: PRNGKey = None,
|
||||||
):
|
):
|
||||||
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
||||||
|
@ -106,10 +106,10 @@ class BeitImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
||||||
do_center_crop: bool = True,
|
do_center_crop: bool = True,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
@ -194,10 +194,10 @@ class BeitImageProcessor(BaseImageProcessor):
|
|||||||
image: ImageInput,
|
image: ImageInput,
|
||||||
do_reduce_labels: Optional[bool] = None,
|
do_reduce_labels: Optional[bool] = None,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: Optional[bool] = None,
|
do_rescale: Optional[bool] = None,
|
||||||
rescale_factor: Optional[float] = None,
|
rescale_factor: Optional[float] = None,
|
||||||
do_normalize: Optional[bool] = None,
|
do_normalize: Optional[bool] = None,
|
||||||
@ -226,10 +226,10 @@ class BeitImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
image: ImageInput,
|
image: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: Optional[bool] = None,
|
do_rescale: Optional[bool] = None,
|
||||||
rescale_factor: Optional[float] = None,
|
rescale_factor: Optional[float] = None,
|
||||||
do_normalize: Optional[bool] = None,
|
do_normalize: Optional[bool] = None,
|
||||||
@ -271,10 +271,10 @@ class BeitImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
segmentation_map: ImageInput,
|
segmentation_map: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_reduce_labels: Optional[bool] = None,
|
do_reduce_labels: Optional[bool] = None,
|
||||||
input_data_format: Optional[Union[str, ChannelDimension]] = None,
|
input_data_format: Optional[Union[str, ChannelDimension]] = None,
|
||||||
):
|
):
|
||||||
@ -320,10 +320,10 @@ class BeitImageProcessor(BaseImageProcessor):
|
|||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
segmentation_maps: Optional[ImageInput] = None,
|
segmentation_maps: Optional[ImageInput] = None,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: Optional[bool] = None,
|
do_rescale: Optional[bool] = None,
|
||||||
rescale_factor: Optional[float] = None,
|
rescale_factor: Optional[float] = None,
|
||||||
do_normalize: Optional[bool] = None,
|
do_normalize: Optional[bool] = None,
|
||||||
@ -470,7 +470,7 @@ class BeitImageProcessor(BaseImageProcessor):
|
|||||||
|
|
||||||
return BatchFeature(data=data, tensor_type=return_tensors)
|
return BatchFeature(data=data, tensor_type=return_tensors)
|
||||||
|
|
||||||
def post_process_semantic_segmentation(self, outputs, target_sizes: List[Tuple] = None):
|
def post_process_semantic_segmentation(self, outputs, target_sizes: Optional[List[Tuple]] = None):
|
||||||
"""
|
"""
|
||||||
Converts the output of [`BeitForSemanticSegmentation`] into semantic segmentation maps. Only supports PyTorch.
|
Converts the output of [`BeitForSemanticSegmentation`] into semantic segmentation maps. Only supports PyTorch.
|
||||||
|
|
||||||
|
@ -634,7 +634,7 @@ class FlaxBeitPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
self,
|
self,
|
||||||
pixel_values,
|
pixel_values,
|
||||||
bool_masked_pos=None,
|
bool_masked_pos=None,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: jax.random.PRNGKey = None,
|
dropout_rng: jax.random.PRNGKey = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
|
@ -864,13 +864,13 @@ class FlaxBertPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
head_mask=None,
|
head_mask=None,
|
||||||
encoder_hidden_states=None,
|
encoder_hidden_states=None,
|
||||||
encoder_attention_mask=None,
|
encoder_attention_mask=None,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: jax.random.PRNGKey = None,
|
dropout_rng: jax.random.PRNGKey = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
):
|
):
|
||||||
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
||||||
output_hidden_states = (
|
output_hidden_states = (
|
||||||
|
@ -1725,14 +1725,14 @@ class FlaxBigBirdPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
head_mask=None,
|
head_mask=None,
|
||||||
encoder_hidden_states=None,
|
encoder_hidden_states=None,
|
||||||
encoder_attention_mask=None,
|
encoder_attention_mask=None,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: Optional[jax.random.PRNGKey] = None,
|
dropout_rng: Optional[jax.random.PRNGKey] = None,
|
||||||
indices_rng: Optional[jax.random.PRNGKey] = None,
|
indices_rng: Optional[jax.random.PRNGKey] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
):
|
):
|
||||||
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
||||||
output_hidden_states = (
|
output_hidden_states = (
|
||||||
@ -2442,7 +2442,7 @@ class FlaxBigBirdForQuestionAnswering(FlaxBigBirdPreTrainedModel):
|
|||||||
position_ids=None,
|
position_ids=None,
|
||||||
head_mask=None,
|
head_mask=None,
|
||||||
question_lengths=None,
|
question_lengths=None,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: Optional[jax.random.PRNGKey] = None,
|
dropout_rng: Optional[jax.random.PRNGKey] = None,
|
||||||
indices_rng: Optional[jax.random.PRNGKey] = None,
|
indices_rng: Optional[jax.random.PRNGKey] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
|
@ -92,10 +92,10 @@ class BitImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
||||||
do_center_crop: bool = True,
|
do_center_crop: bool = True,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
@ -177,7 +177,7 @@ class BitImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Optional[int] = None,
|
crop_size: Optional[int] = None,
|
||||||
|
@ -980,7 +980,7 @@ class FlaxBlenderbotPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: PRNGKey = None,
|
dropout_rng: PRNGKey = None,
|
||||||
):
|
):
|
||||||
r"""
|
r"""
|
||||||
@ -1043,12 +1043,12 @@ class FlaxBlenderbotPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
encoder_attention_mask: Optional[jnp.ndarray] = None,
|
encoder_attention_mask: Optional[jnp.ndarray] = None,
|
||||||
decoder_attention_mask: Optional[jnp.ndarray] = None,
|
decoder_attention_mask: Optional[jnp.ndarray] = None,
|
||||||
decoder_position_ids: Optional[jnp.ndarray] = None,
|
decoder_position_ids: Optional[jnp.ndarray] = None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: PRNGKey = None,
|
dropout_rng: PRNGKey = None,
|
||||||
):
|
):
|
||||||
r"""
|
r"""
|
||||||
@ -1161,7 +1161,7 @@ class FlaxBlenderbotPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: PRNGKey = None,
|
dropout_rng: PRNGKey = None,
|
||||||
):
|
):
|
||||||
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
||||||
@ -1311,12 +1311,12 @@ class FlaxBlenderbotForConditionalGeneration(FlaxBlenderbotPreTrainedModel):
|
|||||||
encoder_attention_mask: Optional[jnp.ndarray] = None,
|
encoder_attention_mask: Optional[jnp.ndarray] = None,
|
||||||
decoder_attention_mask: Optional[jnp.ndarray] = None,
|
decoder_attention_mask: Optional[jnp.ndarray] = None,
|
||||||
decoder_position_ids: Optional[jnp.ndarray] = None,
|
decoder_position_ids: Optional[jnp.ndarray] = None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: PRNGKey = None,
|
dropout_rng: PRNGKey = None,
|
||||||
):
|
):
|
||||||
r"""
|
r"""
|
||||||
|
@ -977,7 +977,7 @@ class FlaxBlenderbotSmallPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: PRNGKey = None,
|
dropout_rng: PRNGKey = None,
|
||||||
):
|
):
|
||||||
r"""
|
r"""
|
||||||
@ -1040,12 +1040,12 @@ class FlaxBlenderbotSmallPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
encoder_attention_mask: Optional[jnp.ndarray] = None,
|
encoder_attention_mask: Optional[jnp.ndarray] = None,
|
||||||
decoder_attention_mask: Optional[jnp.ndarray] = None,
|
decoder_attention_mask: Optional[jnp.ndarray] = None,
|
||||||
decoder_position_ids: Optional[jnp.ndarray] = None,
|
decoder_position_ids: Optional[jnp.ndarray] = None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: PRNGKey = None,
|
dropout_rng: PRNGKey = None,
|
||||||
):
|
):
|
||||||
r"""
|
r"""
|
||||||
@ -1157,7 +1157,7 @@ class FlaxBlenderbotSmallPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: PRNGKey = None,
|
dropout_rng: PRNGKey = None,
|
||||||
):
|
):
|
||||||
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
||||||
@ -1308,12 +1308,12 @@ class FlaxBlenderbotSmallForConditionalGeneration(FlaxBlenderbotSmallPreTrainedM
|
|||||||
encoder_attention_mask: Optional[jnp.ndarray] = None,
|
encoder_attention_mask: Optional[jnp.ndarray] = None,
|
||||||
decoder_attention_mask: Optional[jnp.ndarray] = None,
|
decoder_attention_mask: Optional[jnp.ndarray] = None,
|
||||||
decoder_position_ids: Optional[jnp.ndarray] = None,
|
decoder_position_ids: Optional[jnp.ndarray] = None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
deterministic: bool = True,
|
deterministic: bool = True,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: PRNGKey = None,
|
dropout_rng: PRNGKey = None,
|
||||||
):
|
):
|
||||||
r"""
|
r"""
|
||||||
|
@ -83,7 +83,7 @@ class BlipImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
|
@ -148,7 +148,7 @@ class BloomOnnxConfig(OnnxConfigWithPast):
|
|||||||
self,
|
self,
|
||||||
config: PretrainedConfig,
|
config: PretrainedConfig,
|
||||||
task: str = "default",
|
task: str = "default",
|
||||||
patching_specs: List[PatchingSpec] = None,
|
patching_specs: Optional[List[PatchingSpec]] = None,
|
||||||
use_past: bool = False,
|
use_past: bool = False,
|
||||||
):
|
):
|
||||||
super().__init__(config, task=task, patching_specs=patching_specs, use_past=use_past)
|
super().__init__(config, task=task, patching_specs=patching_specs, use_past=use_past)
|
||||||
|
@ -463,8 +463,8 @@ class FlaxBloomPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
self,
|
self,
|
||||||
input_ids,
|
input_ids,
|
||||||
attention_mask=None,
|
attention_mask=None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: jax.random.PRNGKey = None,
|
dropout_rng: jax.random.PRNGKey = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
|
@ -172,7 +172,7 @@ class BridgeTowerImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
size_divisor: int = 32,
|
size_divisor: int = 32,
|
||||||
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
@ -181,7 +181,7 @@ class BridgeTowerImageProcessor(BaseImageProcessor):
|
|||||||
image_mean: Optional[Union[float, List[float]]] = None,
|
image_mean: Optional[Union[float, List[float]]] = None,
|
||||||
image_std: Optional[Union[float, List[float]]] = None,
|
image_std: Optional[Union[float, List[float]]] = None,
|
||||||
do_center_crop: bool = True,
|
do_center_crop: bool = True,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_pad: bool = True,
|
do_pad: bool = True,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -385,7 +385,7 @@ class BridgeTowerImageProcessor(BaseImageProcessor):
|
|||||||
image_std: Optional[Union[float, List[float]]] = None,
|
image_std: Optional[Union[float, List[float]]] = None,
|
||||||
do_pad: Optional[bool] = None,
|
do_pad: Optional[bool] = None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
return_tensors: Optional[Union[str, TensorType]] = None,
|
return_tensors: Optional[Union[str, TensorType]] = None,
|
||||||
data_format: ChannelDimension = ChannelDimension.FIRST,
|
data_format: ChannelDimension = ChannelDimension.FIRST,
|
||||||
input_data_format: Optional[Union[str, ChannelDimension]] = None,
|
input_data_format: Optional[Union[str, ChannelDimension]] = None,
|
||||||
|
@ -1581,7 +1581,7 @@ class CamembertForCausalLM(CamembertPreTrainedModel, GenerationMixin):
|
|||||||
encoder_hidden_states: Optional[torch.FloatTensor] = None,
|
encoder_hidden_states: Optional[torch.FloatTensor] = None,
|
||||||
encoder_attention_mask: Optional[torch.FloatTensor] = None,
|
encoder_attention_mask: Optional[torch.FloatTensor] = None,
|
||||||
labels: Optional[torch.LongTensor] = None,
|
labels: Optional[torch.LongTensor] = None,
|
||||||
past_key_values: Tuple[Tuple[torch.FloatTensor]] = None,
|
past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
|
||||||
use_cache: Optional[bool] = None,
|
use_cache: Optional[bool] = None,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
"""chameleon model configuration"""
|
"""chameleon model configuration"""
|
||||||
|
|
||||||
from typing import List
|
from typing import List, Optional
|
||||||
|
|
||||||
from ...configuration_utils import PretrainedConfig
|
from ...configuration_utils import PretrainedConfig
|
||||||
from ...utils import logging
|
from ...utils import logging
|
||||||
@ -75,7 +75,7 @@ class ChameleonVQVAEConfig(PretrainedConfig):
|
|||||||
base_channels: int = 128,
|
base_channels: int = 128,
|
||||||
channel_multiplier: List[int] = [1, 1, 2, 2, 4],
|
channel_multiplier: List[int] = [1, 1, 2, 2, 4],
|
||||||
num_res_blocks: int = 2,
|
num_res_blocks: int = 2,
|
||||||
attn_resolutions: List[int] = None,
|
attn_resolutions: Optional[List[int]] = None,
|
||||||
dropout: float = 0.0,
|
dropout: float = 0.0,
|
||||||
attn_type: str = "vanilla",
|
attn_type: str = "vanilla",
|
||||||
initializer_range=0.02,
|
initializer_range=0.02,
|
||||||
|
@ -88,10 +88,10 @@ class ChameleonImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PIL.Image.LANCZOS,
|
resample: PILImageResampling = PIL.Image.LANCZOS,
|
||||||
do_center_crop: bool = True,
|
do_center_crop: bool = True,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 0.0078,
|
rescale_factor: Union[int, float] = 0.0078,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
@ -173,7 +173,7 @@ class ChameleonImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Optional[int] = None,
|
crop_size: Optional[int] = None,
|
||||||
|
@ -96,10 +96,10 @@ class ChineseCLIPImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
||||||
do_center_crop: bool = True,
|
do_center_crop: bool = True,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
@ -170,7 +170,7 @@ class ChineseCLIPImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Optional[int] = None,
|
crop_size: Optional[int] = None,
|
||||||
|
@ -95,10 +95,10 @@ class CLIPImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
||||||
do_center_crop: bool = True,
|
do_center_crop: bool = True,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
@ -203,7 +203,7 @@ class CLIPImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Optional[int] = None,
|
crop_size: Optional[int] = None,
|
||||||
|
@ -667,7 +667,7 @@ class FlaxCLIPTextPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
input_ids,
|
input_ids,
|
||||||
attention_mask=None,
|
attention_mask=None,
|
||||||
position_ids=None,
|
position_ids=None,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: jax.random.PRNGKey = None,
|
dropout_rng: jax.random.PRNGKey = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
@ -745,7 +745,7 @@ class FlaxCLIPVisionPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
def __call__(
|
def __call__(
|
||||||
self,
|
self,
|
||||||
pixel_values,
|
pixel_values,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: jax.random.PRNGKey = None,
|
dropout_rng: jax.random.PRNGKey = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
@ -823,7 +823,7 @@ class FlaxCLIPPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
pixel_values,
|
pixel_values,
|
||||||
attention_mask=None,
|
attention_mask=None,
|
||||||
position_ids=None,
|
position_ids=None,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: jax.random.PRNGKey = None,
|
dropout_rng: jax.random.PRNGKey = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
@ -867,7 +867,7 @@ class FlaxCLIPPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
input_ids,
|
input_ids,
|
||||||
attention_mask=None,
|
attention_mask=None,
|
||||||
position_ids=None,
|
position_ids=None,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: jax.random.PRNGKey = None,
|
dropout_rng: jax.random.PRNGKey = None,
|
||||||
train=False,
|
train=False,
|
||||||
):
|
):
|
||||||
@ -930,7 +930,7 @@ class FlaxCLIPPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def get_image_features(
|
def get_image_features(
|
||||||
self, pixel_values, params: dict = None, dropout_rng: jax.random.PRNGKey = None, train=False
|
self, pixel_values, params: Optional[dict] = None, dropout_rng: jax.random.PRNGKey = None, train=False
|
||||||
):
|
):
|
||||||
r"""
|
r"""
|
||||||
Args:
|
Args:
|
||||||
|
@ -151,7 +151,7 @@ class CodeGenOnnxConfig(OnnxConfigWithPast):
|
|||||||
self,
|
self,
|
||||||
config: PretrainedConfig,
|
config: PretrainedConfig,
|
||||||
task: str = "default",
|
task: str = "default",
|
||||||
patching_specs: List[PatchingSpec] = None,
|
patching_specs: Optional[List[PatchingSpec]] = None,
|
||||||
use_past: bool = False,
|
use_past: bool = False,
|
||||||
):
|
):
|
||||||
super().__init__(config, task=task, patching_specs=patching_specs, use_past=use_past)
|
super().__init__(config, task=task, patching_specs=patching_specs, use_past=use_past)
|
||||||
|
@ -749,7 +749,7 @@ def compute_segments(
|
|||||||
mask_threshold: float = 0.5,
|
mask_threshold: float = 0.5,
|
||||||
overlap_mask_area_threshold: float = 0.8,
|
overlap_mask_area_threshold: float = 0.8,
|
||||||
label_ids_to_fuse: Optional[Set[int]] = None,
|
label_ids_to_fuse: Optional[Set[int]] = None,
|
||||||
target_size: Tuple[int, int] = None,
|
target_size: Optional[Tuple[int, int]] = None,
|
||||||
):
|
):
|
||||||
height = mask_probs.shape[1] if target_size is None else target_size[0]
|
height = mask_probs.shape[1] if target_size is None else target_size[0]
|
||||||
width = mask_probs.shape[2] if target_size is None else target_size[1]
|
width = mask_probs.shape[2] if target_size is None else target_size[1]
|
||||||
@ -863,13 +863,13 @@ class ConditionalDetrImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
format: Union[str, AnnotationFormat] = AnnotationFormat.COCO_DETECTION,
|
format: Union[str, AnnotationFormat] = AnnotationFormat.COCO_DETECTION,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
image_mean: Union[float, List[float]] = None,
|
image_mean: Optional[Union[float, List[float]]] = None,
|
||||||
image_std: Union[float, List[float]] = None,
|
image_std: Optional[Union[float, List[float]]] = None,
|
||||||
do_convert_annotations: Optional[bool] = None,
|
do_convert_annotations: Optional[bool] = None,
|
||||||
do_pad: bool = True,
|
do_pad: bool = True,
|
||||||
pad_size: Optional[Dict[str, int]] = None,
|
pad_size: Optional[Dict[str, int]] = None,
|
||||||
@ -1633,7 +1633,7 @@ class ConditionalDetrImageProcessor(BaseImageProcessor):
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
# Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.post_process_semantic_segmentation with Detr->ConditionalDetr
|
# Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.post_process_semantic_segmentation with Detr->ConditionalDetr
|
||||||
def post_process_semantic_segmentation(self, outputs, target_sizes: List[Tuple[int, int]] = None):
|
def post_process_semantic_segmentation(self, outputs, target_sizes: Optional[List[Tuple[int, int]]] = None):
|
||||||
"""
|
"""
|
||||||
Converts the output of [`ConditionalDetrForSegmentation`] into semantic segmentation maps. Only supports PyTorch.
|
Converts the output of [`ConditionalDetrForSegmentation`] into semantic segmentation maps. Only supports PyTorch.
|
||||||
|
|
||||||
|
@ -850,7 +850,7 @@ class ConditionalDetrImageProcessorFast(BaseImageProcessorFast):
|
|||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def post_process_semantic_segmentation(self, outputs, target_sizes: List[Tuple[int, int]] = None):
|
def post_process_semantic_segmentation(self, outputs, target_sizes: Optional[List[Tuple[int, int]]] = None):
|
||||||
"""
|
"""
|
||||||
Converts the output of [`ConditionalDetrForSegmentation`] into semantic segmentation maps. Only supports PyTorch.
|
Converts the output of [`ConditionalDetrForSegmentation`] into semantic segmentation maps. Only supports PyTorch.
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ class ConvNextImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
crop_pct: Optional[float] = None,
|
crop_pct: Optional[float] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
@ -190,7 +190,7 @@ class ConvNextImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
crop_pct: Optional[float] = None,
|
crop_pct: Optional[float] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_rescale: Optional[bool] = None,
|
do_rescale: Optional[bool] = None,
|
||||||
|
@ -222,7 +222,9 @@ class CpmAntTokenizer(PreTrainedTokenizer):
|
|||||||
index += 1
|
index += 1
|
||||||
return (vocab_file,)
|
return (vocab_file,)
|
||||||
|
|
||||||
def build_inputs_with_special_tokens(self, token_ids_0: List[int], token_ids_1: List[int] = None) -> List[int]:
|
def build_inputs_with_special_tokens(
|
||||||
|
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
|
||||||
|
) -> List[int]:
|
||||||
"""
|
"""
|
||||||
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
|
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
|
||||||
adding special tokens. A CPMAnt sequence has the following format:
|
adding special tokens. A CPMAnt sequence has the following format:
|
||||||
|
@ -19,6 +19,7 @@ import gc
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from huggingface_hub import hf_hub_download
|
from huggingface_hub import hf_hub_download
|
||||||
@ -87,7 +88,7 @@ ORIGINAL_TO_CONVERTED_KEY_MAPPING = {
|
|||||||
|
|
||||||
|
|
||||||
# Copied from transformers.models.mllama.convert_mllama_weights_to_hf.convert_old_keys_to_new_keys
|
# Copied from transformers.models.mllama.convert_mllama_weights_to_hf.convert_old_keys_to_new_keys
|
||||||
def convert_old_keys_to_new_keys(state_dict_keys: dict = None):
|
def convert_old_keys_to_new_keys(state_dict_keys: Optional[dict] = None):
|
||||||
"""
|
"""
|
||||||
This function should be applied only once, on the concatenated keys to efficiently rename using
|
This function should be applied only once, on the concatenated keys to efficiently rename using
|
||||||
the key mappings.
|
the key mappings.
|
||||||
|
@ -89,7 +89,7 @@ class DbrxFFNConfig(PretrainedConfig):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
ffn_act_fn: dict = None,
|
ffn_act_fn: Optional[dict] = None,
|
||||||
ffn_hidden_size: int = 3584,
|
ffn_hidden_size: int = 3584,
|
||||||
moe_num_experts: int = 4,
|
moe_num_experts: int = 4,
|
||||||
moe_top_k: int = 1,
|
moe_top_k: int = 1,
|
||||||
|
@ -747,7 +747,7 @@ def compute_segments(
|
|||||||
mask_threshold: float = 0.5,
|
mask_threshold: float = 0.5,
|
||||||
overlap_mask_area_threshold: float = 0.8,
|
overlap_mask_area_threshold: float = 0.8,
|
||||||
label_ids_to_fuse: Optional[Set[int]] = None,
|
label_ids_to_fuse: Optional[Set[int]] = None,
|
||||||
target_size: Tuple[int, int] = None,
|
target_size: Optional[Tuple[int, int]] = None,
|
||||||
):
|
):
|
||||||
height = mask_probs.shape[1] if target_size is None else target_size[0]
|
height = mask_probs.shape[1] if target_size is None else target_size[0]
|
||||||
width = mask_probs.shape[2] if target_size is None else target_size[1]
|
width = mask_probs.shape[2] if target_size is None else target_size[1]
|
||||||
@ -861,13 +861,13 @@ class DeformableDetrImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
format: Union[str, AnnotationFormat] = AnnotationFormat.COCO_DETECTION,
|
format: Union[str, AnnotationFormat] = AnnotationFormat.COCO_DETECTION,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
image_mean: Union[float, List[float]] = None,
|
image_mean: Optional[Union[float, List[float]]] = None,
|
||||||
image_std: Union[float, List[float]] = None,
|
image_std: Optional[Union[float, List[float]]] = None,
|
||||||
do_convert_annotations: Optional[bool] = None,
|
do_convert_annotations: Optional[bool] = None,
|
||||||
do_pad: bool = True,
|
do_pad: bool = True,
|
||||||
pad_size: Optional[Dict[str, int]] = None,
|
pad_size: Optional[Dict[str, int]] = None,
|
||||||
|
@ -84,10 +84,10 @@ class DeiTImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PIL.Image.BICUBIC,
|
resample: PILImageResampling = PIL.Image.BICUBIC,
|
||||||
do_center_crop: bool = True,
|
do_center_crop: bool = True,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
@ -166,10 +166,10 @@ class DeiTImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample=None,
|
resample=None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: Optional[bool] = None,
|
do_rescale: Optional[bool] = None,
|
||||||
rescale_factor: Optional[float] = None,
|
rescale_factor: Optional[float] = None,
|
||||||
do_normalize: Optional[bool] = None,
|
do_normalize: Optional[bool] = None,
|
||||||
|
@ -553,13 +553,13 @@ class DetaImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
format: Union[str, AnnotationFormat] = AnnotationFormat.COCO_DETECTION,
|
format: Union[str, AnnotationFormat] = AnnotationFormat.COCO_DETECTION,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
image_mean: Union[float, List[float]] = None,
|
image_mean: Optional[Union[float, List[float]]] = None,
|
||||||
image_std: Union[float, List[float]] = None,
|
image_std: Optional[Union[float, List[float]]] = None,
|
||||||
do_convert_annotations: bool = True,
|
do_convert_annotations: bool = True,
|
||||||
do_pad: bool = True,
|
do_pad: bool = True,
|
||||||
pad_size: Optional[Dict[str, int]] = None,
|
pad_size: Optional[Dict[str, int]] = None,
|
||||||
|
@ -91,7 +91,7 @@ class EfficientFormerImageProcessor(BaseImageProcessor):
|
|||||||
do_center_crop: bool = True,
|
do_center_crop: bool = True,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
image_mean: Optional[Union[float, List[float]]] = None,
|
image_mean: Optional[Union[float, List[float]]] = None,
|
||||||
image_std: Optional[Union[float, List[float]]] = None,
|
image_std: Optional[Union[float, List[float]]] = None,
|
||||||
@ -179,7 +179,7 @@ class EfficientFormerImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Optional[int] = None,
|
crop_size: Optional[int] = None,
|
||||||
|
@ -1684,7 +1684,7 @@ class MegaForCausalLM(MegaPreTrainedModel):
|
|||||||
encoder_hidden_states: Optional[torch.FloatTensor] = None,
|
encoder_hidden_states: Optional[torch.FloatTensor] = None,
|
||||||
encoder_attention_mask: Optional[torch.FloatTensor] = None,
|
encoder_attention_mask: Optional[torch.FloatTensor] = None,
|
||||||
labels: Optional[torch.LongTensor] = None,
|
labels: Optional[torch.LongTensor] = None,
|
||||||
past_key_values: Tuple[Tuple[torch.FloatTensor]] = None,
|
past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
|
||||||
use_cache: Optional[bool] = None,
|
use_cache: Optional[bool] = None,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
|
@ -497,7 +497,7 @@ class TapexTokenizer(PreTrainedTokenizer):
|
|||||||
self,
|
self,
|
||||||
table: Union["pd.DataFrame", List["pd.DataFrame"]] = None,
|
table: Union["pd.DataFrame", List["pd.DataFrame"]] = None,
|
||||||
query: Optional[Union[TextInput, List[TextInput]]] = None,
|
query: Optional[Union[TextInput, List[TextInput]]] = None,
|
||||||
answer: Union[str, List[str]] = None,
|
answer: Optional[Union[str, List[str]]] = None,
|
||||||
add_special_tokens: bool = True,
|
add_special_tokens: bool = True,
|
||||||
padding: Union[bool, str, PaddingStrategy] = False,
|
padding: Union[bool, str, PaddingStrategy] = False,
|
||||||
truncation: Union[bool, str, TruncationStrategy] = None,
|
truncation: Union[bool, str, TruncationStrategy] = None,
|
||||||
@ -574,7 +574,7 @@ class TapexTokenizer(PreTrainedTokenizer):
|
|||||||
self,
|
self,
|
||||||
table: Union["pd.DataFrame", List["pd.DataFrame"]],
|
table: Union["pd.DataFrame", List["pd.DataFrame"]],
|
||||||
query: Optional[Union[TextInput, List[TextInput]]] = None,
|
query: Optional[Union[TextInput, List[TextInput]]] = None,
|
||||||
answer: Union[str, List[str]] = None,
|
answer: Optional[Union[str, List[str]]] = None,
|
||||||
add_special_tokens: bool = True,
|
add_special_tokens: bool = True,
|
||||||
padding: Union[bool, str, PaddingStrategy] = False,
|
padding: Union[bool, str, PaddingStrategy] = False,
|
||||||
truncation: Union[bool, str, TruncationStrategy] = None,
|
truncation: Union[bool, str, TruncationStrategy] = None,
|
||||||
@ -662,10 +662,10 @@ class TapexTokenizer(PreTrainedTokenizer):
|
|||||||
self,
|
self,
|
||||||
table: Union["pd.DataFrame", List["pd.DataFrame"]],
|
table: Union["pd.DataFrame", List["pd.DataFrame"]],
|
||||||
query: Optional[List[TextInput]] = None,
|
query: Optional[List[TextInput]] = None,
|
||||||
answer: List[str] = None,
|
answer: Optional[List[str]] = None,
|
||||||
add_special_tokens: bool = True,
|
add_special_tokens: bool = True,
|
||||||
padding: Union[bool, str, PaddingStrategy] = False,
|
padding: Union[bool, str, PaddingStrategy] = False,
|
||||||
truncation: Union[bool, str] = None,
|
truncation: Optional[Union[bool, str]] = None,
|
||||||
max_length: Optional[int] = None,
|
max_length: Optional[int] = None,
|
||||||
pad_to_multiple_of: Optional[int] = None,
|
pad_to_multiple_of: Optional[int] = None,
|
||||||
return_tensors: Optional[Union[str, TensorType]] = None,
|
return_tensors: Optional[Union[str, TensorType]] = None,
|
||||||
@ -884,7 +884,7 @@ class TapexTokenizer(PreTrainedTokenizer):
|
|||||||
answer: Optional[str] = None,
|
answer: Optional[str] = None,
|
||||||
add_special_tokens: bool = True,
|
add_special_tokens: bool = True,
|
||||||
padding: Union[bool, str, PaddingStrategy] = False,
|
padding: Union[bool, str, PaddingStrategy] = False,
|
||||||
truncation: Union[bool, str] = None,
|
truncation: Optional[Union[bool, str]] = None,
|
||||||
max_length: Optional[int] = None,
|
max_length: Optional[int] = None,
|
||||||
pad_to_multiple_of: Optional[int] = None,
|
pad_to_multiple_of: Optional[int] = None,
|
||||||
return_tensors: Optional[Union[str, TensorType]] = None,
|
return_tensors: Optional[Union[str, TensorType]] = None,
|
||||||
@ -1053,7 +1053,7 @@ class TapexTokenizer(PreTrainedTokenizer):
|
|||||||
answer: List[str],
|
answer: List[str],
|
||||||
add_special_tokens: bool = True,
|
add_special_tokens: bool = True,
|
||||||
padding: Union[bool, str, PaddingStrategy] = False,
|
padding: Union[bool, str, PaddingStrategy] = False,
|
||||||
truncation: Union[bool, str] = None,
|
truncation: Optional[Union[bool, str]] = None,
|
||||||
max_length: Optional[int] = None,
|
max_length: Optional[int] = None,
|
||||||
pad_to_multiple_of: Optional[int] = None,
|
pad_to_multiple_of: Optional[int] = None,
|
||||||
return_tensors: Optional[Union[str, TensorType]] = None,
|
return_tensors: Optional[Union[str, TensorType]] = None,
|
||||||
@ -1197,7 +1197,7 @@ class TapexTokenizer(PreTrainedTokenizer):
|
|||||||
answer: str,
|
answer: str,
|
||||||
add_special_tokens: bool = True,
|
add_special_tokens: bool = True,
|
||||||
padding: Union[bool, str, PaddingStrategy] = False,
|
padding: Union[bool, str, PaddingStrategy] = False,
|
||||||
truncation: Union[bool, str] = None,
|
truncation: Optional[Union[bool, str]] = None,
|
||||||
max_length: Optional[int] = None,
|
max_length: Optional[int] = None,
|
||||||
pad_to_multiple_of: Optional[int] = None,
|
pad_to_multiple_of: Optional[int] = None,
|
||||||
return_tensors: Optional[Union[str, TensorType]] = None,
|
return_tensors: Optional[Union[str, TensorType]] = None,
|
||||||
|
@ -121,12 +121,12 @@ class TvltImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
patch_size: List[int] = [16, 16],
|
patch_size: List[int] = [16, 16],
|
||||||
num_frames: int = 8,
|
num_frames: int = 8,
|
||||||
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
||||||
do_center_crop: bool = True,
|
do_center_crop: bool = True,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
@ -221,10 +221,10 @@ class TvltImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
image: ImageInput,
|
image: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: Optional[bool] = None,
|
do_rescale: Optional[bool] = None,
|
||||||
rescale_factor: Optional[float] = None,
|
rescale_factor: Optional[float] = None,
|
||||||
do_normalize: Optional[bool] = None,
|
do_normalize: Optional[bool] = None,
|
||||||
@ -278,12 +278,12 @@ class TvltImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
videos: ImageInput,
|
videos: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
patch_size: List[int] = None,
|
patch_size: Optional[List[int]] = None,
|
||||||
num_frames: Optional[int] = None,
|
num_frames: Optional[int] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: Optional[bool] = None,
|
do_rescale: Optional[bool] = None,
|
||||||
rescale_factor: Optional[float] = None,
|
rescale_factor: Optional[float] = None,
|
||||||
do_normalize: Optional[bool] = None,
|
do_normalize: Optional[bool] = None,
|
||||||
|
@ -93,10 +93,10 @@ class ViTHybridImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
||||||
do_center_crop: bool = True,
|
do_center_crop: bool = True,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
@ -193,7 +193,7 @@ class ViTHybridImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Optional[int] = None,
|
crop_size: Optional[int] = None,
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import gc
|
import gc
|
||||||
import os
|
import os
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import regex as re
|
import regex as re
|
||||||
import torch
|
import torch
|
||||||
@ -93,7 +94,7 @@ ORIGINAL_TO_CONVERTED_KEY_MAPPING = {
|
|||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
|
|
||||||
def convert_old_keys_to_new_keys(state_dict_keys: dict = None):
|
def convert_old_keys_to_new_keys(state_dict_keys: Optional[dict] = None):
|
||||||
output_dict = {}
|
output_dict = {}
|
||||||
if state_dict_keys is not None:
|
if state_dict_keys is not None:
|
||||||
old_text = "\n".join(state_dict_keys)
|
old_text = "\n".join(state_dict_keys)
|
||||||
|
@ -732,7 +732,7 @@ def compute_segments(
|
|||||||
mask_threshold: float = 0.5,
|
mask_threshold: float = 0.5,
|
||||||
overlap_mask_area_threshold: float = 0.8,
|
overlap_mask_area_threshold: float = 0.8,
|
||||||
label_ids_to_fuse: Optional[Set[int]] = None,
|
label_ids_to_fuse: Optional[Set[int]] = None,
|
||||||
target_size: Tuple[int, int] = None,
|
target_size: Optional[Tuple[int, int]] = None,
|
||||||
):
|
):
|
||||||
height = mask_probs.shape[1] if target_size is None else target_size[0]
|
height = mask_probs.shape[1] if target_size is None else target_size[0]
|
||||||
width = mask_probs.shape[2] if target_size is None else target_size[1]
|
width = mask_probs.shape[2] if target_size is None else target_size[1]
|
||||||
@ -845,13 +845,13 @@ class DetrImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
format: Union[str, AnnotationFormat] = AnnotationFormat.COCO_DETECTION,
|
format: Union[str, AnnotationFormat] = AnnotationFormat.COCO_DETECTION,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
image_mean: Union[float, List[float]] = None,
|
image_mean: Optional[Union[float, List[float]]] = None,
|
||||||
image_std: Union[float, List[float]] = None,
|
image_std: Optional[Union[float, List[float]]] = None,
|
||||||
do_convert_annotations: Optional[bool] = None,
|
do_convert_annotations: Optional[bool] = None,
|
||||||
do_pad: bool = True,
|
do_pad: bool = True,
|
||||||
pad_size: Optional[Dict[str, int]] = None,
|
pad_size: Optional[Dict[str, int]] = None,
|
||||||
@ -1824,7 +1824,7 @@ class DetrImageProcessor(BaseImageProcessor):
|
|||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def post_process_semantic_segmentation(self, outputs, target_sizes: List[Tuple[int, int]] = None):
|
def post_process_semantic_segmentation(self, outputs, target_sizes: Optional[List[Tuple[int, int]]] = None):
|
||||||
"""
|
"""
|
||||||
Converts the output of [`DetrForSegmentation`] into semantic segmentation maps. Only supports PyTorch.
|
Converts the output of [`DetrForSegmentation`] into semantic segmentation maps. Only supports PyTorch.
|
||||||
|
|
||||||
|
@ -1088,7 +1088,7 @@ class DetrImageProcessorFast(BaseImageProcessorFast):
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
# Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.post_process_semantic_segmentation
|
# Copied from transformers.models.detr.image_processing_detr.DetrImageProcessor.post_process_semantic_segmentation
|
||||||
def post_process_semantic_segmentation(self, outputs, target_sizes: List[Tuple[int, int]] = None):
|
def post_process_semantic_segmentation(self, outputs, target_sizes: Optional[List[Tuple[int, int]]] = None):
|
||||||
"""
|
"""
|
||||||
Converts the output of [`DetrForSegmentation`] into semantic segmentation maps. Only supports PyTorch.
|
Converts the output of [`DetrForSegmentation`] into semantic segmentation maps. Only supports PyTorch.
|
||||||
|
|
||||||
|
@ -592,7 +592,7 @@ class FlaxDinov2PreTrainedModel(FlaxPreTrainedModel):
|
|||||||
def __call__(
|
def __call__(
|
||||||
self,
|
self,
|
||||||
pixel_values,
|
pixel_values,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: jax.random.PRNGKey = None,
|
dropout_rng: jax.random.PRNGKey = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
|
@ -459,7 +459,7 @@ class FlaxDistilBertPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
input_ids,
|
input_ids,
|
||||||
attention_mask=None,
|
attention_mask=None,
|
||||||
head_mask=None,
|
head_mask=None,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: jax.random.PRNGKey = None,
|
dropout_rng: jax.random.PRNGKey = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
|
@ -94,7 +94,7 @@ class DonutImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
||||||
do_thumbnail: bool = True,
|
do_thumbnail: bool = True,
|
||||||
do_align_long_axis: bool = False,
|
do_align_long_axis: bool = False,
|
||||||
@ -313,7 +313,7 @@ class DonutImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_thumbnail: Optional[bool] = None,
|
do_thumbnail: Optional[bool] = None,
|
||||||
do_align_long_axis: Optional[bool] = None,
|
do_align_long_axis: Optional[bool] = None,
|
||||||
|
@ -154,7 +154,7 @@ class DPTImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
||||||
keep_aspect_ratio: bool = False,
|
keep_aspect_ratio: bool = False,
|
||||||
ensure_multiple_of: int = 1,
|
ensure_multiple_of: int = 1,
|
||||||
@ -299,7 +299,7 @@ class DPTImageProcessor(BaseImageProcessor):
|
|||||||
image: ImageInput,
|
image: ImageInput,
|
||||||
do_reduce_labels: Optional[bool] = None,
|
do_reduce_labels: Optional[bool] = None,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
keep_aspect_ratio: Optional[bool] = None,
|
keep_aspect_ratio: Optional[bool] = None,
|
||||||
ensure_multiple_of: Optional[int] = None,
|
ensure_multiple_of: Optional[int] = None,
|
||||||
@ -340,7 +340,7 @@ class DPTImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
image: ImageInput,
|
image: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
keep_aspect_ratio: Optional[bool] = None,
|
keep_aspect_ratio: Optional[bool] = None,
|
||||||
ensure_multiple_of: Optional[int] = None,
|
ensure_multiple_of: Optional[int] = None,
|
||||||
@ -391,7 +391,7 @@ class DPTImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
segmentation_map: ImageInput,
|
segmentation_map: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
keep_aspect_ratio: Optional[bool] = None,
|
keep_aspect_ratio: Optional[bool] = None,
|
||||||
ensure_multiple_of: Optional[int] = None,
|
ensure_multiple_of: Optional[int] = None,
|
||||||
@ -592,7 +592,7 @@ class DPTImageProcessor(BaseImageProcessor):
|
|||||||
return BatchFeature(data=data, tensor_type=return_tensors)
|
return BatchFeature(data=data, tensor_type=return_tensors)
|
||||||
|
|
||||||
# Copied from transformers.models.beit.image_processing_beit.BeitImageProcessor.post_process_semantic_segmentation with Beit->DPT
|
# Copied from transformers.models.beit.image_processing_beit.BeitImageProcessor.post_process_semantic_segmentation with Beit->DPT
|
||||||
def post_process_semantic_segmentation(self, outputs, target_sizes: List[Tuple] = None):
|
def post_process_semantic_segmentation(self, outputs, target_sizes: Optional[List[Tuple]] = None):
|
||||||
"""
|
"""
|
||||||
Converts the output of [`DPTForSemanticSegmentation`] into semantic segmentation maps. Only supports PyTorch.
|
Converts the output of [`DPTForSemanticSegmentation`] into semantic segmentation maps. Only supports PyTorch.
|
||||||
|
|
||||||
|
@ -87,10 +87,10 @@ class EfficientNetImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PIL.Image.NEAREST,
|
resample: PILImageResampling = PIL.Image.NEAREST,
|
||||||
do_center_crop: bool = False,
|
do_center_crop: bool = False,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
rescale_offset: bool = False,
|
rescale_offset: bool = False,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
@ -213,10 +213,10 @@ class EfficientNetImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample=None,
|
resample=None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: Optional[bool] = None,
|
do_rescale: Optional[bool] = None,
|
||||||
rescale_factor: Optional[float] = None,
|
rescale_factor: Optional[float] = None,
|
||||||
rescale_offset: Optional[bool] = None,
|
rescale_offset: Optional[bool] = None,
|
||||||
|
@ -777,13 +777,13 @@ class FlaxElectraPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
head_mask=None,
|
head_mask=None,
|
||||||
encoder_hidden_states=None,
|
encoder_hidden_states=None,
|
||||||
encoder_attention_mask=None,
|
encoder_attention_mask=None,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: jax.random.PRNGKey = None,
|
dropout_rng: jax.random.PRNGKey = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
):
|
):
|
||||||
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
||||||
output_hidden_states = (
|
output_hidden_states = (
|
||||||
|
@ -304,7 +304,7 @@ class Emu3Config(PretrainedConfig):
|
|||||||
self,
|
self,
|
||||||
vq_config: Union[Dict, Emu3VQVAEConfig] = None,
|
vq_config: Union[Dict, Emu3VQVAEConfig] = None,
|
||||||
text_config: Union[Dict, Emu3TextConfig] = None,
|
text_config: Union[Dict, Emu3TextConfig] = None,
|
||||||
vocabulary_map: Dict[int, int] = None,
|
vocabulary_map: Optional[Dict[int, int]] = None,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
if vq_config is None:
|
if vq_config is None:
|
||||||
|
@ -309,7 +309,7 @@ class Emu3ImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_rescale: Optional[bool] = None,
|
do_rescale: Optional[bool] = None,
|
||||||
rescale_factor: Optional[float] = None,
|
rescale_factor: Optional[float] = None,
|
||||||
|
@ -550,7 +550,7 @@ class EncoderDecoderModel(PreTrainedModel, GenerationMixin):
|
|||||||
decoder_input_ids: Optional[torch.LongTensor] = None,
|
decoder_input_ids: Optional[torch.LongTensor] = None,
|
||||||
decoder_attention_mask: Optional[torch.BoolTensor] = None,
|
decoder_attention_mask: Optional[torch.BoolTensor] = None,
|
||||||
encoder_outputs: Optional[Tuple[torch.FloatTensor]] = None,
|
encoder_outputs: Optional[Tuple[torch.FloatTensor]] = None,
|
||||||
past_key_values: Tuple[Tuple[torch.FloatTensor]] = None,
|
past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
|
||||||
inputs_embeds: Optional[torch.FloatTensor] = None,
|
inputs_embeds: Optional[torch.FloatTensor] = None,
|
||||||
decoder_inputs_embeds: Optional[torch.FloatTensor] = None,
|
decoder_inputs_embeds: Optional[torch.FloatTensor] = None,
|
||||||
labels: Optional[torch.LongTensor] = None,
|
labels: Optional[torch.LongTensor] = None,
|
||||||
|
@ -436,7 +436,7 @@ class FlaxEncoderDecoderModel(FlaxPreTrainedModel):
|
|||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: PRNGKey = None,
|
dropout_rng: PRNGKey = None,
|
||||||
):
|
):
|
||||||
r"""
|
r"""
|
||||||
@ -508,12 +508,12 @@ class FlaxEncoderDecoderModel(FlaxPreTrainedModel):
|
|||||||
encoder_attention_mask: Optional[jnp.ndarray] = None,
|
encoder_attention_mask: Optional[jnp.ndarray] = None,
|
||||||
decoder_attention_mask: Optional[jnp.ndarray] = None,
|
decoder_attention_mask: Optional[jnp.ndarray] = None,
|
||||||
decoder_position_ids: Optional[jnp.ndarray] = None,
|
decoder_position_ids: Optional[jnp.ndarray] = None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: PRNGKey = None,
|
dropout_rng: PRNGKey = None,
|
||||||
):
|
):
|
||||||
r"""
|
r"""
|
||||||
@ -638,7 +638,7 @@ class FlaxEncoderDecoderModel(FlaxPreTrainedModel):
|
|||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
dropout_rng: PRNGKey = None,
|
dropout_rng: PRNGKey = None,
|
||||||
):
|
):
|
||||||
r"""
|
r"""
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
"""FastSpeech2Conformer model configuration"""
|
"""FastSpeech2Conformer model configuration"""
|
||||||
|
|
||||||
from typing import Dict
|
from typing import Dict, Optional
|
||||||
|
|
||||||
from ...configuration_utils import PretrainedConfig
|
from ...configuration_utils import PretrainedConfig
|
||||||
from ...utils import logging
|
from ...utils import logging
|
||||||
@ -459,8 +459,8 @@ class FastSpeech2ConformerWithHifiGanConfig(PretrainedConfig):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
model_config: Dict = None,
|
model_config: Optional[Dict] = None,
|
||||||
vocoder_config: Dict = None,
|
vocoder_config: Optional[Dict] = None,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
if model_config is None:
|
if model_config is None:
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
"""FLAVA model configurations"""
|
"""FLAVA model configurations"""
|
||||||
|
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
from ...configuration_utils import PretrainedConfig
|
from ...configuration_utils import PretrainedConfig
|
||||||
from ...utils import logging
|
from ...utils import logging
|
||||||
@ -472,10 +472,10 @@ class FlavaConfig(PretrainedConfig):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
image_config: Dict[str, Any] = None,
|
image_config: Optional[Dict[str, Any]] = None,
|
||||||
text_config: Dict[str, Any] = None,
|
text_config: Optional[Dict[str, Any]] = None,
|
||||||
multimodal_config: Dict[str, Any] = None,
|
multimodal_config: Optional[Dict[str, Any]] = None,
|
||||||
image_codebook_config: Dict[str, Any] = None,
|
image_codebook_config: Optional[Dict[str, Any]] = None,
|
||||||
hidden_size: int = 768,
|
hidden_size: int = 768,
|
||||||
layer_norm_eps: float = 1e-12,
|
layer_norm_eps: float = 1e-12,
|
||||||
projection_dim: int = 768,
|
projection_dim: int = 768,
|
||||||
|
@ -228,10 +228,10 @@ class FlavaImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
||||||
do_center_crop: bool = True,
|
do_center_crop: bool = True,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
@ -392,10 +392,10 @@ class FlavaImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
image: ImageInput,
|
image: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: Optional[bool] = None,
|
do_rescale: Optional[bool] = None,
|
||||||
rescale_factor: Optional[float] = None,
|
rescale_factor: Optional[float] = None,
|
||||||
do_normalize: Optional[bool] = None,
|
do_normalize: Optional[bool] = None,
|
||||||
@ -457,7 +457,7 @@ class FlavaImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_center_crop: Optional[bool] = None,
|
do_center_crop: Optional[bool] = None,
|
||||||
crop_size: Optional[Dict[str, int]] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
|
@ -537,7 +537,7 @@ class FuyuImageProcessor(BaseImageProcessor):
|
|||||||
}
|
}
|
||||||
return FuyuBatchFeature(data=data, tensor_type=return_tensors)
|
return FuyuBatchFeature(data=data, tensor_type=return_tensors)
|
||||||
|
|
||||||
def get_num_patches(self, image_height: int, image_width: int, patch_size: Dict[str, int] = None) -> int:
|
def get_num_patches(self, image_height: int, image_width: int, patch_size: Optional[Dict[str, int]] = None) -> int:
|
||||||
"""
|
"""
|
||||||
Calculate number of patches required to encode an image.
|
Calculate number of patches required to encode an image.
|
||||||
|
|
||||||
|
@ -485,8 +485,8 @@ class FlaxGemmaPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
input_ids,
|
input_ids,
|
||||||
attention_mask=None,
|
attention_mask=None,
|
||||||
position_ids=None,
|
position_ids=None,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
dropout_rng: jax.random.PRNGKey = None,
|
dropout_rng: jax.random.PRNGKey = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
|
@ -95,7 +95,7 @@ class Gemma3ImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
@ -241,7 +241,7 @@ class Gemma3ImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_rescale: Optional[bool] = None,
|
do_rescale: Optional[bool] = None,
|
||||||
rescale_factor: Optional[float] = None,
|
rescale_factor: Optional[float] = None,
|
||||||
|
@ -61,7 +61,7 @@ ORIGINAL_TO_CONVERTED_KEY_MAPPING = {
|
|||||||
CONTEXT_LENGTH = 8000
|
CONTEXT_LENGTH = 8000
|
||||||
|
|
||||||
|
|
||||||
def convert_old_keys_to_new_keys(state_dict_keys: dict = None):
|
def convert_old_keys_to_new_keys(state_dict_keys: Optional[dict] = None):
|
||||||
"""
|
"""
|
||||||
This function should be applied only once, on the concatenated keys to efficiently rename using
|
This function should be applied only once, on the concatenated keys to efficiently rename using
|
||||||
the key mappings.
|
the key mappings.
|
||||||
|
@ -172,7 +172,7 @@ class GotOcr2ImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
crop_to_patches: bool = False,
|
crop_to_patches: bool = False,
|
||||||
min_patches: int = 1,
|
min_patches: int = 1,
|
||||||
max_patches: int = 12,
|
max_patches: int = 12,
|
||||||
@ -419,7 +419,7 @@ class GotOcr2ImageProcessor(BaseImageProcessor):
|
|||||||
min_patches: int,
|
min_patches: int,
|
||||||
max_patches: int,
|
max_patches: int,
|
||||||
use_thumbnail: bool = True,
|
use_thumbnail: bool = True,
|
||||||
patch_size: Union[Tuple, int, dict] = None,
|
patch_size: Optional[Union[Tuple, int, dict]] = None,
|
||||||
data_format: ChannelDimension = None,
|
data_format: ChannelDimension = None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
|
@ -114,7 +114,7 @@ class GotOcr2ImageProcessorFast(BaseImageProcessorFast):
|
|||||||
min_patches: int,
|
min_patches: int,
|
||||||
max_patches: int,
|
max_patches: int,
|
||||||
use_thumbnail: bool = True,
|
use_thumbnail: bool = True,
|
||||||
patch_size: Union[Tuple, int, dict] = None,
|
patch_size: Optional[Union[Tuple, int, dict]] = None,
|
||||||
interpolation: Optional["F.InterpolationMode"] = None,
|
interpolation: Optional["F.InterpolationMode"] = None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
|
@ -194,7 +194,7 @@ class GPT2OnnxConfig(OnnxConfigWithPast):
|
|||||||
self,
|
self,
|
||||||
config: PretrainedConfig,
|
config: PretrainedConfig,
|
||||||
task: str = "default",
|
task: str = "default",
|
||||||
patching_specs: List[PatchingSpec] = None,
|
patching_specs: Optional[List[PatchingSpec]] = None,
|
||||||
use_past: bool = False,
|
use_past: bool = False,
|
||||||
):
|
):
|
||||||
super().__init__(config, task=task, patching_specs=patching_specs, use_past=use_past)
|
super().__init__(config, task=task, patching_specs=patching_specs, use_past=use_past)
|
||||||
|
@ -461,8 +461,8 @@ class FlaxGPT2PreTrainedModel(FlaxPreTrainedModel):
|
|||||||
position_ids=None,
|
position_ids=None,
|
||||||
encoder_hidden_states: Optional[jnp.ndarray] = None,
|
encoder_hidden_states: Optional[jnp.ndarray] = None,
|
||||||
encoder_attention_mask: Optional[jnp.ndarray] = None,
|
encoder_attention_mask: Optional[jnp.ndarray] = None,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
dropout_rng: jax.random.PRNGKey = None,
|
dropout_rng: jax.random.PRNGKey = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
|
@ -404,8 +404,8 @@ class FlaxGPTNeoPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
input_ids,
|
input_ids,
|
||||||
attention_mask=None,
|
attention_mask=None,
|
||||||
position_ids=None,
|
position_ids=None,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
dropout_rng: jax.random.PRNGKey = None,
|
dropout_rng: jax.random.PRNGKey = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
|
@ -140,7 +140,7 @@ class GPTJOnnxConfig(OnnxConfigWithPast):
|
|||||||
self,
|
self,
|
||||||
config: PretrainedConfig,
|
config: PretrainedConfig,
|
||||||
task: str = "default",
|
task: str = "default",
|
||||||
patching_specs: List[PatchingSpec] = None,
|
patching_specs: Optional[List[PatchingSpec]] = None,
|
||||||
use_past: bool = False,
|
use_past: bool = False,
|
||||||
):
|
):
|
||||||
super().__init__(config, task=task, patching_specs=patching_specs, use_past=use_past)
|
super().__init__(config, task=task, patching_specs=patching_specs, use_past=use_past)
|
||||||
|
@ -438,8 +438,8 @@ class FlaxGPTJPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
input_ids,
|
input_ids,
|
||||||
attention_mask=None,
|
attention_mask=None,
|
||||||
position_ids=None,
|
position_ids=None,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
dropout_rng: jax.random.PRNGKey = None,
|
dropout_rng: jax.random.PRNGKey = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
|
@ -756,7 +756,7 @@ def compute_segments(
|
|||||||
mask_threshold: float = 0.5,
|
mask_threshold: float = 0.5,
|
||||||
overlap_mask_area_threshold: float = 0.8,
|
overlap_mask_area_threshold: float = 0.8,
|
||||||
label_ids_to_fuse: Optional[Set[int]] = None,
|
label_ids_to_fuse: Optional[Set[int]] = None,
|
||||||
target_size: Tuple[int, int] = None,
|
target_size: Optional[Tuple[int, int]] = None,
|
||||||
):
|
):
|
||||||
height = mask_probs.shape[1] if target_size is None else target_size[0]
|
height = mask_probs.shape[1] if target_size is None else target_size[0]
|
||||||
width = mask_probs.shape[2] if target_size is None else target_size[1]
|
width = mask_probs.shape[2] if target_size is None else target_size[1]
|
||||||
@ -899,13 +899,13 @@ class GroundingDinoImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
format: Union[str, AnnotationFormat] = AnnotationFormat.COCO_DETECTION,
|
format: Union[str, AnnotationFormat] = AnnotationFormat.COCO_DETECTION,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
image_mean: Union[float, List[float]] = None,
|
image_mean: Optional[Union[float, List[float]]] = None,
|
||||||
image_std: Union[float, List[float]] = None,
|
image_std: Optional[Union[float, List[float]]] = None,
|
||||||
do_convert_annotations: Optional[bool] = None,
|
do_convert_annotations: Optional[bool] = None,
|
||||||
do_pad: bool = True,
|
do_pad: bool = True,
|
||||||
pad_size: Optional[Dict[str, int]] = None,
|
pad_size: Optional[Dict[str, int]] = None,
|
||||||
|
@ -2554,7 +2554,7 @@ class GroundingDinoForObjectDetection(GroundingDinoPreTrainedModel):
|
|||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
output_hidden_states: Optional[bool] = None,
|
output_hidden_states: Optional[bool] = None,
|
||||||
return_dict: Optional[bool] = None,
|
return_dict: Optional[bool] = None,
|
||||||
labels: List[Dict[str, Union[torch.LongTensor, torch.FloatTensor]]] = None,
|
labels: Optional[List[Dict[str, Union[torch.LongTensor, torch.FloatTensor]]]] = None,
|
||||||
):
|
):
|
||||||
r"""
|
r"""
|
||||||
labels (`List[Dict]` of len `(batch_size,)`, *optional*):
|
labels (`List[Dict]` of len `(batch_size,)`, *optional*):
|
||||||
|
@ -101,7 +101,7 @@ class IdeficsImageProcessor(BaseImageProcessor):
|
|||||||
image_size: Optional[Dict[str, int]] = None,
|
image_size: Optional[Dict[str, int]] = None,
|
||||||
image_mean: Optional[Union[float, List[float]]] = None,
|
image_mean: Optional[Union[float, List[float]]] = None,
|
||||||
image_std: Optional[Union[float, List[float]]] = None,
|
image_std: Optional[Union[float, List[float]]] = None,
|
||||||
transform: Callable = None,
|
transform: Optional[Callable] = None,
|
||||||
do_rescale: Optional[bool] = None,
|
do_rescale: Optional[bool] = None,
|
||||||
rescale_factor: Optional[float] = None,
|
rescale_factor: Optional[float] = None,
|
||||||
return_tensors: Optional[Union[str, TensorType]] = TensorType.PYTORCH,
|
return_tensors: Optional[Union[str, TensorType]] = TensorType.PYTORCH,
|
||||||
|
@ -190,7 +190,7 @@ class Idefics2ImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
do_convert_rgb: bool = True,
|
do_convert_rgb: bool = True,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: float = 1 / 255,
|
rescale_factor: float = 1 / 255,
|
||||||
|
@ -295,10 +295,10 @@ class Idefics3ImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
do_convert_rgb: bool = True,
|
do_convert_rgb: bool = True,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.LANCZOS,
|
resample: PILImageResampling = PILImageResampling.LANCZOS,
|
||||||
do_image_splitting: bool = True,
|
do_image_splitting: bool = True,
|
||||||
max_image_size: Dict[str, int] = None,
|
max_image_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: float = 1 / 255,
|
rescale_factor: float = 1 / 255,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
|
@ -21,6 +21,7 @@ import argparse
|
|||||||
import gc
|
import gc
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import torch
|
import torch
|
||||||
@ -63,7 +64,7 @@ ORIGINAL_TO_CONVERTED_KEY_MAPPING = {
|
|||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
|
|
||||||
def convert_old_keys_to_new_keys(state_dict_keys: dict = None):
|
def convert_old_keys_to_new_keys(state_dict_keys: Optional[dict] = None):
|
||||||
"""
|
"""
|
||||||
Converts old keys to new keys using the mapping and dynamically removes the 'ijepa.' prefix if necessary.
|
Converts old keys to new keys using the mapping and dynamically removes the 'ijepa.' prefix if necessary.
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ class ImageGPTImageProcessor(BaseImageProcessor):
|
|||||||
# clusters is a first argument to maintain backwards compatibility with the old ImageGPTImageProcessor
|
# clusters is a first argument to maintain backwards compatibility with the old ImageGPTImageProcessor
|
||||||
clusters: Optional[Union[List[List[int]], np.ndarray]] = None,
|
clusters: Optional[Union[List[List[int]], np.ndarray]] = None,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
do_color_quantize: bool = True,
|
do_color_quantize: bool = True,
|
||||||
@ -180,7 +180,7 @@ class ImageGPTImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
do_normalize: Optional[bool] = None,
|
do_normalize: Optional[bool] = None,
|
||||||
do_color_quantize: Optional[bool] = None,
|
do_color_quantize: Optional[bool] = None,
|
||||||
|
@ -141,7 +141,7 @@ class InformerConfig(PretrainedConfig):
|
|||||||
distribution_output: str = "student_t",
|
distribution_output: str = "student_t",
|
||||||
loss: str = "nll",
|
loss: str = "nll",
|
||||||
input_size: int = 1,
|
input_size: int = 1,
|
||||||
lags_sequence: List[int] = None,
|
lags_sequence: Optional[List[int]] = None,
|
||||||
scaling: Optional[Union[str, bool]] = "mean",
|
scaling: Optional[Union[str, bool]] = "mean",
|
||||||
num_dynamic_real_features: int = 0,
|
num_dynamic_real_features: int = 0,
|
||||||
num_static_real_features: int = 0,
|
num_static_real_features: int = 0,
|
||||||
|
@ -84,7 +84,7 @@ class InstructBlipVideoImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
|
@ -139,7 +139,7 @@ class LayoutLMOnnxConfig(OnnxConfig):
|
|||||||
self,
|
self,
|
||||||
config: PretrainedConfig,
|
config: PretrainedConfig,
|
||||||
task: str = "default",
|
task: str = "default",
|
||||||
patching_specs: List[PatchingSpec] = None,
|
patching_specs: Optional[List[PatchingSpec]] = None,
|
||||||
):
|
):
|
||||||
super().__init__(config, task=task, patching_specs=patching_specs)
|
super().__init__(config, task=task, patching_specs=patching_specs)
|
||||||
self.max_2d_positions = config.max_2d_position_embeddings - 1
|
self.max_2d_positions = config.max_2d_position_embeddings - 1
|
||||||
|
@ -129,7 +129,7 @@ class LayoutLMv2ImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
||||||
apply_ocr: bool = True,
|
apply_ocr: bool = True,
|
||||||
ocr_lang: Optional[str] = None,
|
ocr_lang: Optional[str] = None,
|
||||||
@ -201,7 +201,7 @@ class LayoutLMv2ImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = None,
|
resample: PILImageResampling = None,
|
||||||
apply_ocr: Optional[bool] = None,
|
apply_ocr: Optional[bool] = None,
|
||||||
ocr_lang: Optional[str] = None,
|
ocr_lang: Optional[str] = None,
|
||||||
|
@ -71,7 +71,7 @@ class LayoutLMv2Processor(ProcessorMixin):
|
|||||||
images,
|
images,
|
||||||
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None,
|
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None,
|
||||||
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
||||||
boxes: Union[List[List[int]], List[List[List[int]]]] = None,
|
boxes: Optional[Union[List[List[int]], List[List[List[int]]]]] = None,
|
||||||
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
||||||
add_special_tokens: bool = True,
|
add_special_tokens: bool = True,
|
||||||
padding: Union[bool, str, PaddingStrategy] = False,
|
padding: Union[bool, str, PaddingStrategy] = False,
|
||||||
|
@ -406,7 +406,7 @@ class LayoutLMv2Tokenizer(PreTrainedTokenizer):
|
|||||||
self,
|
self,
|
||||||
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]],
|
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]],
|
||||||
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
||||||
boxes: Union[List[List[int]], List[List[List[int]]]] = None,
|
boxes: Optional[Union[List[List[int]], List[List[List[int]]]]] = None,
|
||||||
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
||||||
add_special_tokens: bool = True,
|
add_special_tokens: bool = True,
|
||||||
padding: Union[bool, str, PaddingStrategy] = False,
|
padding: Union[bool, str, PaddingStrategy] = False,
|
||||||
|
@ -157,7 +157,7 @@ class LayoutLMv2TokenizerFast(PreTrainedTokenizerFast):
|
|||||||
self,
|
self,
|
||||||
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]],
|
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]],
|
||||||
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
||||||
boxes: Union[List[List[int]], List[List[List[int]]]] = None,
|
boxes: Optional[Union[List[List[int]], List[List[List[int]]]]] = None,
|
||||||
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
||||||
add_special_tokens: bool = True,
|
add_special_tokens: bool = True,
|
||||||
padding: Union[bool, str, PaddingStrategy] = False,
|
padding: Union[bool, str, PaddingStrategy] = False,
|
||||||
|
@ -146,13 +146,13 @@ class LayoutLMv3ImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
resample: PILImageResampling = PILImageResampling.BILINEAR,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_value: float = 1 / 255,
|
rescale_value: float = 1 / 255,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
image_mean: Union[float, Iterable[float]] = None,
|
image_mean: Optional[Union[float, Iterable[float]]] = None,
|
||||||
image_std: Union[float, Iterable[float]] = None,
|
image_std: Optional[Union[float, Iterable[float]]] = None,
|
||||||
apply_ocr: bool = True,
|
apply_ocr: bool = True,
|
||||||
ocr_lang: Optional[str] = None,
|
ocr_lang: Optional[str] = None,
|
||||||
tesseract_config: Optional[str] = "",
|
tesseract_config: Optional[str] = "",
|
||||||
@ -228,13 +228,13 @@ class LayoutLMv3ImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
images: ImageInput,
|
images: ImageInput,
|
||||||
do_resize: Optional[bool] = None,
|
do_resize: Optional[bool] = None,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample=None,
|
resample=None,
|
||||||
do_rescale: Optional[bool] = None,
|
do_rescale: Optional[bool] = None,
|
||||||
rescale_factor: Optional[float] = None,
|
rescale_factor: Optional[float] = None,
|
||||||
do_normalize: Optional[bool] = None,
|
do_normalize: Optional[bool] = None,
|
||||||
image_mean: Union[float, Iterable[float]] = None,
|
image_mean: Optional[Union[float, Iterable[float]]] = None,
|
||||||
image_std: Union[float, Iterable[float]] = None,
|
image_std: Optional[Union[float, Iterable[float]]] = None,
|
||||||
apply_ocr: Optional[bool] = None,
|
apply_ocr: Optional[bool] = None,
|
||||||
ocr_lang: Optional[str] = None,
|
ocr_lang: Optional[str] = None,
|
||||||
tesseract_config: Optional[str] = None,
|
tesseract_config: Optional[str] = None,
|
||||||
|
@ -71,7 +71,7 @@ class LayoutLMv3Processor(ProcessorMixin):
|
|||||||
images,
|
images,
|
||||||
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None,
|
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None,
|
||||||
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
||||||
boxes: Union[List[List[int]], List[List[List[int]]]] = None,
|
boxes: Optional[Union[List[List[int]], List[List[List[int]]]]] = None,
|
||||||
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
||||||
add_special_tokens: bool = True,
|
add_special_tokens: bool = True,
|
||||||
padding: Union[bool, str, PaddingStrategy] = False,
|
padding: Union[bool, str, PaddingStrategy] = False,
|
||||||
|
@ -535,7 +535,7 @@ class LayoutLMv3Tokenizer(PreTrainedTokenizer):
|
|||||||
self,
|
self,
|
||||||
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]],
|
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]],
|
||||||
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
||||||
boxes: Union[List[List[int]], List[List[List[int]]]] = None,
|
boxes: Optional[Union[List[List[int]], List[List[List[int]]]]] = None,
|
||||||
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
||||||
add_special_tokens: bool = True,
|
add_special_tokens: bool = True,
|
||||||
padding: Union[bool, str, PaddingStrategy] = False,
|
padding: Union[bool, str, PaddingStrategy] = False,
|
||||||
|
@ -201,7 +201,7 @@ class LayoutLMv3TokenizerFast(PreTrainedTokenizerFast):
|
|||||||
self,
|
self,
|
||||||
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]],
|
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]],
|
||||||
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
||||||
boxes: Union[List[List[int]], List[List[List[int]]]] = None,
|
boxes: Optional[Union[List[List[int]], List[List[List[int]]]]] = None,
|
||||||
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
||||||
add_special_tokens: bool = True,
|
add_special_tokens: bool = True,
|
||||||
padding: Union[bool, str, PaddingStrategy] = False,
|
padding: Union[bool, str, PaddingStrategy] = False,
|
||||||
|
@ -70,7 +70,7 @@ class LayoutXLMProcessor(ProcessorMixin):
|
|||||||
images,
|
images,
|
||||||
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None,
|
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None,
|
||||||
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
||||||
boxes: Union[List[List[int]], List[List[List[int]]]] = None,
|
boxes: Optional[Union[List[List[int]], List[List[List[int]]]]] = None,
|
||||||
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
||||||
add_special_tokens: bool = True,
|
add_special_tokens: bool = True,
|
||||||
padding: Union[bool, str, PaddingStrategy] = False,
|
padding: Union[bool, str, PaddingStrategy] = False,
|
||||||
|
@ -441,7 +441,7 @@ class LayoutXLMTokenizer(PreTrainedTokenizer):
|
|||||||
self,
|
self,
|
||||||
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]],
|
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]],
|
||||||
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
||||||
boxes: Union[List[List[int]], List[List[List[int]]]] = None,
|
boxes: Optional[Union[List[List[int]], List[List[List[int]]]]] = None,
|
||||||
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
||||||
add_special_tokens: bool = True,
|
add_special_tokens: bool = True,
|
||||||
padding: Union[bool, str, PaddingStrategy] = False,
|
padding: Union[bool, str, PaddingStrategy] = False,
|
||||||
|
@ -269,7 +269,7 @@ class LayoutXLMTokenizerFast(PreTrainedTokenizerFast):
|
|||||||
self,
|
self,
|
||||||
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]],
|
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]],
|
||||||
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
text_pair: Optional[Union[PreTokenizedInput, List[PreTokenizedInput]]] = None,
|
||||||
boxes: Union[List[List[int]], List[List[List[int]]]] = None,
|
boxes: Optional[Union[List[List[int]], List[List[List[int]]]]] = None,
|
||||||
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
word_labels: Optional[Union[List[int], List[List[int]]]] = None,
|
||||||
add_special_tokens: bool = True,
|
add_special_tokens: bool = True,
|
||||||
padding: Union[bool, str, PaddingStrategy] = False,
|
padding: Union[bool, str, PaddingStrategy] = False,
|
||||||
|
@ -90,10 +90,10 @@ class LevitImageProcessor(BaseImageProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
||||||
do_center_crop: bool = True,
|
do_center_crop: bool = True,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
|
@ -467,8 +467,8 @@ class FlaxLlamaPreTrainedModel(FlaxPreTrainedModel):
|
|||||||
input_ids,
|
input_ids,
|
||||||
attention_mask=None,
|
attention_mask=None,
|
||||||
position_ids=None,
|
position_ids=None,
|
||||||
params: dict = None,
|
params: Optional[dict] = None,
|
||||||
past_key_values: dict = None,
|
past_key_values: Optional[dict] = None,
|
||||||
dropout_rng: jax.random.PRNGKey = None,
|
dropout_rng: jax.random.PRNGKey = None,
|
||||||
train: bool = False,
|
train: bool = False,
|
||||||
output_attentions: Optional[bool] = None,
|
output_attentions: Optional[bool] = None,
|
||||||
|
@ -90,7 +90,7 @@ ORIGINAL_TO_CONVERTED_KEY_MAPPING = {
|
|||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
|
|
||||||
def convert_old_keys_to_new_keys(state_dict_keys: dict = None):
|
def convert_old_keys_to_new_keys(state_dict_keys: Optional[dict] = None):
|
||||||
"""
|
"""
|
||||||
This function should be applied only once, on the concatenated keys to efficiently rename using
|
This function should be applied only once, on the concatenated keys to efficiently rename using
|
||||||
the key mappings.
|
the key mappings.
|
||||||
|
@ -1287,7 +1287,7 @@ class Llama4VisionEncoderLayer(nn.Module):
|
|||||||
hidden_state: torch.Tensor,
|
hidden_state: torch.Tensor,
|
||||||
freqs_ci: torch.Tensor,
|
freqs_ci: torch.Tensor,
|
||||||
attention_mask: Optional[torch.Tensor] = None,
|
attention_mask: Optional[torch.Tensor] = None,
|
||||||
output_attentions: bool = None,
|
output_attentions: Optional[bool] = None,
|
||||||
):
|
):
|
||||||
# Self Attention
|
# Self Attention
|
||||||
residual = hidden_state
|
residual = hidden_state
|
||||||
|
@ -99,10 +99,10 @@ class LlavaImageProcessor(BaseImageProcessor):
|
|||||||
self,
|
self,
|
||||||
do_pad: bool = False,
|
do_pad: bool = False,
|
||||||
do_resize: bool = True,
|
do_resize: bool = True,
|
||||||
size: Dict[str, int] = None,
|
size: Optional[Dict[str, int]] = None,
|
||||||
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
resample: PILImageResampling = PILImageResampling.BICUBIC,
|
||||||
do_center_crop: bool = True,
|
do_center_crop: bool = True,
|
||||||
crop_size: Dict[str, int] = None,
|
crop_size: Optional[Dict[str, int]] = None,
|
||||||
do_rescale: bool = True,
|
do_rescale: bool = True,
|
||||||
rescale_factor: Union[int, float] = 1 / 255,
|
rescale_factor: Union[int, float] = 1 / 255,
|
||||||
do_normalize: bool = True,
|
do_normalize: bool = True,
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user