emanuelaboros commited on
Commit
0c042a3
·
verified ·
1 Parent(s): 32f63b8

Update modeling_lang.py

Browse files
Files changed (1) hide show
  1. modeling_lang.py +18 -1
modeling_lang.py CHANGED
@@ -19,7 +19,24 @@ class LangDetectorModel(PreTrainedModel):
19
  self.dummy_param = nn.Parameter(torch.zeros(1))
20
  # Load floret model
21
  print('Does it arrive here:', self.config.config)
22
- self.model_floret = floret.load_model(self.config.config.filename)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  #
25
  def forward(self, input_ids, **kwargs):
 
19
  self.dummy_param = nn.Parameter(torch.zeros(1))
20
  # Load floret model
21
  print('Does it arrive here:', self.config.config)
22
+
23
+ # Get filename from config
24
+ bin_filename = self.config.config.filename
25
+
26
+ # Check if the file is already present locally, else download it
27
+ if not os.path.exists(bin_filename):
28
+ print(f"{bin_filename} not found locally, downloading from Hugging Face hub...")
29
+ bin_path = hf_hub_download(repo_id=self.config.config._name_or_path,
30
+ filename=bin_filename)
31
+ print(f"Downloaded .bin file at: {bin_path}")
32
+ else:
33
+ print(f"{bin_filename} found locally.")
34
+
35
+ # Load floret model using the full path
36
+ self.model_floret = floret.load_model(bin_filename)
37
+
38
+
39
+ # self.model_floret = floret.load_model(self.config.config.filename)
40
 
41
  #
42
  def forward(self, input_ids, **kwargs):