giuseppe-tanzi commited on
Commit
2f7b56f
·
verified ·
1 Parent(s): d848202

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
@@ -64,9 +64,15 @@ import torch
64
  import numpy as np
65
  import importlib.util
66
 
67
- # Load model - architecture is included in the repository
68
- model = AutoModel.from_pretrained("videoloc/seamless-basic")
69
- config = AutoConfig.from_pretrained("videoloc/seamless-basic")
 
 
 
 
 
 
70
 
71
  # Load the data collator (included in this repo)
72
  collator_file = hf_hub_download(repo_id="videoloc/seamless-basic", filename="data_collator.py")
 
64
  import numpy as np
65
  import importlib.util
66
 
67
+ # Load model - custom architecture requires importing the model class
68
+ model_files = hf_hub_download(repo_id="videoloc/seamless-basic", filename="modeling_seamless_basic.py")
69
+ spec = importlib.util.spec_from_file_location("modeling_seamless_basic", model_files)
70
+ modeling_module = importlib.util.module_from_spec(spec)
71
+ spec.loader.exec_module(modeling_module)
72
+
73
+ # Now load the model using the custom class
74
+ config = modeling_module.SeamlessBasicConfig.from_pretrained("videoloc/seamless-basic")
75
+ model = modeling_module.HFSeamlessBasic.from_pretrained("videoloc/seamless-basic")
76
 
77
  # Load the data collator (included in this repo)
78
  collator_file = hf_hub_download(repo_id="videoloc/seamless-basic", 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-basic")
13
- config = AutoConfig.from_pretrained("videoloc/seamless-basic")
 
 
 
 
 
 
14
 
15
  # Load data collator
16
  collator_file = hf_hub_download(repo_id="videoloc/seamless-basic", 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-basic", filename="modeling_seamless_basic.py")
13
+ spec = importlib.util.spec_from_file_location("modeling_seamless_basic", 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.SeamlessBasicConfig.from_pretrained("videoloc/seamless-basic")
19
+ model = modeling_module.HFSeamlessBasic.from_pretrained("videoloc/seamless-basic")
20
 
21
  # Load data collator
22
  collator_file = hf_hub_download(repo_id="videoloc/seamless-basic", filename="data_collator.py")