ImportError: cannot import name 'find_classes' from 'torchvision.datasets.folder'


When I m trying to create a trained-NN using GDVB framework, I get the following error.

Traceback (most recent call last):
File “/home/wg/anaconda3/lib/python3.8/”, line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File “/home/wg/anaconda3/lib/python3.8/”, line 87, in _run_code
exec(code, run_globals)
File “/home/wg/Documents/GDVB/lib/R4V/r4v/”, line 6, in
from . import cli
File “/home/wg/Documents/GDVB/lib/R4V/r4v/cli/”, line 5, in
from … import distillation
File “/home/wg/Documents/GDVB/lib/R4V/r4v/distillation/”, line 11, in
from .data import get_data_loader
File “/home/wg/Documents/GDVB/lib/R4V/r4v/distillation/”, line 12, in
from torchvision.datasets.folder import (
ImportError: cannot import name ‘find_classes’ from ‘torchvision.datasets.folder’ (/home/wg/Documents/GDVB/.venv/lib/python3.8/site-packages/torchvision/datasets/

Best regards

It looks like this depends on a very recent change to torchvision which may not have even made it to the conda packages yet.
Make DatasetFolder.find_classes public (#3628) · pytorch/vision@f9af70a (

You can try updating your version of torchvision and if that doesn’t work you might need to build and install from source.

Additionally to @eqy’s suggestions you could also install the nightly binary (select “Preview(nightly)” here) to get the most recent changes in the binaries.
I’ve checked that a relatively new torchvision version 0.10.0.dev20210516 contains the find_classes method.