I am using opencv3.1.0.
While I am trying to run:
import cv2.cv as cv
import cv2
cascade = cv.Load('/usr/share/OpenCV/haarcascades/haarcascade_frontalface_alt2.xml')
I find that cv2.cv is not in opencv3, so I change cv2.cv to cv2
and then I get the error message in the title.
Any thoughts?
Many thanks.
You are trying to load a classifier from a file, correct?
According to the OpenCV3 documentation you should use CascadeClassifier for this.
Example:
import cv2
cascade = cv2.CascadeClassifier('/usr/share/OpenCV/haarcascades/haarcascade_frontalface_alt2.xml')
Source: http://docs.opencv.org/3.0-beta/modules/objdetect/doc/cascade_classification.html
Related
import skimage
image = skimage.data.imread("my_image.png")
I used this code to read an image, but I got an error as "skimage.data" has no attribute "imread".
My skimage version is 0.18.1. What has to be changed in this to read an image?
The error is straightforward. You try to call the imread function in the data module, but there is no such function in this module. Call
skimage.io.imread('blah.png')
instead.
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
This is the error I can't figure out.
module 'keras.backend' has no attribute 'unique_object_name'
This is what I'm importing:
import cv2
import os
from keras.models import load_model
import numpy as np
from pygame import mixer
import time
I get the error when I try and run this line:
model = load_model('C:/Users/Henry/Downloads/Drowsiness detection/Drowsiness detection/models/cnnCat2.h5')
Method keras.models.load_model() probably worked properly before Keras become part of Tensorflow.
If you are using newer version of tf you should call this to load model:
tf.keras.models.load_model()
I keep getting an error when i run this code:
from sklearn import preprocessing
lencoder = preprocessing.LabelEncoder()
voc_processor = tf.contrib.learn.preprocessing.VocabularyProcessor(kw_list)
voc_processor.fit(vocabulary)
X_transform = voc_processor.transform(reviews_df.reviewText)
X_transform = np.array(list(X_transform))
This is the error I get:
AttributeError: module 'tensorflow' has no attribute 'contrib'
Is there another approach to run this without having use an old version of tensorflow. I understand I am getting this error because tf.contrib. has been deprecated.
You can take a look at how new examples are dealing with text preprocessing, as an example
import tensorflow as tf
import tensorflow_transform as tft
[...]
review_tokens = tf.compat.v1.string_split(review, DELIMITERS)
review_indices = tft.compute_and_apply_vocabulary(
review_tokens, top_k=VOCAB_SIZE)
from
https://github.com/tensorflow/transform/blob/master/examples/sentiment_example.py
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