Marcin-XStudio commited on
Commit
10fbe68
·
1 Parent(s): 854d4b4

change path

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -17,11 +17,14 @@ app = FastAPI()
17
 
18
 
19
  model_name = "numind/NuExtract-1.5-tiny"
20
- # MODEL_CACHE_DIR = "/app/model_cache"
21
- # model_cache_path = snapshot_download(
22
- # repo_id="numind/NuExtract-1.5-tiny",
23
- # cache_dir=MODEL_CACHE_DIR
24
- # )
 
 
 
25
  device = "gpu" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
26
  dtype = torch.float16 if device in ("mps", "gpu") else torch.float32
27
 
@@ -41,14 +44,14 @@ def load_model():
41
  # model_name, torch_dtype=dtype, trust_remote_code=True
42
  # )
43
  model = AutoModelForCausalLM.from_pretrained(
44
- "/app/model_cache/models--numind--NuExtract-1.5-tiny", # include the full folder name
45
  local_files_only=True,
46
  torch_dtype=dtype,
47
  trust_remote_code=True
48
  ).to(device).eval()
49
  # tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
50
  tokenizer = AutoTokenizer.from_pretrained(
51
- "/app/model_cache/models--numind--NuExtract-1.5-tiny", # include the full folder name
52
  local_files_only=True,
53
  trust_remote_code=True
54
  )
 
17
 
18
 
19
  model_name = "numind/NuExtract-1.5-tiny"
20
+ MODEL_CACHE_DIR = "/app/model_cache"
21
+ model_cache_path = snapshot_download(
22
+ repo_id="numind/NuExtract-1.5-tiny",
23
+ cache_dir=MODEL_CACHE_DIR
24
+ )
25
+
26
+ print(">>> MODEL CACHE PATH:", model_cache_path, os.listdir(model_cache_path))
27
+
28
  device = "gpu" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
29
  dtype = torch.float16 if device in ("mps", "gpu") else torch.float32
30
 
 
44
  # model_name, torch_dtype=dtype, trust_remote_code=True
45
  # )
46
  model = AutoModelForCausalLM.from_pretrained(
47
+ model_cache_path,
48
  local_files_only=True,
49
  torch_dtype=dtype,
50
  trust_remote_code=True
51
  ).to(device).eval()
52
  # tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
53
  tokenizer = AutoTokenizer.from_pretrained(
54
+ model_cache_path,
55
  local_files_only=True,
56
  trust_remote_code=True
57
  )