Fix adapter.py imports to work when loaded from Hugging Face Hub cache
Browse files- adapter.py +11 -2
adapter.py
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from restoration import AbRestore
|
| 2 |
from ablang_encodings import AbEncoding
|
| 3 |
from alignment import AbAlignment
|
| 4 |
from scores import AbScores
|
| 5 |
-
import torch
|
| 6 |
-
import numpy as np
|
| 7 |
from extra_utils import res_to_seq, res_to_list
|
| 8 |
|
| 9 |
class HuggingFaceTokenizerAdapter:
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
import torch
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
# Get the directory where this adapter.py file is located
|
| 7 |
+
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 8 |
+
if current_dir not in sys.path:
|
| 9 |
+
sys.path.insert(0, current_dir)
|
| 10 |
+
|
| 11 |
+
# Import utility modules
|
| 12 |
from restoration import AbRestore
|
| 13 |
from ablang_encodings import AbEncoding
|
| 14 |
from alignment import AbAlignment
|
| 15 |
from scores import AbScores
|
|
|
|
|
|
|
| 16 |
from extra_utils import res_to_seq, res_to_list
|
| 17 |
|
| 18 |
class HuggingFaceTokenizerAdapter:
|