uploadcare / pillow-simd

The friendly PIL fork
https://python-pillow.github.io/pillow-perf/
Other
2.12k stars 85 forks source link

OSError: decoder libtiff not available #101

Closed FrancescoSaverioZuppichini closed 2 years ago

FrancescoSaverioZuppichini commented 2 years ago

Dear all,

I have installed pillow-simd by following your guide but as soon as I try to use it in python I got the following error:

OSError: decoder libtiff not available

My system spec:

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:        20.04
Codename:       focal
Python 3.8.10

My code:

import torch
import torchvision.transforms as T
import numpy as np
from torchvision.datasets import ImageFolder
from torch.utils.data import DataLoader
from utils import show_dataset
from pytorch_lightning import seed_everything

seed_everything(0)

ds = ImageFolder(root='../dataset/rvl-cdip/images-384/train/', transform=T.Compose([
    T.Resize((256, 256)),
    T.ToTensor()
])
)

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

The stack trace shows that it breaks when PIL is used to load one image

/DeepCluster/venv/lib/python3.8/site-packages/PIL/Image.py in convert(self, mode, matrix, dither, palette, colors)
    871         """
    872 
--> 873         self.load()
    874 
    875         if not mode and self.mode == "P":

~/DeepCluster/venv/lib/python3.8/site-packages/PIL/TiffImagePlugin.py in load(self)
   1068     def load(self):
   1069         if self.use_load_libtiff:
-> 1070             return self._load_libtiff()
   1071         return super().load()
   1072 

~/DeepCluster/venv/lib/python3.8/site-packages/PIL/TiffImagePlugin.py in _load_libtiff(self)
   1131             args[2] = fp
   1132 
-> 1133         decoder = Image._getdecoder(
   1134             self.mode, "libtiff", tuple(args), self.decoderconfig
   1135         )

~/DeepCluster/venv/lib/python3.8/site-packages/PIL/Image.py in _getdecoder(mode, decoder_name, args, extra)
    410         return decoder(mode, *args + extra)
    411     except AttributeError:
--> 412         raise OSError("decoder %s not available" % decoder_name)
    413 
    414 

OSError: decoder libtiff not available

Thanks,

Francesco

FrancescoSaverioZuppichini commented 2 years ago
pip install pillow-simd --upgrade --force-reinstall --no-cache-dir

fixed the issue