giuseppe-tanzi commited on
Commit
b702a18
·
verified ·
1 Parent(s): 87f6e47

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
@@ -79,9 +79,15 @@ import torch
79
  import numpy as np
80
  import importlib.util
81
 
82
- # Load model - architecture is included in the repository
83
- model = AutoModel.from_pretrained("videoloc/seamless-langpairs")
84
- config = AutoConfig.from_pretrained("videoloc/seamless-langpairs")
 
 
 
 
 
 
85
 
86
  # Load the data collator (included in this repo)
87
  collator_file = hf_hub_download(repo_id="videoloc/seamless-langpairs", filename="data_collator.py")
 
79
  import numpy as np
80
  import importlib.util
81
 
82
+ # Load model - custom architecture requires importing the model class
83
+ model_files = hf_hub_download(repo_id="videoloc/seamless-langpairs", filename="modeling_seamless_langpairs.py")
84
+ spec = importlib.util.spec_from_file_location("modeling_seamless_langpairs", model_files)
85
+ modeling_module = importlib.util.module_from_spec(spec)
86
+ spec.loader.exec_module(modeling_module)
87
+
88
+ # Now load the model using the custom class
89
+ config = modeling_module.SeamlessLanguagePairsConfig.from_pretrained("videoloc/seamless-langpairs")
90
+ model = modeling_module.HFSeamlessLanguagePairs.from_pretrained("videoloc/seamless-langpairs")
91
 
92
  # Load the data collator (included in this repo)
93
  collator_file = hf_hub_download(repo_id="videoloc/seamless-langpairs", 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-langpairs")
13
- config = AutoConfig.from_pretrained("videoloc/seamless-langpairs")
 
 
 
 
 
 
14
 
15
  # Load data collator
16
  collator_file = hf_hub_download(repo_id="videoloc/seamless-langpairs", 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-langpairs", filename="modeling_seamless_langpairs.py")
13
+ spec = importlib.util.spec_from_file_location("modeling_seamless_langpairs", 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.SeamlessLanguagePairsConfig.from_pretrained("videoloc/seamless-langpairs")
19
+ model = modeling_module.HFSeamlessLanguagePairs.from_pretrained("videoloc/seamless-langpairs")
20
 
21
  # Load data collator
22
  collator_file = hf_hub_download(repo_id="videoloc/seamless-langpairs", filename="data_collator.py")