I am getting this error when I am predicting image class using learn.predict(img)
the image file format is png
AttributeError: PngImageFile object has no attribute apply_tfms
Google PngImageFile => http://code.nabla.net/doc/PIL/api/PIL/PngImagePlugin/PIL.PngImagePlugin.PngImageFile.html
Google apply_tfms => https://docs.fast.ai/vision.image.html#Image.apply_tfms
The call is expecting a fastai Image but it seems you're passing in a PIL Image.
It's impossible to tell for sure without actual code, but that seems a likely reason.
Related
I've been trying to run the GluonCV tutorial for action recognition.
I didn't modify anything, but I'm getting an error at the very beginning of the script, when applying the transformation function to the image.
The error is:
AttributeError: 'list' object has no attribute 'shape'
To try and solve it, I wanted to replace the list with a single image, so I tried:
img = transform_fn(img.asnumpy())
plt.imshow(np.transpose(img, (1,2,0)))
plt.show()
but in this case, I get another error:
TypeError: Image data of dtype object cannot be converted to float
Any idea on how to fix it?
Thanks!
It seems I had to update gluoncv to a later version.
A little weird, because I installed it following the instruction on the tutorial page, but it works after the update.
my code can convert only one upper part of my PDF first sheet, when I am tying to convert all pages I can't because I get the error in my code.
import tabula
tabula.convert_into("/Users/gfidarov/Desktop/Python/KH_Profilansicht_13.11.2019-2.pdf", "/Users/gfidarov/Desktop/Python/test.csv", output_format="csv",pages='all')
The error which I get is about the pages function
when I am writing it PyCharm says Expected type 'dict', for 'str' instead
I am using python 3.x version in my PyCharm.
Is there other ways how to choose all pages to convert not only upper side of first page
Do you have a runtime error? PyCharm complain is just a warning one can "safely" ignore. The problem is tabula.convert_into has an incorrect docstring type annotation:
kwargs (dict)
should be e.g.
kwargs (str)
See https://www.python.org/dev/peps/pep-0484/#arbitrary-argument-lists-and-default-argument-values
I am trying to use sklearn nmf on a binary file (.bin) imported via numpy and converted to uint8. I import the file no problem, but it's coming in as a 1D array, and when I try and arrange into a 2D array (which sklearn.NMF requires) it errors. I have imported numpy and sklearn.
Import data:
m1 = np.fromfile('file', dtype='uint8')
Code it errors on (I added the - symbol following advice from the docs, it also errors without the - symbol):
m1.arange(962240400).reshape((31020,-31020))
The error:
AttributeError: 'numpy.ndarray' object has no attribute 'arange'
I have tried looking at the official docs and stack overflow, but nothing seems to be working. If anyone has any ideas as to why my code is wrong that would be great.
Use np.arange(962240400).reshape((31020,-31020)), it is a function of numpy, not a method of the array m1
use arange in place of arrange.there should only one 'r'
As i'm doing card scanning to extract the text from images i want to get exact text from image but i'm getting only accurate image values from card and im trying to applpy adaptive threshold on my card but i'm geeting error like
File "C:/Users/shruthipriyanka/PycharmProjects/Scanning/sample.py", line 11, in <module>
newimage = cv2.resize(oriimage,(583,327))
Type Error: src is not a numpy array, neither a scalar
can anyone explain what i did wrong and suggest some resolution for this.
What most likely is happening is you are passing the resize function a PIL image. You can do something like thispix = numpy.array(pic) to convert the image to a numpy array.
When I run the code from the following link:
https://gist.github.com/fchollet/f35fbc80e066a49d65f1688a7e99f069#file-classifier_from_little_data_script_2-py
I get the following error:
Using TensorFlow backend. Found 2000 images belonging to 2 classes.
/home/nd/anaconda3/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:692:
UserWarning: Possibly corrupt EXIF data. Expecting to read 80000 bytes
but only got 0. Skipping tag 64640 "Skipping tag %s" % (size,
len(data), tag))
I am Using Ubuntu.
Tried Solution : change 'w' to 'wb' in line 70 and 81.
Thnx in advance
This is because some of the images have corrupted exif info. You can just remove the exif info of all your images to remove this warning.
The python package piexif can help you. you can use the following code to remove the exif info of an image:
import piexif
# suppose im_path is a valid image path
piexif.remove(im_path)
You can find more discussion here.
The error seems to imply that you try to use TIFF images (rather than JPEGs) and that the PIL library canĀ“t import these without an error (Possibly corrupt EXIF data).
I suggest you try some test JPEGs to make sure your images can be imported correctly.