I am struggling with an error called 'function' object has no attribute 'fft2'. First of all,
I have imported the following:
import cv2
import matplotlib.pyplot as plt
import numpy as np
from scipy import fft
After executing the following block of code in jupyter notebook:
gainDisplay=1
InImgFFT=fft.fft2(InImg,norm="ortho")
InImgAmplSpec=np.abs(fft.fftshift(InImgFFT))
plt.figure(figsize=(W/DPI+1,H/DPI+1))
plt.imshow(np.clip(InImgAmplSpec*gainDisplay,0,255),cmap = 'rainbow')
plt.suptitle('The amplitude spectrum of the gray scale input image')
plt.show()
I get the error mentioned at the line with fft.fft2() function
Could you please help me to solve this error?
scipy version is 1.5.2
Another mention would be that I have a conda environment where i have installed all the packets, but I hope that won't be a problem.
Related
I am new to object detetctio and trying to run code for simple object detection on google colab, please help me with the solution
import cv2
import numpy as np
import matplotlib.pyplot as plt
import cvlib as cv
from cvlib.object_detection import draw_bbox
from numpy.lib.polynomial import poly
img = cv2.imread("/content/banner.jpg")
img1 = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
plt.figure(figsize=(10,10))
plt.axis("off")
plt.imshow(img1)
plt.show()
box, label,count = cv.detect_common_objects(img)
#output = draw_bbox(img, box,label, count)
but it is giving error as
error: OpenCV(3.4.3) /io/opencv/modules/dnn/src/darknet/darknet_io.cpp:552: error: (-212:Parsing error) Unsupported activation: mish in function 'ReadDarknetFromCfgStream'
Are you running object detection on Yolov4?
If yes, please note that Yolov4 is not supported by Opencv 4.2.0 and 4.3.0.
Try to download the last version in master branch support YoloV4 (according to KyloEntro)
Personally, I have upgraded opencv-python to version 4.5.3.56, and there is no more error!
please update your opencv, more recent versions have a proper mish activation
import cvlib as cv
DONT use 3rd party libs built on top of opencv, since you have no control about versioning, and noone knows about those enough to help you
In the following code I'm getting errors when trying to call librosa.grifflim, telling me the attribute does not exist.
import os
from matplotlib import pyplot as plt
import librosa
import librosa.display
import IPython.display as ipd
import numpy as np
import cv2
S = cv2.imread('spectrograms/CantinaBand60.wav10.jpg')
D = librosa.amplitude_to_db(np.abs(S), ref=np.max)
signal = librosa.griffinlim(D)
sf.write('test.wav', signal, 352000)
I've upgraded librosa, and I still encounter the error. The documentation page for this function no longer seems to exist either. I've also tried import just that module using librosa.griffinlim but it continues to tell me this module doesn't exist. Was this function removed during a recent version? If so, is there another function I can use to apply the griffin lim algorithm?
librosa.griffinlim was introduced in librosa 0.7.0. So you need to have that version or later. You can check this using the following code.
import librosa; print(librosa.__version__)
When attempting to pass my RNN call, I call tf.nn.rnn_cell and I receive the following error:
AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'rnn_cell'
Which is odd, because I'm sure I imported everything correctly:
from __future__ import print_function, division
from tensorflow.contrib import rnn
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
But looking at the docs, things have moved around between tensorflow versions.
what would you all recommend to fix this??
Line, I'm getting the error against:
state_per_layer_list = tf.unstack(init_state, axis=0)
rnn_tuple_state = tuple(
[tf.nn.rnn_cell.LSTMStateTuple(state_per_layer_list[idx][0], state_per_layer_list[idx][1])
for idx in range(num_layers)]
)
Specifically:
tf.nn.rnn_cell
I'm using anaconda 3 to manage all of this so, the dependancies should all be taken care of. I have already tried working around a damn rank/shape error with Tensor shapes which took ages to resolve.
Cheers in advance.
Replace tf.nn.rnn_cell with tf.contrib.rnn
Since version 1.0, rnn implemented as part of the contrib module.
More information can be found here
https://www.tensorflow.org/api_guides/python/contrib.rnn
I am trying to learn how to use basemap in python. I used the following site for learning http://www.datadependence.com/2016/06/creating-map-visualisations-in-python/.
but when I typed the following
import matplotlib.pyplot as plt
import matplotlib.cm
import basemap
fig,ax=plt.subplots(figsize=(10,20))
m=basemap(resolution='c',projection='merc',lat_0=54.5,lon_0=-4.36,llcrnrlon=-6.,llcrnrlat=49.5,urcrnrlon=2.,urcrnrlat=55.2)
m.drawmapboundary(fill_color='#46bcec')
m.fillcontinents(color='#f2f2f2',lake_color='#46bcec')
m.drawcoastlines()
I get an error as TypeError: 'module' object is not callable. Why is the reason for this?
You misunderstood the example code. You have to write:
from mpl_toolkits.basemap import Basemap
m=Basemap(resolution='c',projection='merc',lat_0=54.5,lon_0=-4.36,llcrnrlon=-6.,llcrnrlat=49.5,urcrnrlon=2.,urcrnrlat=55.2)
Basemap have to be start from capital letter. It is very important for Python. Python is case sensitivity language.
import numpy as np
import matplotlib.pyplot as plt
x = [2,3,4,5,7,9,13,15,17]
plt.plot(x)
plt.ylabel('Sunlight')
plt.xlabel('Time')
plt.show()
while executing this in anaconda I got the error
Entry Point Not Found:"The procedure entry point
mkl_aa_fw_get_max_memory could not be located in the dynamic link
library mkl_core.dll"
Can anyone please tell how to resolve the issue