-
Notifications
You must be signed in to change notification settings - Fork 654
Description
Instructions
Describe the problem
When using the matplotlib backend with the default style defined here, any version of matplotlib from 3.6 onward will give this error:
OSError: 'seaborn-ticks' is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)
The _DEFAULT_STYLE
in core/plots/matplotlib.py
is currently set to seaborn-ticks
, which has been deprecated in matplotlib as per this PR (see also this StackOverflow post). The old styles are still available, but have been renamed to include v8_0
in their names (e.g. seaborn-ticks
is now seaborn-v8_0-ticks
).
Code to reproduce issue
From the COCO-style evaluation example in the docs, but with the backend set to matplotlib:
import fiftyone as fo
import fiftyone.zoo as foz
dataset = foz.load_zoo_dataset("quickstart")
print(dataset)
# Performs an IoU sweep so that mAP and PR curves can be computed
results = dataset.evaluate_detections(
"predictions",
gt_field="ground_truth",
compute_mAP=True,
)
print(results.mAP())
# 0.3957
plot = results.plot_pr_curves(classes=["person", "kite", "car"], backend="matplotlib")
plot.show()
System information
- OS Platform and Distribution: Linux Ubuntu 22.04
- Python version (
python --version
): Python 3.10.12 - FiftyOne version (
fiftyone --version
): FiftyOne v0.23.7 - FiftyOne installed from (pip or source): pip
Other info/logs
Full traceback:
Traceback (most recent call last):
File "/home/jeroen/tmp.py", line 17, in <module>
plot = results.plot_pr_curves(classes=["person", "kite", "car"], backend="matplotlib")
File "/home/jeroen/.pyenv/versions/explore/lib/python3.10/site-packages/fiftyone/utils/eval/coco.py", line 345, in plot_pr_curves
return fop.plot_pr_curves(
File "/home/jeroen/.pyenv/versions/explore/lib/python3.10/site-packages/fiftyone/core/plots/base.py", line 264, in plot_pr_curves
return _plot_pr_curves(precisions, recall, classes, **kwargs)
File "/home/jeroen/.pyenv/versions/explore/lib/python3.10/site-packages/fiftyone/core/plots/matplotlib.py", line 345, in plot_pr_curves
with plt.style.context(style):
File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
return next(self.gen)
File "/home/jeroen/.pyenv/versions/explore/lib/python3.10/site-packages/matplotlib/style/core.py", line 194, in context
use(style)
File "/home/jeroen/.pyenv/versions/explore/lib/python3.10/site-packages/matplotlib/style/core.py", line 139, in use
raise
5FFC
OSError(
OSError: 'seaborn-ticks' is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)
Willingness to contribute
The FiftyOne Community encourages bug fix contributions. Would you or another
member of your organization be willing to contribute a fix for this bug to the
FiftyOne codebase?
- Yes. I can contribute a fix for this bug independently
- Yes. I would be willing to contribute a fix for this bug with guidance
from the FiftyOne community - No. I cannot contribute a bug fix at this time
I see two possible solutions:
- Change the default style to
seaborn-v8_0-ticks
if the installed matplotlib version is >= 3.6.0 - Change the default style to one that works across matplotlib versions
While the second one does result in a change in the default visual style of the plots, it is simpler to implement and maintain than checking versions of installed packages, and would be my suggested solution. I'd be happy to create a pull request for either solution.