Unverified Commit 72fb02c4 authored by Sai-Suraj-27's avatar Sai-Suraj-27 Committed by GitHub
Browse files

Fixed `log messages` that are resulting in TypeError due to too many arguments (#32017)

* Fixed log messages that are resulting in TypeErrors due to too many arguments.

* Removed un-necessary imports.
parent 691586b0
...@@ -484,7 +484,7 @@ def main(): ...@@ -484,7 +484,7 @@ def main():
label_to_id = {i: label_name_to_id[label_list[i]] for i in range(num_labels)} label_to_id = {i: label_name_to_id[label_list[i]] for i in range(num_labels)}
else: else:
logger.warning( logger.warning(
"Your model seems to have been trained with labels, but they don't match the dataset: ", "Your model seems to have been trained with labels, but they don't match the dataset: "
f"model labels: {sorted(label_name_to_id.keys())}, dataset labels: {sorted(label_list)}." f"model labels: {sorted(label_name_to_id.keys())}, dataset labels: {sorted(label_list)}."
"\nIgnoring the model labels as a result.", "\nIgnoring the model labels as a result.",
) )
......
...@@ -428,7 +428,7 @@ def main(): ...@@ -428,7 +428,7 @@ def main():
label_to_id = {i: int(label_name_to_id[label_list[i]]) for i in range(num_labels)} label_to_id = {i: int(label_name_to_id[label_list[i]]) for i in range(num_labels)}
else: else:
logger.warning( logger.warning(
"Your model seems to have been trained with labels, but they don't match the dataset: ", "Your model seems to have been trained with labels, but they don't match the dataset: "
f"model labels: {sorted(label_name_to_id.keys())}, dataset labels: {sorted(label_list)}." f"model labels: {sorted(label_name_to_id.keys())}, dataset labels: {sorted(label_list)}."
"\nIgnoring the model labels as a result.", "\nIgnoring the model labels as a result.",
) )
......
...@@ -370,7 +370,7 @@ def main(): ...@@ -370,7 +370,7 @@ def main():
label_to_id = {i: label_name_to_id[label_list[i]] for i in range(num_labels)} label_to_id = {i: label_name_to_id[label_list[i]] for i in range(num_labels)}
else: else:
logger.warning( logger.warning(
"Your model seems to have been trained with labels, but they don't match the dataset: ", "Your model seems to have been trained with labels, but they don't match the dataset: "
f"model labels: {sorted(label_name_to_id.keys())}, dataset labels: {sorted(label_list)}." f"model labels: {sorted(label_name_to_id.keys())}, dataset labels: {sorted(label_list)}."
"\nIgnoring the model labels as a result.", "\nIgnoring the model labels as a result.",
) )
......
...@@ -417,7 +417,7 @@ def main(): ...@@ -417,7 +417,7 @@ def main():
label_to_id = {l: i for i, l in enumerate(label_list)} label_to_id = {l: i for i, l in enumerate(label_list)}
else: else:
logger.warning( logger.warning(
"Your model seems to have been trained with labels, but they don't match the dataset: ", "Your model seems to have been trained with labels, but they don't match the dataset: "
f"model labels: {sorted(model.config.label2id.keys())}, dataset labels:" f"model labels: {sorted(model.config.label2id.keys())}, dataset labels:"
f" {sorted(label_list)}.\nIgnoring the model labels as a result.", f" {sorted(label_list)}.\nIgnoring the model labels as a result.",
) )
......
...@@ -458,7 +458,7 @@ def main(): ...@@ -458,7 +458,7 @@ def main():
label_to_id = {l: i for i, l in enumerate(label_list)} label_to_id = {l: i for i, l in enumerate(label_list)}
else: else:
logger.warning( logger.warning(
"Your model seems to have been trained with labels, but they don't match the dataset: ", "Your model seems to have been trained with labels, but they don't match the dataset: "
f"model labels: {sorted(model.config.label2id.keys())}, dataset labels:" f"model labels: {sorted(model.config.label2id.keys())}, dataset labels:"
f" {sorted(label_list)}.\nIgnoring the model labels as a result.", f" {sorted(label_list)}.\nIgnoring the model labels as a result.",
) )
......
...@@ -326,7 +326,7 @@ def main(): ...@@ -326,7 +326,7 @@ def main():
label_to_id = {i: int(label_name_to_id[label_list[i]]) for i in range(num_labels)} label_to_id = {i: int(label_name_to_id[label_list[i]]) for i in range(num_labels)}
else: else:
logger.warning( logger.warning(
"Your model seems to have been trained with labels, but they don't match the dataset: ", "Your model seems to have been trained with labels, but they don't match the dataset: "
f"model labels: {sorted(label_name_to_id.keys())}, dataset labels: {sorted(label_list)}." f"model labels: {sorted(label_name_to_id.keys())}, dataset labels: {sorted(label_list)}."
"\nIgnoring the model labels as a result.", "\nIgnoring the model labels as a result.",
) )
......
...@@ -374,7 +374,7 @@ def main(): ...@@ -374,7 +374,7 @@ def main():
label_to_id = label_name_to_id # Use the model's labels label_to_id = label_name_to_id # Use the model's labels
else: else:
logger.warning( logger.warning(
"Your model seems to have been trained with labels, but they don't match the dataset: ", "Your model seems to have been trained with labels, but they don't match the dataset: "
f"model labels: {sorted(label_name_to_id.keys())}, dataset labels:" f"model labels: {sorted(label_name_to_id.keys())}, dataset labels:"
f" {sorted(label_list)}.\nIgnoring the model labels as a result.", f" {sorted(label_list)}.\nIgnoring the model labels as a result.",
) )
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
# limitations under the License. # limitations under the License.
"""BEiT model configuration""" """BEiT model configuration"""
import warnings
from collections import OrderedDict from collections import OrderedDict
from typing import Mapping from typing import Mapping
...@@ -21,13 +22,9 @@ from packaging import version ...@@ -21,13 +22,9 @@ from packaging import version
from ...configuration_utils import PretrainedConfig from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig from ...onnx import OnnxConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices
logger = logging.get_logger(__name__)
class BeitConfig(BackboneConfigMixin, PretrainedConfig): class BeitConfig(BackboneConfigMixin, PretrainedConfig):
r""" r"""
This is the configuration class to store the configuration of a [`BeitModel`]. It is used to instantiate an BEiT This is the configuration class to store the configuration of a [`BeitModel`]. It is used to instantiate an BEiT
...@@ -197,7 +194,7 @@ class BeitConfig(BackboneConfigMixin, PretrainedConfig): ...@@ -197,7 +194,7 @@ class BeitConfig(BackboneConfigMixin, PretrainedConfig):
# handle backwards compatibility # handle backwards compatibility
if "segmentation_indices" in kwargs: if "segmentation_indices" in kwargs:
logger.warning( warnings.warn(
"The `segmentation_indices` argument is deprecated and will be removed in a future version, use `out_indices` instead.", "The `segmentation_indices` argument is deprecated and will be removed in a future version, use `out_indices` instead.",
FutureWarning, FutureWarning,
) )
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"""Image processor class for MaskFormer.""" """Image processor class for MaskFormer."""
import math import math
import warnings
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Set, Tuple, Union from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Set, Tuple, Union
import numpy as np import numpy as np
...@@ -987,7 +988,7 @@ class MaskFormerImageProcessor(BaseImageProcessor): ...@@ -987,7 +988,7 @@ class MaskFormerImageProcessor(BaseImageProcessor):
`torch.Tensor`: `torch.Tensor`:
A tensor of shape (`batch_size, num_class_labels, height, width`). A tensor of shape (`batch_size, num_class_labels, height, width`).
""" """
logger.warning( warnings.warn(
"`post_process_segmentation` is deprecated and will be removed in v5 of Transformers, please use" "`post_process_segmentation` is deprecated and will be removed in v5 of Transformers, please use"
" `post_process_instance_segmentation`", " `post_process_instance_segmentation`",
FutureWarning, FutureWarning,
......
...@@ -366,7 +366,7 @@ def main(): ...@@ -366,7 +366,7 @@ def main():
label_to_id = {i: int(label_name_to_id[label_list[i]]) for i in range(num_labels)} label_to_id = {i: int(label_name_to_id[label_list[i]]) for i in range(num_labels)}
else: else:
logger.warning( logger.warning(
"Your model seems to have been trained with labels, but they don't match the dataset: ", "Your model seems to have been trained with labels, but they don't match the dataset: "
f"model labels: {sorted(label_name_to_id.keys())}, dataset labels: {sorted(label_list)}." f"model labels: {sorted(label_name_to_id.keys())}, dataset labels: {sorted(label_list)}."
"\nIgnoring the model labels as a result.", "\nIgnoring the model labels as a result.",
) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment