Skip to content

Commit 5c576f5

Browse files
authored
🚨🚨🚨 image-classification pipeline single-label and multi-label prob type squashing fns (sigmoid vs softmax) are backwards (#35848)
single-label and multi-label prob type squashing fns (sigmoid vs softmax) were backwards for image-classification pipeline
1 parent 5450e7c commit 5c576f5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎src/transformers/pipelines/image_classification.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ def _forward(self, model_inputs):
189189

190190
def postprocess(self, model_outputs, function_to_apply=None, top_k=5):
191191
if function_to_apply is None:
192-
if self.model.config.problem_type == "single_label_classification" or self.model.config.num_labels == 1:
192+
if self.model.config.problem_type == "multi_label_classification" or self.model.config.num_labels == 1:
193193
function_to_apply = ClassificationFunction.SIGMOID
194-
elif self.model.config.problem_type == "multi_label_classification" or self.model.config.num_labels > 1:
194+
elif self.model.config.problem_type == "single_label_classification" or self.model.config.num_labels > 1:
195195
function_to_apply = ClassificationFunction.SOFTMAX
196196
elif hasattr(self.model.config, "function_to_apply") and function_to_apply is None:
197197
function_to_apply = self.model.config.function_to_apply

0 commit comments

Comments
 (0)