Diamanta commited on
Commit
5b048d0
·
verified ·
1 Parent(s): 809cefd

Update download_model.py

Browse files
Files changed (1) hide show
  1. download_model.py +5 -4
download_model.py CHANGED
@@ -1,16 +1,17 @@
1
  import os
2
  from huggingface_hub import hf_hub_download
3
 
4
- # Redirect all internal caching to writable location
5
  os.environ["HF_HOME"] = "/tmp/huggingface"
6
  os.environ["HF_HUB_CACHE"] = "/tmp/huggingface"
7
 
 
8
  model_path = hf_hub_download(
9
  repo_id="TheBloke/phi-2-GGUF",
10
  filename="phi-2.Q4_K_M.gguf",
11
  cache_dir="/tmp/huggingface"
12
  )
13
 
14
- # Copy model to working directory
15
- import shutil
16
- shutil.copy(model_path, "./phi-2.Q4_K_M.gguf")
 
1
  import os
2
  from huggingface_hub import hf_hub_download
3
 
4
+ # Set environment to use writable location
5
  os.environ["HF_HOME"] = "/tmp/huggingface"
6
  os.environ["HF_HUB_CACHE"] = "/tmp/huggingface"
7
 
8
+ # Download model into temp-writable location
9
  model_path = hf_hub_download(
10
  repo_id="TheBloke/phi-2-GGUF",
11
  filename="phi-2.Q4_K_M.gguf",
12
  cache_dir="/tmp/huggingface"
13
  )
14
 
15
+ # Save the path so app.py can use it
16
+ with open("/tmp/model_path.txt", "w") as f:
17
+ f.write(model_path)