giuseppe-tanzi commited on
Commit
b66d404
·
verified ·
1 Parent(s): 1c89b4a

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +9 -3
  2. 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 is included in the repository
76
- model = AutoModel.from_pretrained("videoloc/seamless-translation")
77
- config = AutoConfig.from_pretrained("videoloc/seamless-translation")
 
 
 
 
 
 
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 is included in the repository
12
- model = AutoModel.from_pretrained("videoloc/seamless-translation")
13
- config = AutoConfig.from_pretrained("videoloc/seamless-translation")
 
 
 
 
 
 
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")