Spaces:
Sleeping
Sleeping
Commit ·
49b6ab0
1
Parent(s): fff116e
fix: mock transformers.onnx in bhashini to bypass IndicTrans2 load crash
Browse files- bhashini.py +14 -0
bhashini.py
CHANGED
|
@@ -3,6 +3,20 @@ import os
|
|
| 3 |
import gc
|
| 4 |
import torch
|
| 5 |
import threading
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
INDICTRANS_LANG_MAP = {
|
| 8 |
"hindi": "hin_Deva",
|
|
|
|
| 3 |
import gc
|
| 4 |
import torch
|
| 5 |
import threading
|
| 6 |
+
import sys
|
| 7 |
+
import types
|
| 8 |
+
|
| 9 |
+
# --- CRITICAL SPRINT 18 PATCH ---
|
| 10 |
+
# IndicTrans2 configuration requires `transformers.onnx`, which was removed in transformers 4.40+.
|
| 11 |
+
# We mock it here to prevent 'ModuleNotFoundError' when loading the local models,
|
| 12 |
+
# allowing compatibility with transformers>=4.48.0 (required by Ettin Reranker).
|
| 13 |
+
if 'transformers.onnx' not in sys.modules:
|
| 14 |
+
mock_onnx = types.ModuleType('transformers.onnx')
|
| 15 |
+
class MockOnnxConfig:
|
| 16 |
+
pass
|
| 17 |
+
mock_onnx.OnnxConfig = MockOnnxConfig
|
| 18 |
+
sys.modules['transformers.onnx'] = mock_onnx
|
| 19 |
+
# --------------------------------
|
| 20 |
|
| 21 |
INDICTRANS_LANG_MAP = {
|
| 22 |
"hindi": "hin_Deva",
|