Eearthling commited on
Commit
dac9fa6
·
verified ·
1 Parent(s): bb05853

Upload 2 files

Browse files
Files changed (2) hide show
  1. Dockerfile +4 -1
  2. download_models.py +37 -0
Dockerfile CHANGED
@@ -17,10 +17,13 @@ RUN pip install --no-cache-dir -r requirements.txt
17
  RUN useradd -m -u 1000 user
18
  USER user
19
  ENV HOME=/home/user \
20
- PATH=/home/user/.local/bin:$PATH
21
 
22
  WORKDIR $HOME/app
23
 
 
 
 
24
  COPY --chown=user . $HOME/app
25
 
26
  EXPOSE 7860
 
17
  RUN useradd -m -u 1000 user
18
  USER user
19
  ENV HOME=/home/user \
20
+ PATH=/home/user/.local/bin:$PATH
21
 
22
  WORKDIR $HOME/app
23
 
24
+ COPY --chown=user download_models.py .
25
+ RUN python download_models.py
26
+
27
  COPY --chown=user . $HOME/app
28
 
29
  EXPOSE 7860
download_models.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import urllib.request
3
+ from transformers import PegasusForConditionalGeneration, PegasusTokenizer
4
+ from transformers import AutoTokenizer, M2M100ForConditionalGeneration, M2M100Config
5
+
6
+ def download_file(url, filename):
7
+ print(f"Downloading {filename} from {url}...")
8
+ try:
9
+ urllib.request.urlretrieve(url, filename)
10
+ print(f"Successfully downloaded {filename}")
11
+ except Exception as e:
12
+ print(f"Error downloading {filename}: {e}")
13
+ raise
14
+
15
+ def download_hf_models():
16
+ # PEGUSUS
17
+ pegasus_name = "google/pegasus-cnn_dailymail"
18
+ print(f"Downloading {pegasus_name}...")
19
+ PegasusTokenizer.from_pretrained(pegasus_name)
20
+ PegasusForConditionalGeneration.from_pretrained(pegasus_name)
21
+
22
+ # NLLB
23
+ nllb_name = "facebook/nllb-200-distilled-1.3B"
24
+ print(f"Downloading {nllb_name}...")
25
+ AutoTokenizer.from_pretrained(nllb_name)
26
+ M2M100Config.from_pretrained(nllb_name)
27
+ M2M100ForConditionalGeneration.from_pretrained(nllb_name)
28
+
29
+ print("All Hugging Face models downloaded and cached.")
30
+
31
+ if __name__ == "__main__":
32
+ # Download lid.176.bin
33
+ fasttext_url = "https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.bin"
34
+ download_file(fasttext_url, "lid.176.bin")
35
+
36
+ # Download HF Models
37
+ download_hf_models()