mlcommons / GaNDLF

A generalizable application framework for segmentation, regression, and classification using PyTorch
https://gandlf.org
Apache License 2.0
152 stars 77 forks source link

AUROC error while running classification of pathology images #817

Closed sylwiamm closed 3 weeks ago

sylwiamm commented 4 months ago

Describe the bug

A clear and concise description of what the bug is. Metrics error while running pathology classification on the cluster.

To Reproduce

Steps to reproduce the behavior:

  1. Use the data 'TIL classification'
  2. Run 'Classification, model VGG16'
  3. See error (it would be helpful to include the error message and stack trace)
    ERROR: Traceback (most recent call last):
    File "GaNDLF/gandlf_run", line 126, in <module>
    main_run(
    File "GaNDLF/GANDLF/cli/main_run.py", line 103, in main_run
    TrainingManager_split(
    File "GaNDLF/GANDLF/training_manager.py", line 348, in TrainingManager_split
    training_loop(
    File "GaNDLF/GANDLF/compute/training_loop.py", line 346, in training_loop
    overall_metrics = overall_stats(
    File "GaNDLF/GANDLF/metrics/__init__.py", line 120, in overall_stats
    return classification.overall_stats(predictions, ground_truth, params)
    File "GaNDLF/GANDLF/metrics/classification.py", line 77, in overall_stats
    output_metrics[metric_name] = get_output_from_calculator(
    File "GaNDLF/GANDLF/utils/tensor.py", line 540, in get_output_from_calculator
    temp_output = calculator(prediction, target)
    File "dev_gandlf/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
    File "dev_gandlf/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
    File "dev_gandlf/lib/python3.9/site-packages/torchmetrics/metric.py", line 298, in forward
    self._forward_cache = self._forward_reduce_state_update(*args, **kwargs)
    File "dev_gandlf/lib/python3.9/site-packages/torchmetrics/metric.py", line 368, in _forward_reduce_state_update
    batch_val = self.compute()
    File "dev_gandlf/lib/python3.9/site-packages/torchmetrics/metric.py", line 607, in wrapped_func
    value = _squeeze_if_scalar(compute(*args, **kwargs))
    File "dev_gandlf/lib/python3.9/site-packages/torchmetrics/classification/auroc.py", line 123, in compute
    return _binary_auroc_compute(state, self.thresholds, self.max_fpr)
    File "dev_gandlf/lib/python3.9/site-packages/torchmetrics/functional/classification/auroc.py", line 88, in _binary_auroc_compute
    fpr, tpr, _ = _binary_roc_compute(state, thresholds, pos_label)
    File "dev_gandlf/lib/python3.9/site-packages/torchmetrics/functional/classification/roc.py", line 54, in _binary_roc_compute
    fps, tps, thres = _binary_clf_curve(preds=state[0], target=state[1], pos_label=pos_label)
    File "dev_gandlf/lib/python3.9/site-packages/torchmetrics/functional/classification/precision_recall_curve.py", line 61, in _binary_clf_curve
    target = target[desc_score_indices]
    IndexError: index 7 is out of bounds for dimension 0 with size 5

Expected behavior

It supposed to work :)

Media

If applicable, add images, screenshots or other relevant media to help explain your problem.

Environment information

GaNDLF version, OS, and any other relevant information.

Additional context

Add any other context about the problem here.

sylwiamm commented 4 months ago

@sarthakpati you can assign this to me

sarthakpati commented 4 months ago

Thanks!

I just updated the formatting a bit to make the report more legible. 😄

github-actions[bot] commented 2 months ago

Stale issue message

github-actions[bot] commented 3 weeks ago

Stale issue message

sarthakpati commented 3 weeks ago

Should be fixed with #885