Marcin-XStudio commited on
Commit
d1a5b46
·
1 Parent(s): 6ac2280

fix write access error

Browse files
Files changed (2) hide show
  1. Dockerfile +9 -6
  2. app.py +8 -8
Dockerfile CHANGED
@@ -1,23 +1,26 @@
 
1
  FROM python:3.10-slim
2
  WORKDIR /app
3
 
4
- # 1) Install HF tools + your deps
5
  RUN pip install --no-cache-dir huggingface_hub
6
  COPY requirements.txt .
7
  RUN pip install --no-cache-dir -r requirements.txt
8
 
9
- # 2) Snapshot the model into /app/model_cache
 
 
 
10
  RUN python - <<EOF
11
  from huggingface_hub import snapshot_download
 
12
  snapshot_download(
13
  repo_id="numind/NuExtract-1.5-tiny",
14
- cache_dir="/app/model_cache",
15
- local_dir="numind/NuExtract-1.5-tiny",
16
- local_dir_use_symlinks=False
17
  )
18
  EOF
19
 
20
- # 3) Copy your code
21
  COPY . .
22
 
23
  ENV PORT=7860
 
1
+ # Dockerfile
2
  FROM python:3.10-slim
3
  WORKDIR /app
4
 
5
+ # 1) Install HF tooling & your deps
6
  RUN pip install --no-cache-dir huggingface_hub
7
  COPY requirements.txt .
8
  RUN pip install --no-cache-dir -r requirements.txt
9
 
10
+ # 2) Create a cache dir and make it world-writable
11
+ RUN mkdir -p /app/model_cache && chmod 777 /app/model_cache
12
+
13
+ # 3) Download the model into /app/model_cache
14
  RUN python - <<EOF
15
  from huggingface_hub import snapshot_download
16
+ # this writes under /app/model_cache/models--numind--NuExtract-1.5-tiny/...
17
  snapshot_download(
18
  repo_id="numind/NuExtract-1.5-tiny",
19
+ cache_dir="/app/model_cache"
 
 
20
  )
21
  EOF
22
 
23
+ # 4) Copy your code
24
  COPY . .
25
 
26
  ENV PORT=7860
app.py CHANGED
@@ -41,17 +41,17 @@ def load_model():
41
  # model_name, torch_dtype=dtype, trust_remote_code=True
42
  # )
43
  model = AutoModelForCausalLM.from_pretrained(
44
- model_cache_path,
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
- model_cache_path,
52
- local_files_only=True,
53
- trust_remote_code=True
54
- )
55
  print("Model and tokenizer loaded.", flush=True)
56
 
57
  def predict_NuExtract(texts, template, batch_size=10, max_length=5096, max_new_tokens=1024):
 
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
+ )
55
  print("Model and tokenizer loaded.", flush=True)
56
 
57
  def predict_NuExtract(texts, template, batch_size=10, max_length=5096, max_new_tokens=1024):