[config] Ensure that id2label always takes precedence over num_labels

This commit is contained in:
Julien Chaumond
2020-06-01 16:54:55 +02:00
parent 751a1e0890
commit ec8717d5d8

View File

@@ -89,7 +89,7 @@ class PretrainedConfig(object):
self.id2label = kwargs.pop("id2label", None)
self.label2id = kwargs.pop("label2id", None)
if self.id2label is not None:
del kwargs["num_labels"]
kwargs.pop("num_labels", None)
self.id2label = dict((int(key), value) for key, value in self.id2label.items())
# Keys are always strings in JSON so convert ids to int here.
else: