packaging.version.InvalidVersion: Invalid version: '0.10.1,<0.11'
I meet this error when start training
Traceback (most recent call last):
File "main.py", line 6, in
I have the same problem.
having the same problem. It has something to do with transformers package and pl version
I get the same issue. I updated pytorch-lightning to a more recent version like 1.5.0, which fixed this error:
cannot import name 'get_num_classes' from 'torchmetrics.utilities.data'
but then it created a different issue in pytorch-lightning where it couldn't create a trainer from arguments.
NameError: name 'trainer' is not defined
if you remove the transformers package, then it runs correctly. Also kornia (0.5.0) needs to be installed and torchmetrics 0.10 or 0.11
I get the same issue. I updated pytorch-lightning to a more recent version like 1.5.0, which fixed this error:
cannot import name 'get_num_classes' from 'torchmetrics.utilities.data'but then it created a different issue in pytorch-lightning where it couldn't create a trainer from arguments.NameError: name 'trainer' is not defined
did you fix the '0.10.1<0.11' error?
I have the same problem
Downgrade torchmetrics to 0.5
using pytorch-lightning=1.8 works fine for me.
-
packaging.version.InvalidVersion: Invalid version: '0.10.1,<0.11'- Upgrading transfomers to 4.6 or higher works for me
- Related issue: https://github.com/huggingface/transformers/issues/20799#issuecomment-1375328420
-
ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data'- Downgrading torchmetrics to 0.6 works for me
use
pip list | grep packaging
to check if the version of your packaging is upper than 21.3
try to reinstall your packaging , like this
pip install packaging==21.3
this issue has something to do with the format requirements in new packaging version checking
TLDR:
conda env create -f environment.yaml
conda activate ldm
pip install packaging==21.3
pip install 'torchmetrics<0.8'
- Perform
pip install packaging==21.3as mentioned by @Candysad to fixpackaging.version.InvalidVersion: Invalid version: '0.10.1,<0.11'. - Then comes to the second error
ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data'. This is becausetorchmetricsremovedget_num_classesfromtorchmetrics.utilities.dataat version v0.8.0, so a quick fix can bepip install 'torchmetrics<0.8'to downgrade your torchmetrics version to0.7.3
I get the same issue. I updated pytorch-lightning to a more recent version like 1.5.0, which fixed this error:
cannot import name 'get_num_classes' from 'torchmetrics.utilities.data'but then it created a different issue in pytorch-lightning where it couldn't create a trainer from arguments.NameError: name 'trainer' is not defined
hey, did you solve the problem with the 'trainer' not defined?
I'm interested in how did you solve the NameError: name 'trainer' is not defined as well
Hello, I would like to ask the difference between unconditional LDM and conditional LDM. After the model is trained, is unconditional sampling generate image randomly, but not based on a given image? So, if I want to generate a normal image from a flawed image (without any annotations in the inference phase), should I use conditional LDM? @HuengchI @zaburo-ch @tianye2856 @scottp100
packaging.version.InvalidVersion: Invalid version: '0.10.1,<0.11'
- Upgrading transfomers to 4.6 or higher works for me
- Related issue: ImportError: cannot import name 'AutoModelForMaskedLM' from 'transformers' (unknown location) huggingface/transformers#20799 (comment)
ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data'
- Downgrading torchmetrics to 0.6 works for me
me too, good job
But a final step “pip install einops==0.6.0” was before successful running at my side.
conda env create -f environment.yaml conda activate ldm pip install packaging==21.3 pip install 'torchmetrics<0.8'
Works good for me
However, I also encounter the error from torch._six import string_classes ModuleNotFoundError: No module named 'torch._six'
Doing the following step is helpful for me: (reference https://github.com/pytorch/pytorch/pull/94709)
from torch._six import string_classes
-> delete this import and replace string_classes with str
TLDR:
conda env create -f environment.yaml conda activate ldm pip install packaging==21.3 pip install 'torchmetrics<0.8'
Tried this but now I'm getting this error. This error occurs during Sampling Batches (unconditional): (DDIM Sampler & Plotting: Restored training weights runs successfully).
File "scripts/sample_diffusion.py", line 309, in
run(model, imglogdir, eta=opt.eta, File "scripts/sample_diffusion.py", line 123, in run logs = make_convolutional_sample(model, batch_size=batch_size, File "/home/usama/.local/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "scripts/sample_diffusion.py", line 100, in make_convolutional_sample x_sample = model.decode_first_stage(sample) File "/home/usama/.local/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "/home/usama/usama/others/latent-diffusion/ldm/models/diffusion/ddpm.py", line 761, in decode_first_stage return self.first_stage_model.decode(z, force_not_quantize=predict_cids or force_not_quantize) File "/home/usama/usama/others/latent-diffusion/ldm/models/autoencoder.py", line 277, in decode quant, emb_loss, info = self.quantize(h) File "/home/usama/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(*args, **kwargs) File "/home/usama/usama/others/latent-diffusion/src/taming-transformers/taming/modules/vqvae/quantize.py", line 276, in forward z = rearrange(z, 'b c h w -> b h w c').contiguous() File "/home/usama/anaconda3/envs/latent-diff/lib/python3.8/site-packages/einops/einops.py", line 424, in rearrange return reduce(tensor, pattern, reduction='rearrange', **axes_lengths) File "/home/usama/anaconda3/envs/latent-diff/lib/python3.8/site-packages/einops/einops.py", line 368, in reduce return recipe.apply(tensor) File "/home/usama/anaconda3/envs/latent-diff/lib/python3.8/site-packages/einops/einops.py", line 203, in apply backend = get_backend(tensor) File "/home/usama/anaconda3/envs/latent-diff/lib/python3.8/site-packages/einops/_backends.py", line 49, in get_backend if backend.is_appropriate_type(tensor): File "/home/usama/anaconda3/envs/latent-diff/lib/python3.8/site-packages/einops/_backends.py", line 513, in is_appropriate_type return self.K.is_tensor(tensor) and self.K.is_keras_tensor(tensor) AttributeError: module 'keras.backend' has no attribute 'is_tensor'
How do I just add this thread to my favourites? :D This is so unbelievable.
TLDR:
conda env create -f environment.yaml conda activate ldm pip install packaging==21.3 pip install 'torchmetrics<0.8'
- Perform
pip install packaging==21.3as mentioned by @Candysad to fixpackaging.version.InvalidVersion: Invalid version: '0.10.1,<0.11'.- Then comes to the second error
ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data'. This is becausetorchmetricsremovedget_num_classesfromtorchmetrics.utilities.dataat version v0.8.0, so a quick fix can bepip install 'torchmetrics<0.8'to downgrade your torchmetrics version to0.7.3
I followed exactly these steps, and got the following error:
ValueError: transformers.__spec__ is None
Has anyone also encountered this issue?
TLDR:
conda env create -f environment.yaml conda activate ldm pip install packaging==21.3 pip install 'torchmetrics<0.8'
- Perform
pip install packaging==21.3as mentioned by @Candysad to fixpackaging.version.InvalidVersion: Invalid version: '0.10.1,<0.11'.- Then comes to the second error
ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data'. This is becausetorchmetricsremovedget_num_classesfromtorchmetrics.utilities.dataat version v0.8.0, so a quick fix can bepip install 'torchmetrics<0.8'to downgrade your torchmetrics version to0.7.3I followed exactly these steps, and got the following error:
ValueError: transformers.__spec__ is NoneHas anyone also encountered this issue?
Updating transformers to 4.10.2 solved the issue for me.
New TLDR: conda env create -f environment.yaml conda activate ldm pip install packaging==21.3 pip install 'torchmetrics<0.8' pip install transformers==4.10.2