JonusNattapong commited on
Commit
7f29093
·
verified ·
1 Parent(s): c139f1d

Upload trained model

Browse files
Files changed (1) hide show
  1. hanuman_loader.py +5 -5
hanuman_loader.py CHANGED
@@ -19,7 +19,7 @@ import torch
19
  from transformers import AutoTokenizer
20
  from modeling import Hanuman
21
  import json
22
- import os
23
 
24
 
25
  class HanumanModel:
@@ -40,8 +40,8 @@ class HanumanModel:
40
  # Download tokenizer
41
  tokenizer = AutoTokenizer.from_pretrained(repo_id)
42
 
43
- # Download config
44
- config_path = os.path.join(repo_id, "config.json") # This will be downloaded by HF
45
  with open(config_path, "r", encoding="utf-8") as f:
46
  cfg = json.load(f)
47
 
@@ -55,8 +55,8 @@ class HanumanModel:
55
  use_think_head=True # Assuming your model uses this
56
  )
57
 
58
- # Load weights
59
- model_path = os.path.join(repo_id, "pytorch_model.bin")
60
  state = torch.load(model_path, map_location=map_location)
61
  model.load_state_dict(state)
62
 
 
19
  from transformers import AutoTokenizer
20
  from modeling import Hanuman
21
  import json
22
+ from huggingface_hub import hf_hub_download
23
 
24
 
25
  class HanumanModel:
 
40
  # Download tokenizer
41
  tokenizer = AutoTokenizer.from_pretrained(repo_id)
42
 
43
+ # Download config file from HF Hub
44
+ config_path = hf_hub_download(repo_id, "config.json")
45
  with open(config_path, "r", encoding="utf-8") as f:
46
  cfg = json.load(f)
47
 
 
55
  use_think_head=True # Assuming your model uses this
56
  )
57
 
58
+ # Download and load model weights
59
+ model_path = hf_hub_download(repo_id, "pytorch_model.bin")
60
  state = torch.load(model_path, map_location=map_location)
61
  model.load_state_dict(state)
62