yalsaffar commited on
Commit
7a3f742
·
1 Parent(s): aa4aced
Files changed (2) hide show
  1. Dockerfile +5 -1
  2. models/nllb.py +3 -1
Dockerfile CHANGED
@@ -50,6 +50,10 @@ ENV NEMO_NLP_TMP=/app/.cache
50
  # Create cache directory
51
  RUN mkdir -p /app/.cache
52
 
 
 
 
 
53
  # Copy the setup script and requirements file into the container
54
  COPY setup.sh requirements.txt /app/
55
 
@@ -97,4 +101,4 @@ EXPOSE 3000
97
  ENV IN_DOCKER=True
98
 
99
  # Run the FastAPI app and Node.js server
100
- CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port 8000 & sleep 45 && /app/wait-for-it.sh --url http://0.0.0.0:8000/health --strict --timeout=300 -- node /app/app/server.js"]
 
50
  # Create cache directory
51
  RUN mkdir -p /app/.cache
52
 
53
+ # Set environment variable for Hugging Face cache directory
54
+ ENV HF_HOME=/app/.cache/huggingface
55
+ ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
56
+
57
  # Copy the setup script and requirements file into the container
58
  COPY setup.sh requirements.txt /app/
59
 
 
101
  ENV IN_DOCKER=True
102
 
103
  # Run the FastAPI app and Node.js server
104
+ CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port 8000 & sleep 20 && /app/wait-for-it.sh --url http://0.0.0.0:8000/health --strict --timeout=300 -- node /app/app/server.js"]
models/nllb.py CHANGED
@@ -1,6 +1,6 @@
1
  from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
2
  import torch
3
-
4
  def nllb():
5
  """
6
  Load and return the NLLB (No Language Left Behind) model and tokenizer.
@@ -19,6 +19,8 @@ def nllb():
19
  #device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
20
  device = torch.device("cpu")
21
  # Load the tokenizer and model
 
 
22
  tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-200-distilled-1.3B")
23
  model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-200-distilled-1.3B").to(device)
24
  # write done to the file named status.txt
 
1
  from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
2
  import torch
3
+ import os
4
  def nllb():
5
  """
6
  Load and return the NLLB (No Language Left Behind) model and tokenizer.
 
19
  #device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
20
  device = torch.device("cpu")
21
  # Load the tokenizer and model
22
+ os.environ['HF_HOME'] = '/app/.cache/huggingface'
23
+ os.environ['TRANSFORMERS_CACHE'] = '/app/.cache/huggingface'
24
  tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-200-distilled-1.3B")
25
  model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-200-distilled-1.3B").to(device)
26
  # write done to the file named status.txt