Skip to content

Commit

Permalink
fix import error (switch to lazy)
Browse files Browse the repository at this point in the history
  • Loading branch information
jadechoghari committed Dec 29, 2024
1 parent 350cafe commit db724d9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/source/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ Flax), PyTorch, and/or TensorFlow.
| [RoFormer](model_doc/roformer) ||||
| [RT-DETR](model_doc/rt_detr) ||||
| [RT-DETR-ResNet](model_doc/rt_detr_resnet) ||||
| [RtDetrV2](model_doc/rt_detr_v2) ||||
| [RT-DETR-V2-ResNet](model_doc/rt_detr_v2) ||||
| [RtDetrV2ResNetConfig](model_doc/rt_detr_v2_resnet) ||||
| [RWKV](model_doc/rwkv) ||||
| [SAM](model_doc/sam) ||||
| [SeamlessM4T](model_doc/seamless_m4t) ||||
Expand Down
12 changes: 10 additions & 2 deletions src/transformers/models/rt_detr_v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,13 @@

from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
from .configuration_rt_detr_v2 import *
from .modeling_rt_detr_v2 import *


if TYPE_CHECKING:
from .configuration_rt_detr_v2 import *
from .modeling_rt_detr_v2 import *
else:
import sys

_file = globals()["__file__"]
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ class RtDetrV2Config(PretrainedConfig):
Relative weight of the generalized IoU loss in the object detection loss.
eos_coefficient (`float`, *optional*, defaults to 0.0001):
Relative classification weight of the 'no-object' class in the object detection loss.
decoder_n_levels (`<fill_type>`, *optional*, defaults to 3): <fill_docstring>
decoder_offset_scale (`<fill_type>`, *optional*, defaults to 0.5): <fill_docstring>
Examples:
Expand Down Expand Up @@ -448,3 +450,6 @@ def from_backbone_configs(cls, backbone_config: PretrainedConfig, **kwargs):
backbone_config=backbone_config,
**kwargs,
)


__all__ = ["RtDetrV2ResNetConfig", "RtDetrV2Config"]
3 changes: 3 additions & 0 deletions src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2175,3 +2175,6 @@ def forward(
enc_outputs_coord_logits=outputs.enc_outputs_coord_logits,
denoising_meta_values=outputs.denoising_meta_values,
)


__all__ = ["RtDetrV2Model", "RtDetrV2PreTrainedModel", "RtDetrV2ForObjectDetection"]
9 changes: 9 additions & 0 deletions src/transformers/models/rt_detr_v2/modular_rt_detr_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,12 @@ def __init__(self, config: RtDetrV2Config):
# fix bug
self.model.decoder.class_embed = self.class_embed
self.model.decoder.bbox_embed = self.bbox_embed


__all__ = [
"RtDetrV2ResNetConfig",
"RtDetrV2Config",
"RtDetrV2Model",
"RtDetrV2PreTrainedModel",
"RtDetrV2ForObjectDetection",
]

0 comments on commit db724d9

Please sign in to comment.