InterDigitalInc / CompressAI

A PyTorch library and evaluation platform for end-to-end compression research
https://interdigitalinc.github.io/CompressAI/
BSD 3-Clause Clear License
1.12k stars 228 forks source link

error when trying to use entropy bottleneck of compressai in my code #297

Open takhtardeshirsoheib opened 1 month ago

takhtardeshirsoheib commented 1 month ago

error as below:

python train.py Traceback (most recent call last): File "C:\Users\sohtak\Ph.D-Sweden-France\Sweden\Phase2\Python-Codes\The_Final_versions\VAE_05062024_Bestversion\train.py", line 165, in main() File "C:\Users\sohtak\Ph.D-Sweden-France\Sweden\Phase2\Python-Codes\The_Final_versions\VAE_05062024_Bestversion\train.py", line 41, in main model = CombinedVAE(latent_channels=latent_channels, pre_trained_spatial_path='./Spatial_checkpoints/vae_model_FT_epoch_200.pth') File "C:\Users\sohtak\Ph.D-Sweden-France\Sweden\Phase2\Python-Codes\The_Final_versions\VAE_05062024_Bestversion\model.py", line 13, in init self.entropy_bottleneck = EntropyBottleneck(latent_channels_s) File "C:\Users\sohtak\Ph.D-Sweden-France\Sweden\Phase2\Python-Codes\The_Final_versions\VAE_05062024_Bestversion\compressai\compressai\entropy_models\entropy_models.py", line 351, in init super().init(*args, **kwargs) File "C:\Users\sohtak\Ph.D-Sweden-France\Sweden\Phase2\Python-Codes\The_Final_versions\VAE_05062024_Bestversion\compressai\compressai\entropy_models\entropy_models.py", line 118, in init entropy_coder = default_entropy_coder() File "C:\Users\sohtak\Ph.D-Sweden-France\Sweden\Phase2\Python-Codes\The_Final_versions\VAE_05062024_Bestversion\compressai\compressai\entropy_models\entropy_models.py", line 84, in default_entropy_coder from compressai import get_entropy_coder ImportError: cannot import name 'get_entropy_coder' from 'compressai' (unknown location)

YodaEmbedding commented 1 month ago

That says the module compressai is not available in Python's paths.

Try installing CompressAI using the instructions in https://github.com/InterDigitalInc/CompressAI?tab=readme-ov-file#installation. In your case, this means creating a virtual environment, activating the virtual environment, and then pip install -e C:\Users\sohtak\Ph.D-Sweden-France\Sweden\Phase2\Python-Codes\The_Final_versions\VAE_05062024_Bestversion\compressai.

Note that CompressAI is not officially supported on Windows. However, some users have figured out how to get it running by installing the relevant compilers.