mo01018 commited on
Commit
a33168c
·
verified ·
1 Parent(s): 3bea94b

Update load_pipeline_from_hub function

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -8,7 +8,7 @@ import datetime
8
  import numpy as np
9
  from huggingface_hub import hf_hub_download
10
  import torch
11
-
12
 
13
  pd.set_option('display.max_colwidth', 1000)
14
 
@@ -21,9 +21,16 @@ def cpu_load(*args, **kwargs):
21
  torch.load = cpu_load
22
 
23
  def load_pipeline_from_hub(filename):
 
 
 
24
  repo_id = 'hw01558/nlp-coursework-pipelines'
25
- local_path = hf_hub_download(repo_id=repo_id, filename=filename)
26
  return load(local_path)
 
 
 
 
27
 
28
  PIPELINES = [
29
  {
 
8
  import numpy as np
9
  from huggingface_hub import hf_hub_download
10
  import torch
11
+ import os
12
 
13
  pd.set_option('display.max_colwidth', 1000)
14
 
 
21
  torch.load = cpu_load
22
 
23
  def load_pipeline_from_hub(filename):
24
+ cache_dir = "/tmp/hf_cache"
25
+ os.environ["HF_HUB_CACHE"] = cache_dir # optional but informative
26
+
27
  repo_id = 'hw01558/nlp-coursework-pipelines'
28
+ local_path = hf_hub_download(repo_id=repo_id, filename=filename, cache_dir=cache_dir)
29
  return load(local_path)
30
+
31
+ #repo_id = 'hw01558/nlp-coursework-pipelines'
32
+ #local_path = hf_hub_download(repo_id=repo_id, filename=filename)
33
+ #return load(local_path)
34
 
35
  PIPELINES = [
36
  {