# Feature Extraction pipeline for images

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffeature-extraction-pipeline-for-images%2F49942%3E%5C
**Category:** Beginners\
**Created:** [August 8, 2023, 9:59am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffeature-extraction-pipeline-for-images%2F49942 "2023-08-08T09:59:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MartinKS](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@MartinKS](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FMartinKS)%5C
**Post date:** [August 8, 2023, 9:59am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffeature-extraction-pipeline-for-images%2F49942%2F1 "2023-08-08T09:59:10Z")

</div>

I’ve followed the tutorials as best I can for Feature Extraction of text, and that pipeline seems to work really well. The code is in the multimodal section of the pipeline documentation, but I can’t see what kind of input the model is expecting for an image. The filepath and a PIL image both have given errors, though the PIL version seems to work better than the filepath.  
My current code is below:  
from transformers import pipeline  
import torch  
from PIL import Image

extractor = pipeline(model=“google/vit-base-patch16-224”, task=“feature-extraction”,device=0)  
img = Image.open(“0531d216-4a12-4836-8389-efbbfac21a2b.png”)  
result = extractor(inputs=img, return\_tensors=True)  
print(result.shape)

This gives an error:  
Cell In[18], line 7  
5 extractor = pipeline(model=“google/vit-base-patch16-224”, task=“feature-extraction”,device=0)  
6 img = Image.open(“0531d216-4a12-4836-8389-efbbfac21a2b.png”)  
----\> 7 result = extractor(inputs=img, return\_tensors=True)  
8 result.shape # This is a tensor of shape [1, sequence\_lenth, hidden\_dimension] representing the input string.

File ~/.local/lib/python3.10/site-packages/transformers/pipelines/feature\_extraction.py:107, in FeatureExtractionPipeline. **call** (self, \*args, \*\*kwargs)  
97 def **call** (self, \*args, \*\*kwargs):  
98 “”"  
99 Extract the features of the input(s).  
100  
(…)  
105 A nested list of `float`: The features computed by the model.  
106 “”"  
 → 107 return super(). **call** (\*args, \*\*kwargs)

File ~/.local/lib/python3.10/site-packages/transformers/pipelines/base.py:1122, in Pipeline. **call** (self, inputs, num\_workers, batch\_size, \*args, \*\*kwargs)  
1114 return next(  
1115 iter(  
1116 self.get\_iterator(  
(…)  
1119 )  
1120 )  
1121 else:  
 → 1122 return self.run\_single(inputs, preprocess\_params, forward\_params, postprocess\_params)

File ~/.local/lib/python3.10/site-packages/transformers/pipelines/base.py:1128, in Pipeline.run\_single(self, inputs, preprocess\_params, forward\_params, postprocess\_params)  
1127 def run\_single(self, inputs, preprocess\_params, forward\_params, postprocess\_params):  
 → 1128 model\_inputs = self.preprocess(inputs, \*\*preprocess\_params)  
1129 model\_outputs = self.forward(model\_inputs, \*\*forward\_params)  
1130 outputs = self.postprocess(model\_outputs, \*\*postprocess\_params)

File ~/.local/lib/python3.10/site-packages/transformers/pipelines/feature\_extraction.py:81, in FeatureExtractionPipeline.preprocess(self, inputs, \*\*tokenize\_kwargs)  
79 def preprocess(self, inputs, \*\*tokenize\_kwargs) → Dict[str, GenericTensor]:  
80 return\_tensors = self.framework  
—\> 81 model\_inputs = self.tokenizer(inputs, return\_tensors=return\_tensors, \*\*tokenize\_kwargs)  
82 return model\_inputs

TypeError: ‘NoneType’ object is not callable

I think that’s referring to the tokenizer - which I’ve not currently set, but they all seem to be text tokenizers? what am I doing wrong here?
