Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mindone/transformers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@
from .models.emu3 import Emu3ForCausalLM, Emu3ForConditionalGeneration, Emu3PreTrainedModel, Emu3TextModel, Emu3VQVAE
from .models.encodec import EncodecModel, EncodecPreTrainedModel
from .models.encoder_decoder import EncoderDecoderModel
from .models.eomt import EomtForUniversalSegmentation, EomtImageProcessor, EomtImageProcessorFast, EomtPreTrainedModel
from .models.ernie import (
ErnieForCausalLM,
ErnieForMaskedLM,
Expand Down Expand Up @@ -1331,6 +1332,7 @@
TapasPreTrainedModel,
)
from .models.textnet import TextNetBackbone, TextNetForImageClassification, TextNetModel, TextNetPreTrainedModel
from .models.timesfm import TimesFmModel, TimesFmModelForPrediction, TimesFmPreTrainedModel
from .models.timesformer import TimesformerForVideoClassification, TimesformerModel, TimesformerPreTrainedModel
from .models.trocr import TrOCRForCausalLM, TrOCRPreTrainedModel
from .models.tvp import TvpForVideoGrounding, TvpModel, TvpPreTrainedModel
Expand Down
9 changes: 8 additions & 1 deletion mindone/transformers/mindspore_adapter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
"bool": ms.bool_,
}


_MIN_INT8 = ms.tensor(np.iinfo(np.int8).min, dtype=ms.int8)
_MIN_INT16 = ms.tensor(np.iinfo(np.int16).min, dtype=ms.int16)
_MIN_INT32 = ms.tensor(np.iinfo(np.int32).min, dtype=ms.int32)
_MIN_INT64 = ms.tensor(np.iinfo(np.int64).min, dtype=ms.int64)
_MIN_FP16 = ms.tensor(np.finfo(np.float16).min, dtype=ms.float16)
_MIN_FP32 = ms.tensor(np.finfo(np.float32).min, dtype=ms.float32)
_MIN_FP64 = ms.tensor(np.finfo(np.float64).min, dtype=ms.float64)
Expand All @@ -41,6 +44,10 @@


_DTYPE_2_MIN = {
ms.int8: _MIN_INT8,
ms.int16: _MIN_INT16,
ms.int32: _MIN_INT32,
ms.int64: _MIN_INT64,
ms.float16: _MIN_FP16,
ms.float32: _MIN_FP32,
ms.float64: _MIN_FP64,
Expand Down
2 changes: 2 additions & 0 deletions mindone/transformers/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
emu3,
encodec,
encoder_decoder,
eomt,
ernie,
esm,
falcon,
Expand Down Expand Up @@ -224,6 +225,7 @@
table_transformer,
tapas,
textnet,
timesfm,
timesformer,
trocr,
tvp,
Expand Down
4 changes: 4 additions & 0 deletions mindone/transformers/models/auto/configuration_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
("emu3", "Emu3Config"),
("encodec", "EncodecConfig"),
("encoder-decoder", "EncoderDecoderConfig"),
("eomt", "EomtConfig"),
("esm", "EsmConfig"),
("falcon", "FalconConfig"),
("falcon_mamba", "FalconMambaConfig"),
Expand Down Expand Up @@ -253,6 +254,7 @@
("table-transformer", "TableTransformerConfig"),
("tapas", "TapasConfig"),
("textnet", "TextNetConfig"),
("timesfm", "TimesFmConfig"),
("timesformer", "TimesformerConfig"),
("trocr", "TrOCRConfig"),
("tvp", "TvpConfig"),
Expand Down Expand Up @@ -363,6 +365,7 @@
("emu3", "Emu3"),
("encodec", "Encodec"),
("encoder-decoder", "Encoder decoder"),
("eomt", "EoMT"),
("esm", "ESM"),
("falcon", "Falcon"),
("falcon_mamba", "FalconMamba"),
Expand Down Expand Up @@ -525,6 +528,7 @@
("table-transformer", "Table Transformer"),
("tapas", "TAPAS"),
("textnet", "TextNet"),
("timesfm", "TimesFm"),
("timesformer", "TimeSformer"),
("trocr", "TrOCR"),
("tvp", "TVP"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
("dinov2", ("BitImageProcessor",)),
("dpt", ("DPTImageProcessor",)),
("efficientnet", ("EfficientNetImageProcessor",)),
("eomt", ("EomtImageProcessor", "EomtImageProcessorFast")),
("flava", ("FlavaImageProcessor",)),
("llava_next", ("LlavaNextImageProcessor",)),
("llava_next_video", ("LlavaNextVideoImageProcessor",)),
Expand Down
8 changes: 8 additions & 0 deletions mindone/transformers/models/auto/modeling_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
("table-transformer", "TableTransformerModel"),
("tapas", "TapasModel"),
("textnet", "TextNetModel"),
("timesfm", "TimesFmModel"),
("timesformer", "TimesformerModel"),
("tvp", "TvpModel"),
("udop", "UdopModel"),
Expand Down Expand Up @@ -653,6 +654,7 @@
[
# Model for Universal Segmentation mapping
("detr", "DetrForSegmentation"),
("eomt", "EomtForUniversalSegmentation"),
("mask2former", "Mask2FormerForUniversalSegmentation"),
("maskformer", "MaskFormerForInstanceSegmentation"),
("oneformer", "OneFormerForUniversalSegmentation"),
Expand Down Expand Up @@ -1268,6 +1270,12 @@

MODEL_FOR_TIME_SERIES_REGRESSION_MAPPING_NAMES = OrderedDict()

MODEL_FOR_TIME_SERIES_PREDICTION_MAPPING_NAMES = OrderedDict(
[
("timesfm", "TimesFmModelForPrediction"),
]
)

MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES = OrderedDict(
[
("swin2sr", "Swin2SRForImageSuperResolution"),
Expand Down
19 changes: 19 additions & 0 deletions mindone/transformers/models/eomt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2025 The HuggingFace Team. All rights reserved.
#
# This code is adapted from https://github.com/huggingface/transformers
# with modifications to run transformers on mindspore.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from .image_processing_eomt import *
from .image_processing_eomt_fast import *
from .modeling_eomt import *
Comment on lines +17 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using wildcard imports (*) is generally discouraged as it can lead to namespace pollution and makes it difficult to trace where symbols are defined. It's better to explicitly import the names that are intended to be part of the module's public API. This also aligns with the convention used in other model directories within this project.

Suggested change
from .image_processing_eomt import *
from .image_processing_eomt_fast import *
from .modeling_eomt import *
from .image_processing_eomt import EomtImageProcessor
from .image_processing_eomt_fast import EomtImageProcessorFast
from .modeling_eomt import EomtForUniversalSegmentation, EomtPreTrainedModel
__all__ = ["EomtImageProcessor", "EomtImageProcessorFast", "EomtForUniversalSegmentation", "EomtPreTrainedModel"]

Loading
Loading