Skip to content

Commit a5b9b17

Browse files
committed
feat(transformers/models): add models of eomt, timesfm
1 parent 8f6e9c9 commit a5b9b17

File tree

16 files changed

+3981
-1
lines changed

16 files changed

+3981
-1
lines changed

mindone/transformers/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@
483483
from .models.emu3 import Emu3ForCausalLM, Emu3ForConditionalGeneration, Emu3PreTrainedModel, Emu3TextModel, Emu3VQVAE
484484
from .models.encodec import EncodecModel, EncodecPreTrainedModel
485485
from .models.encoder_decoder import EncoderDecoderModel
486+
from .models.eomt import EomtForUniversalSegmentation, EomtImageProcessor, EomtImageProcessorFast, EomtPreTrainedModel
486487
from .models.ernie import (
487488
ErnieForCausalLM,
488489
ErnieForMaskedLM,
@@ -1331,6 +1332,7 @@
13311332
TapasPreTrainedModel,
13321333
)
13331334
from .models.textnet import TextNetBackbone, TextNetForImageClassification, TextNetModel, TextNetPreTrainedModel
1335+
from .models.timesfm import TimesFmModel, TimesFmModelForPrediction, TimesFmPreTrainedModel
13341336
from .models.timesformer import TimesformerForVideoClassification, TimesformerModel, TimesformerPreTrainedModel
13351337
from .models.trocr import TrOCRForCausalLM, TrOCRPreTrainedModel
13361338
from .models.tvp import TvpForVideoGrounding, TvpModel, TvpPreTrainedModel

mindone/transformers/mindspore_adapter/utils.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
"bool": ms.bool_,
3030
}
3131

32-
32+
_MIN_INT8 = ms.tensor(np.iinfo(np.int8).min, dtype=ms.int8)
33+
_MIN_INT16 = ms.tensor(np.iinfo(np.int16).min, dtype=ms.int16)
34+
_MIN_INT32 = ms.tensor(np.iinfo(np.int32).min, dtype=ms.int32)
35+
_MIN_INT64 = ms.tensor(np.iinfo(np.int64).min, dtype=ms.int64)
3336
_MIN_FP16 = ms.tensor(np.finfo(np.float16).min, dtype=ms.float16)
3437
_MIN_FP32 = ms.tensor(np.finfo(np.float32).min, dtype=ms.float32)
3538
_MIN_FP64 = ms.tensor(np.finfo(np.float64).min, dtype=ms.float64)
@@ -41,6 +44,10 @@
4144

4245

4346
_DTYPE_2_MIN = {
47+
ms.int8: _MIN_INT8,
48+
ms.int16: _MIN_INT16,
49+
ms.int32: _MIN_INT32,
50+
ms.int64: _MIN_INT64,
4451
ms.float16: _MIN_FP16,
4552
ms.float32: _MIN_FP32,
4653
ms.float64: _MIN_FP64,

mindone/transformers/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
emu3,
7373
encodec,
7474
encoder_decoder,
75+
eomt,
7576
ernie,
7677
esm,
7778
falcon,
@@ -224,6 +225,7 @@
224225
table_transformer,
225226
tapas,
226227
textnet,
228+
timesfm,
227229
timesformer,
228230
trocr,
229231
tvp,

mindone/transformers/models/auto/configuration_auto.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
("emu3", "Emu3Config"),
9696
("encodec", "EncodecConfig"),
9797
("encoder-decoder", "EncoderDecoderConfig"),
98+
("eomt", "EomtConfig"),
9899
("esm", "EsmConfig"),
99100
("falcon", "FalconConfig"),
100101
("falcon_mamba", "FalconMambaConfig"),
@@ -253,6 +254,7 @@
253254
("table-transformer", "TableTransformerConfig"),
254255
("tapas", "TapasConfig"),
255256
("textnet", "TextNetConfig"),
257+
("timesfm", "TimesFmConfig"),
256258
("timesformer", "TimesformerConfig"),
257259
("trocr", "TrOCRConfig"),
258260
("tvp", "TvpConfig"),
@@ -363,6 +365,7 @@
363365
("emu3", "Emu3"),
364366
("encodec", "Encodec"),
365367
("encoder-decoder", "Encoder decoder"),
368+
("eomt", "EoMT"),
366369
("esm", "ESM"),
367370
("falcon", "Falcon"),
368371
("falcon_mamba", "FalconMamba"),
@@ -525,6 +528,7 @@
525528
("table-transformer", "Table Transformer"),
526529
("tapas", "TAPAS"),
527530
("textnet", "TextNet"),
531+
("timesfm", "TimesFm"),
528532
("timesformer", "TimeSformer"),
529533
("trocr", "TrOCR"),
530534
("tvp", "TVP"),

mindone/transformers/models/auto/image_processing_auto.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
("dinov2", ("BitImageProcessor",)),
6464
("dpt", ("DPTImageProcessor",)),
6565
("efficientnet", ("EfficientNetImageProcessor",)),
66+
("eomt", ("EomtImageProcessor", "EomtImageProcessorFast")),
6667
("flava", ("FlavaImageProcessor",)),
6768
("llava_next", ("LlavaNextImageProcessor",)),
6869
("llava_next_video", ("LlavaNextVideoImageProcessor",)),

mindone/transformers/models/auto/modeling_auto.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@
230230
("table-transformer", "TableTransformerModel"),
231231
("tapas", "TapasModel"),
232232
("textnet", "TextNetModel"),
233+
("timesfm", "TimesFmModel"),
233234
("timesformer", "TimesformerModel"),
234235
("tvp", "TvpModel"),
235236
("udop", "UdopModel"),
@@ -653,6 +654,7 @@
653654
[
654655
# Model for Universal Segmentation mapping
655656
("detr", "DetrForSegmentation"),
657+
("eomt", "EomtForUniversalSegmentation"),
656658
("mask2former", "Mask2FormerForUniversalSegmentation"),
657659
("maskformer", "MaskFormerForInstanceSegmentation"),
658660
("oneformer", "OneFormerForUniversalSegmentation"),
@@ -1268,6 +1270,12 @@
12681270

12691271
MODEL_FOR_TIME_SERIES_REGRESSION_MAPPING_NAMES = OrderedDict()
12701272

1273+
MODEL_FOR_TIME_SERIES_PREDICTION_MAPPING_NAMES = OrderedDict(
1274+
[
1275+
("timesfm", "TimesFmModelForPrediction"),
1276+
]
1277+
)
1278+
12711279
MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES = OrderedDict(
12721280
[
12731281
("swin2sr", "Swin2SRForImageSuperResolution"),
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2025 The HuggingFace Team. All rights reserved.
2+
#
3+
# This code is adapted from https://github.com/huggingface/transformers
4+
# with modifications to run transformers on mindspore.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
from .image_processing_eomt import *
18+
from .image_processing_eomt_fast import *
19+
from .modeling_eomt import *

0 commit comments

Comments
 (0)