GluonCV, action recognition tutorial error - python-3.x

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.

Related

AttributeError: module 'torch.utils' has no attribute 'make_grid'

I tried following along with the PyTorch transfer learning tutorial and found it pulled an error code when I brought up the make grid.
It's because it's out of date. As of 1.11.0 it has been moved to torchvision.utils.make_grid instead of torch.utils.make_grid
https://pytorch.org/vision/main/generated/torchvision.utils.make_grid.html?highlight=make_grid#torchvision.utils.make_grid

AttributeError: 'PngImageFile' object has no attribute 'apply_tfms'

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.

AttributeError: module 'folium' has no attribute 'Map'

I tried every possible solution on this website and others like making sure there is no other file named folium.py on my device, reinstalled everything 2 times and I am still getting this error when trying to create a map with m = folium.Map() function. Please help me

AssertionError when using self-defined nested list in Pyspc

I installed pyspc and run on Jupyter Notebook successfully when using original samples.
But when I tried introducing a self defined nested list and an error message showed up.
pyspc library: https://github.com/carlosqsilva/pyspc
from pyspc import*
import numpy
abc=[[2,3,4],[4,5.6],[1,4,5],[3,4,4],[4,5,6]]
a=spc(abc)+xbar_rbar()+rules()+rbar()
print(a)
error message for AssertionError
Thank you for advise where went wrong and how to fix it.
Check the data you have accidentally used the . instead of , for value [4,5.6], second element of the list.
Here is the corrected data
abc=[[2,3,4],[4,5,6],[1,4,5],[3,4,4],[4,5,6]]
Hope this will help.

TypeError: __init__() got an unexpected keyword argument 'shape'

I am new to Tensorflow and I met an error while trying to run some sample codes.
import tensorflow as tf
g1 = tf.Graph()
with g1.as_default():
v = tf.get_variable("v", initializer=tf.zeros_initializer(shape=[1]))
Running the code above gives the error:
TypeError: __init__() got an unexpected keyword argument 'shape'.
The comment below says that tf.zeros_initializer does not accept 'shape' argument according to the documentation. I tried
v = tf.get_variable("v", initializer=tf.zeros_initializer())
and it says ValueError: Shape of a new variable (v) must be fully defined, but instead was .
So, what kind of argument/expression should I use to define the shape without causing a type error?
I cannot find how to solve it online. Please help. Thank you
It appears that the book I'm using is a bit out of date. The following code appears to work so far.
v = tf.get_variable("v", shape=[1], initializer=tf.zeros_initializer)
I will check if it actually works with more code added later.
In version 2.4.1 I use tf.constant() instead

Resources