Fix AutoModel registration by adding dynamic registration code
Browse files- modeling_interfuser.py +18 -1
modeling_interfuser.py
CHANGED
|
@@ -576,4 +576,21 @@ class InterfuserForHuggingFace(PreTrainedModel):
|
|
| 576 |
return InterfuserOutput(waypoints=outputs)
|
| 577 |
traffic, waypoints, is_junction, traffic_light_state, stop_sign, traffic_feature = outputs
|
| 578 |
if not return_dict: return outputs
|
| 579 |
-
return InterfuserOutput(waypoints=waypoints, traffic_predictions=traffic, is_junction=is_junction, traffic_light_state=traffic_light_state, stop_sign=stop_sign, traffic_features=traffic_feature)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 576 |
return InterfuserOutput(waypoints=outputs)
|
| 577 |
traffic, waypoints, is_junction, traffic_light_state, stop_sign, traffic_feature = outputs
|
| 578 |
if not return_dict: return outputs
|
| 579 |
+
return InterfuserOutput(waypoints=waypoints, traffic_predictions=traffic, is_junction=is_junction, traffic_light_state=traffic_light_state, stop_sign=stop_sign, traffic_features=traffic_feature)
|
| 580 |
+
# ==============================================================================
|
| 581 |
+
# --- التسجيل الديناميكي للنموذج في مكتبة Transformers ---
|
| 582 |
+
# هذا هو الجزء الحاسم الذي يحل خطأ KeyError
|
| 583 |
+
# ==============================================================================
|
| 584 |
+
from transformers.models.auto.configuration_auto import AutoConfig
|
| 585 |
+
from transformers.models.auto.modeling_auto import AutoModel
|
| 586 |
+
|
| 587 |
+
print("Registering Interfuser model with AutoModel...")
|
| 588 |
+
|
| 589 |
+
# 1. تسجيل فئة الإعدادات
|
| 590 |
+
AutoConfig.register("interfuser", InterfuserConfig)
|
| 591 |
+
|
| 592 |
+
# 2. تسجيل فئة النموذج
|
| 593 |
+
# هذا يربط model_type="interfuser" مع الكلاس InterfuserForHuggingFace
|
| 594 |
+
AutoModel.register(InterfuserConfig, InterfuserForHuggingFace)
|
| 595 |
+
|
| 596 |
+
print("Registration complete.")
|