Upload folder using huggingface_hub
Browse files- README.md +9 -3
- example_usage.py +9 -3
README.md
CHANGED
|
@@ -72,9 +72,15 @@ import torch
|
|
| 72 |
import numpy as np
|
| 73 |
import importlib.util
|
| 74 |
|
| 75 |
-
# Load model - architecture
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
# Load the data collator (included in this repo)
|
| 80 |
collator_file = hf_hub_download(repo_id="videoloc/seamless-translation", filename="data_collator.py")
|
|
|
|
| 72 |
import numpy as np
|
| 73 |
import importlib.util
|
| 74 |
|
| 75 |
+
# Load model - custom architecture requires importing the model class
|
| 76 |
+
model_files = hf_hub_download(repo_id="videoloc/seamless-translation", filename="modeling_seamless_translation.py")
|
| 77 |
+
spec = importlib.util.spec_from_file_location("modeling_seamless_translation", model_files)
|
| 78 |
+
modeling_module = importlib.util.module_from_spec(spec)
|
| 79 |
+
spec.loader.exec_module(modeling_module)
|
| 80 |
+
|
| 81 |
+
# Now load the model using the custom class
|
| 82 |
+
config = modeling_module.SeamlessTranslationConfig.from_pretrained("videoloc/seamless-translation")
|
| 83 |
+
model = modeling_module.HFSeamlessTranslation.from_pretrained("videoloc/seamless-translation")
|
| 84 |
|
| 85 |
# Load the data collator (included in this repo)
|
| 86 |
collator_file = hf_hub_download(repo_id="videoloc/seamless-translation", filename="data_collator.py")
|
example_usage.py
CHANGED
|
@@ -8,9 +8,15 @@ import numpy as np
|
|
| 8 |
import importlib.util
|
| 9 |
|
| 10 |
def load_model_and_collator():
|
| 11 |
-
# Load model - architecture
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Load data collator
|
| 16 |
collator_file = hf_hub_download(repo_id="videoloc/seamless-translation", filename="data_collator.py")
|
|
|
|
| 8 |
import importlib.util
|
| 9 |
|
| 10 |
def load_model_and_collator():
|
| 11 |
+
# Load model - custom architecture requires importing the model class
|
| 12 |
+
model_files = hf_hub_download(repo_id="videoloc/seamless-translation", filename="modeling_seamless_translation.py")
|
| 13 |
+
spec = importlib.util.spec_from_file_location("modeling_seamless_translation", model_files)
|
| 14 |
+
modeling_module = importlib.util.module_from_spec(spec)
|
| 15 |
+
spec.loader.exec_module(modeling_module)
|
| 16 |
+
|
| 17 |
+
# Now load the model using the custom class
|
| 18 |
+
config = modeling_module.SeamlessTranslationConfig.from_pretrained("videoloc/seamless-translation")
|
| 19 |
+
model = modeling_module.HFSeamlessTranslation.from_pretrained("videoloc/seamless-translation")
|
| 20 |
|
| 21 |
# Load data collator
|
| 22 |
collator_file = hf_hub_download(repo_id="videoloc/seamless-translation", filename="data_collator.py")
|