Upload combined_inference.py with huggingface_hub
Browse files- combined_inference.py +33 -9
combined_inference.py
CHANGED
|
@@ -2,7 +2,31 @@ import argparse
|
|
| 2 |
import json
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
CAUTIONARY_SUBTYPES,
|
| 7 |
COMMERCIAL_SCORE_MIN,
|
| 8 |
HIGH_INTENT_SUBTYPES,
|
|
@@ -14,14 +38,14 @@ from config import (
|
|
| 14 |
SAFE_FALLBACK_SUBTYPE_FAMILIES,
|
| 15 |
SUBTYPE_FAMILY_MAP,
|
| 16 |
SUBTYPE_SCORE_WEIGHTS,
|
| 17 |
-
)
|
| 18 |
-
from inference_intent_type import predict as predict_intent_type
|
| 19 |
-
from inference_decision_phase import predict as predict_decision_phase
|
| 20 |
-
from inference_iab_classifier import predict as predict_iab_content_classifier
|
| 21 |
-
from inference_subtype import predict as predict_intent_subtype
|
| 22 |
-
from model_runtime import get_head
|
| 23 |
-
from multitask_runtime import get_multitask_runtime
|
| 24 |
-
from schemas import validate_classify_response
|
| 25 |
|
| 26 |
# Degraded fallback only: production requires `training/train_iab.py` and
|
| 27 |
# `calibrate_confidence.py --head iab_content`. Used when weights are missing or forced via --skip-iab.
|
|
|
|
| 2 |
import json
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
try:
|
| 6 |
+
# HF `trust_remote_code` path (relative imports inside dynamic module package)
|
| 7 |
+
from .config import ( # type: ignore
|
| 8 |
+
CAUTIONARY_SUBTYPES,
|
| 9 |
+
COMMERCIAL_SCORE_MIN,
|
| 10 |
+
HIGH_INTENT_SUBTYPES,
|
| 11 |
+
INTENT_SCORE_WEIGHTS,
|
| 12 |
+
LOW_SIGNAL_SUBTYPES,
|
| 13 |
+
PHASE_SCORE_WEIGHTS,
|
| 14 |
+
PROJECT_VERSION,
|
| 15 |
+
SAFE_FALLBACK_INTENTS,
|
| 16 |
+
SAFE_FALLBACK_SUBTYPE_FAMILIES,
|
| 17 |
+
SUBTYPE_FAMILY_MAP,
|
| 18 |
+
SUBTYPE_SCORE_WEIGHTS,
|
| 19 |
+
)
|
| 20 |
+
from .inference_intent_type import predict as predict_intent_type # type: ignore
|
| 21 |
+
from .inference_decision_phase import predict as predict_decision_phase # type: ignore
|
| 22 |
+
from .inference_iab_classifier import predict as predict_iab_content_classifier # type: ignore
|
| 23 |
+
from .inference_subtype import predict as predict_intent_subtype # type: ignore
|
| 24 |
+
from .model_runtime import get_head # type: ignore
|
| 25 |
+
from .multitask_runtime import get_multitask_runtime # type: ignore
|
| 26 |
+
from .schemas import validate_classify_response # type: ignore
|
| 27 |
+
except ImportError:
|
| 28 |
+
# Local repo execution path
|
| 29 |
+
from config import (
|
| 30 |
CAUTIONARY_SUBTYPES,
|
| 31 |
COMMERCIAL_SCORE_MIN,
|
| 32 |
HIGH_INTENT_SUBTYPES,
|
|
|
|
| 38 |
SAFE_FALLBACK_SUBTYPE_FAMILIES,
|
| 39 |
SUBTYPE_FAMILY_MAP,
|
| 40 |
SUBTYPE_SCORE_WEIGHTS,
|
| 41 |
+
)
|
| 42 |
+
from inference_intent_type import predict as predict_intent_type
|
| 43 |
+
from inference_decision_phase import predict as predict_decision_phase
|
| 44 |
+
from inference_iab_classifier import predict as predict_iab_content_classifier
|
| 45 |
+
from inference_subtype import predict as predict_intent_subtype
|
| 46 |
+
from model_runtime import get_head
|
| 47 |
+
from multitask_runtime import get_multitask_runtime
|
| 48 |
+
from schemas import validate_classify_response
|
| 49 |
|
| 50 |
# Degraded fallback only: production requires `training/train_iab.py` and
|
| 51 |
# `calibrate_confidence.py --head iab_content`. Used when weights are missing or forced via --skip-iab.
|