Skip to content

Unable to reproduce the accuracy on the COCO dataset as reported in the paper #284

Description

@1826133674

I am trying to reproduce the accuracy of FastSAM on the COCO dataset as reported in the Chinese paper, but I have encountered the following issues: How can I fix these issues?

  1. Unable to generate plots. The plot_mc_curve function in ap_per_class within the file path /FastSAM/ultralytics/yolo/utils/metrics.py raises an error. The error is as follows:
Traceback (most recent call last):
  File "/github/FastSAM/val_sa.py", line 4, in <module>
    model.val(data="sa_0.yaml", \
  File "/miniforge3/envs/FastSAM/lib/python3.9/site-packages/torch/utils/_contextlib.py", line 120, in decorate_context
    return func(*args, **kwargs)
  File "/github/FastSAM/ultralytics/yolo/engine/model.py", line 303, in val
    validator(model=self.model)
  File "/miniforge3/envs/FastSAM/lib/python3.9/site-packages/torch/utils/_contextlib.py", line 120, in decorate_context
    return func(*args, **kwargs)
  File "/github/FastSAM/ultralytics/yolo/engine/validator.py", line 148, in __call__
    desc = self.get_desc()
  File "/github/FastSAM/ultralytics/yolo/v8/detect/val.py", line 128, in get_stats
    self.metrics.process(*stats)
  File "/github/FastSAM/ultralytics/yolo/utils/metrics.py", line 769, in process
    results_mask = ap_per_class(tp_m,
  File "/github/FastSAM/ultralytics/yolo/utils/metrics.py", line 488, in ap_per_class
    plot_mc_curve(px, f1, save_dir / f'{prefix}F1_curve.png', names, ylabel='F1', on_plot=on_plot)
  File "/github/FastSAM/ultralytics/yolo/utils/__init__.py", line 196, in wrapper
    result = func(*args, **kwargs)
  File "/github/FastSAM/ultralytics/yolo/utils/metrics.py", line 358, in plot_mc_curve
    ax.plot(px, y, linewidth=1, label=f'{names[i]}')  # plot(confidence, metric)
KeyError: 1
  1. The actual data involved in the test is very small:
    After commenting out the plotting code, it was found that there were only 76 images in the entire COCO test dataset; the remaining 4,000+ images all generated such warnings and were filtered out.
coco_segs/images/val2017/000000581781.jpg: ignoring corrupt image/label: Label class 46 exceeds dataset class count 1. Possible class labels are 0-0

The final test results are output as follows:

Evaluating pycocotools mAP using fastsam/val83/predictions.json and dataset/coco_segs/annotations/instances_val2017.json...
loading annotations into memory...
Done (t=0.39s)
creating index...
index created!
Loading and preparing results...
DONE (t=0.02s)
creating index...
index created!
Running per image evaluation...
Evaluate annotation type *bbox*
DONE (t=0.09s).
Accumulating evaluation results...
DONE (t=0.04s).
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.011
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.017
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.011
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.003
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.013
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.020
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.168
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.366
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.189
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.354
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.448
Running per image evaluation...
Evaluate annotation type *segm*
DONE (t=0.10s).
Accumulating evaluation results...
DONE (t=0.04s).
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.009
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.015
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.011
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.003
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.010
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.018
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.004
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.146
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.319
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.172
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.315
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.380

The sa.yaml settings I adopted are as follows:

path: '/dataset/coco_segs/'

train: 'train2017.txt'

val: 'val2017.txt'
test: 'val2017.txt'

# Classes
names:
   0: object

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions