Narsil HF staff commited on
Commit
6a7afd0
1 Parent(s): b261536

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py CHANGED
@@ -4,9 +4,23 @@ import datetime
4
  import tempfile
5
  from huggingface_hub import hf_hub_download
6
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  def download_slow(repo_id):
9
  os.environ.pop("HF_TRANSFER", None)
 
 
10
  with tempfile.TemporaryDirectory() as workdir:
11
  hf_hub_download(
12
  repo_id,
@@ -28,6 +42,10 @@ def download_fast(repo_id):
28
 
29
 
30
  def download(repo_id):
 
 
 
 
31
  start = datetime.datetime.now()
32
  download_slow(repo_id)
33
  taken_slow = datetime.datetime.now() - start
 
4
  import tempfile
5
  from huggingface_hub import hf_hub_download
6
 
7
+ def download_very_slow(repo_id):
8
+ os.environ.pop("HF_TRANSFER", None)
9
+ os.environ["HF_CHUNK_SIZE"] = "1024"
10
+
11
+ with tempfile.TemporaryDirectory() as workdir:
12
+ hf_hub_download(
13
+ repo_id,
14
+ filename="pytorch_model.bin",
15
+ force_download=True,
16
+ cache_dir=workdir,
17
+ )
18
+
19
 
20
  def download_slow(repo_id):
21
  os.environ.pop("HF_TRANSFER", None)
22
+ os.environ["HF_CHUNK_SIZE"] = "10485760"
23
+
24
  with tempfile.TemporaryDirectory() as workdir:
25
  hf_hub_download(
26
  repo_id,
 
42
 
43
 
44
  def download(repo_id):
45
+ start = datetime.datetime.now()
46
+ download_very_slow(repo_id)
47
+ taken_slow = datetime.datetime.now() - start
48
+
49
  start = datetime.datetime.now()
50
  download_slow(repo_id)
51
  taken_slow = datetime.datetime.now() - start