AttributeError: 'SegformerImageProcessor' object has no attribute 'reduce_labels'
Author: andysingal
Pull request: no

### System Info

jupyter notebook, RTX 3090

### Who can help?

@amyeroberts @pacman100 

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

Please check: https://colab.research.google.com/drive/1CRzivM0AfwtmV39f5ElpQa_-vLrTS1Aq?usp=sharing
```
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[18], line 26
      3 training_args = TrainingArguments(
      4     output_dir=f"{model_name}-scene-parse-150-lora",
      5     learning_rate=5e-4,
   (...)
     16     report_to="wandb"
     17 )
     18 trainer = Trainer(
     19     model=lora_model,
     20     args=training_args,
   (...)
     23     compute_metrics=compute_metrics,
     24 )
---> 26 trainer.train()

File /usr/local/lib/python3.10/dist-packages/transformers/trainer.py:1546, in Trainer.train(self, resume_from_checkpoint, trial, ignore_keys_for_eval, **kwargs)
   1543 try:
   1544     # Disable progress bars when uploading models during checkpoints to avoid polluting stdout
   1545     hf_hub_utils.disable_progress_bars()
-> 1546     return inner_training_loop(
   1547         args=args,
   1548         resume_from_checkpoint=resume_from_checkpoint,
   1549         trial=trial,
   1550         ignore_keys_for_eval=ignore_keys_for_eval,
   1551     )
   1552 finally:
   1553     hf_hub_utils.enable_progress_bars()

File /usr/local/lib/python3.10/dist-packages/transformers/trainer.py:1944, in Trainer._inner_training_loop(self, batch_size, args, resume_from_checkpoint, trial, ignore_keys_for_eval)
   1941     self.control.should_training_stop = True
   1943 self.control = self.callback_handler.on_epoch_end(args, self.state, self.control)
-> 1944 self._maybe_log_save_evaluate(tr_loss, model, trial, epoch, ignore_keys_for_eval)
   1946 if DebugOption.TPU_METRICS_DEBUG in self.args.debug:
   1947     if is_torch_tpu_available():
   1948         # tpu-comment: Logging debug metrics for PyTorch/XLA (compile, execute times, ops, etc.)

File /usr/local/lib/python3.10/dist-packages/transformers/trainer.py:2256, in Trainer._maybe_log_save_evaluate(self, tr_loss, model, trial, epoch, ignore_keys_for_eval)
   2254         metrics.update(dataset_metrics)
   2255 else:
-> 2256     metrics = self.evaluate(ignore_keys=ignore_keys_for_eval)
   2257 self._report_to_hp_search(trial, self.state.global_step, metrics)
   2259 # Run delayed LR scheduler now that metrics are populated

File /usr/local/lib/python3.10/dist-packages/transformers/trainer.py:2972, in Trainer.evaluate(self, eval_dataset, ignore_keys, metric_key_prefix)
   2969 start_time = time.time()
   2971 eval_loop = self.prediction_loop if self.args.use_legacy_prediction_loop else self.evaluation_loop
-> 2972 output = eval_loop(
   2973     eval_dataloader,
   2974     description="Evaluation",
   2975     # No point gathering the predictions if there are no metrics, otherwise we defer to
   2976     # self.args.prediction_loss_only
   2977     prediction_loss_only=True if self.compute_metrics is None else None,
   2978     ignore_keys=ignore_keys,
   2979     metric_key_prefix=metric_key_prefix,
   2980 )
   2982 total_batch_size = self.args.eval_batch_size * self.args.world_size
   2983 if f"{metric_key_prefix}_jit_compilation_time" in output.metrics:

File /usr/local/lib/python3.10/dist-packages/transformers/trainer.py:3261, in Trainer.evaluation_loop(self, dataloader, description, prediction_loss_only, ignore_keys, metric_key_prefix)
   3257         metrics = self.compute_metrics(
   3258             EvalPrediction(predictions=all_preds, label_ids=all_labels, inputs=all_inputs)
   3259         )
   3260     else:
-> 3261         metrics = self.compute_metrics(EvalPrediction(predictions=all_preds, label_ids=all_labels))
   3262 else:
   3263     metrics = {}

Cell In[12], line 27, in compute_metrics(eval_pred)
     19 pred_labels = logits_tensor.detach().cpu().numpy()
     20 # currently using _compute instead of compute
     21 # see this issue for more info: https://github.com/huggingface/evaluate/pull/328#issuecomment-1286866576
     22 metrics = metric._compute(
     23     predictions=pred_labels,
     24     references=labels,
     25     num_labels=len(id2label),
     26     ignore_index=0,
---> 27     reduce_labels=image_processor.reduce_labels,
     28 )
     30 per_category_accuracy = metrics.pop("per_category_accuracy").tolist()
     31 per_category_iou = metrics.pop("per_category_iou").tolist()

AttributeError: 'SegformerImageProcessor' object has no attribute 'reduce_labels'
```

### Expected behavior

runs the model as shared in : https://huggingface.co/docs/peft/task_guides/semantic_segmentation_lora

Comments:
Hi, could you try use `do_reduce_labels` instead `reduce_labels`? The later one is already deprecated for quite some time.

(we might need to update the doc however)

Yes, It needs to be updated. Thanks

On Tue, Aug 29, 2023 at 7:36 PM Yih-Dar ***@***.***> wrote:

> (we might need to update the doc however)
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/transformers/issues/25801#issuecomment-1697512698>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AE4LJNP5I5TZJBLYCXI3IGLXXXZMZANCNFSM6AAAAAA4BXQRBA>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>


I hope the documentation is updated.

On Thu, Aug 31, 2023 at 5:37 PM Benjamin Bossan ***@***.***>
wrote:

> Closed #25801 <https://github.com/huggingface/transformers/issues/25801>
> as completed via huggingface/peft#891
> <https://github.com/huggingface/peft/pull/891>.
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/transformers/issues/25801#event-10243962094>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AE4LJNPBJ3UOKNXDILGJIHLXYB5ALANCNFSM6AAAAAA4BXQRBA>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>