nielsr HF staff commited on
Commit
2f4c0ed
1 Parent(s): a92f83c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +4 -4
README.md CHANGED
@@ -15,12 +15,12 @@ Current datasets include:
15
  You can read in a label file as follows (using the `huggingface_hub` library):
16
 
17
  ```
18
- from huggingface_hub import hf_hub_url, cached_download
19
  import json
20
 
21
- REPO_ID = "datasets/huggingface/label-files"
22
- FILENAME = "imagenet-22k-id2label.json"
23
- id2label = json.load(open(cached_download(hf_hub_url(REPO_ID, FILENAME)), "r"))
24
  id2label = {int(k):v for k,v in id2label.items()}
25
  ```
26
 
 
15
  You can read in a label file as follows (using the `huggingface_hub` library):
16
 
17
  ```
18
+ from huggingface_hub import hf_hub_download
19
  import json
20
 
21
+ repo_id = "datasets/huggingface/label-files"
22
+ filename = "imagenet-22k-id2label.json"
23
+ id2label = json.load(open(hf_hub_download(repo_id, filename, repo_type="dataset"), "r"))
24
  id2label = {int(k):v for k,v in id2label.items()}
25
  ```
26