Use repo_type instead of deprecated datasets repo IDs (#19202)
* Use repo_type instead of deprecated datasets repo IDs * Add missing one in doc
This commit is contained in:
@@ -67,9 +67,9 @@ You'll also want to create a dictionary that maps a label id to a label class wh
|
||||
>>> import json
|
||||
>>> from huggingface_hub import cached_download, hf_hub_url
|
||||
|
||||
>>> repo_id = "datasets/huggingface/label-files"
|
||||
>>> repo_id = "huggingface/label-files"
|
||||
>>> filename = "ade20k-id2label.json"
|
||||
>>> id2label = json.load(open(cached_download(hf_hub_url(repo_id, filename)), "r"))
|
||||
>>> id2label = json.load(open(cached_download(hf_hub_url(repo_id, filename, repo_type="dataset")), "r"))
|
||||
>>> id2label = {int(k): v for k, v in id2label.items()}
|
||||
>>> label2id = {v: k for k, v in id2label.items()}
|
||||
>>> num_labels = len(id2label)
|
||||
|
||||
Reference in New Issue
Block a user