ImportError: cannot import name 'x' from 'y'
(ldm) C:\WBC\latent-diffusion-main&gt;python scripts/txt2img.py --prompt &quot;a sunset behind a mountain range, vector image&quot; --ddim_eta 1.0 --n_samples 1 --n_iter 1 --H 384 --W 1024 --scale 5.0
Loading model from models/ldm/text2img-large/model.ckpt
Traceback (most recent call last):
  File &quot;scripts/txt2img.py&quot;, line 108, in &lt;module&gt;
    model = load_model_from_config(config, &quot;models/ldm/text2img-large/model.ckpt&quot;)  # TODO: check path
  File &quot;scripts/txt2img.py&quot;, line 19, in load_model_from_config
    model = instantiate_from_config(config.model)
  File &quot;c:\wbc\latent-diffusion-main\ldm\util.py&quot;, line 78, in instantiate_from_config
    return get_obj_from_str(config[&quot;target&quot;])(**config.get(&quot;params&quot;, dict()))
  File &quot;c:\wbc\latent-diffusion-main\ldm\util.py&quot;, line 86, in get_obj_from_str
    return getattr(importlib.import_module(module, package=None), cls)
  File &quot;C:\ProgramData\Anaconda3\envs\ldm\lib\importlib\__init__.py&quot;, line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1014, in _gcd_import
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 991, in _find_and_load
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 975, in _find_and_load_unlocked
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 671, in _load_unlocked
  File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 783, in exec_module
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 219, in _call_with_frames_removed
  File &quot;c:\wbc\latent-diffusion-main\ldm\models\diffusion\ddpm.py&quot;, line 12, in &lt;module&gt;
    import pytorch_lightning as pl
  File &quot;C:\ProgramData\Anaconda3\envs\ldm\lib\site-packages\pytorch_lightning\__init__.py&quot;, line 20, in &lt;module&gt;
    from pytorch_lightning import metrics  # noqa: E402
  File &quot;C:\ProgramData\Anaconda3\envs\ldm\lib\site-packages\pytorch_lightning\metrics\__init__.py&quot;, line 15, in &lt;module&gt;
    from pytorch_lightning.metrics.classification import (  # noqa: F401
  File &quot;C:\ProgramData\Anaconda3\envs\ldm\lib\site-packages\pytorch_lightning\metrics\classification\__init__.py&quot;, line 14, in &lt;module&gt;
    from pytorch_lightning.metrics.classification.accuracy import Accuracy  # noqa: F401
  File &quot;C:\ProgramData\Anaconda3\envs\ldm\lib\site-packages\pytorch_lightning\metrics\classification\accuracy.py&quot;, line 18, in &lt;module&gt;
    from pytorch_lightning.metrics.utils import deprecated_metrics, void
  File &quot;C:\ProgramData\Anaconda3\envs\ldm\lib\site-packages\pytorch_lightning\metrics\utils.py&quot;, line 22, in &lt;module&gt;
    from torchmetrics.utilities.data import get_num_classes as _get_num_classes
ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data' (C:\ProgramData\Anaconda3\envs\ldm\lib\site-packages\torchmetrics\utilities\data.py)

I can't run a latent diffusion neural network. I'm using anaconda and the environment that comes with the neural network. I think I'm doing everything right, but something goes wrong. If you know how to solve this problem, I would be extremely grateful.

Looking at your error, it appears get_num_classes doesn't exist anymore. I verified this by looking that their github and docs.
It was removed after this commit.
