How to use waldboost detector in opencv-3.2 using python - python-3.x

import cv2
import numpy as np
detector=cv2.createWaldBoost()
but this code is showing me error
detector=cv2.createWaldBoost()
AttributeError: module 'cv2' has no attribute 'createWaldBoost'

Related

ImportError: cannot import name 'int_classes' from 'torch._six' (/usr/local/lib/python3.7/dist-packages/torch/_six.py)

I am working on healthcare image dataset for image segmentation. More specific, it is "Spinal Cord Gray Matter Segmentation Using PyTorch". When I am trying to install libraries initially using this code:
!pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.0-cp36-cp36m-linux_x86_64.whl
!pip3 install torchvision
!pip install medicaltorch
!pip3 install numpy==1.14.1
it is showing some errors in between required satisfied like this:
1st screenshot
2nd screenshot
After that I am importing libraries:
from collections import defaultdict
import time
import os
import numpy as np
from tqdm import tqdm
from medicaltorch import datasets as mt_datasets
from medicaltorch import models as mt_models
from medicaltorch import transforms as mt_transforms
from medicaltorch import losses as mt_losses
from medicaltorch import metrics as mt_metrics
from medicaltorch import filters as mt_filters
import torch
from torchvision import transforms
from torch.utils.data import DataLoader
from torch import autograd, optim
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torchvision.utils as vutils
cudnn.benchmark = True
import matplotlib.pyplot as plt
%matplotlib inline
This importing is throwing an error like this:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-8-80b8c583d1fe> in <module>()
20
21
---> 22 from medicaltorch import datasets as mt_datasets
23 from medicaltorch import models as mt_models
24 from medicaltorch import transforms as mt_transforms
/usr/local/lib/python3.7/dist-packages/medicaltorch/datasets.py in <module>()
11 from torch.utils.data import Dataset
12 import torch
---> 13 from torch._six import string_classes, int_classes
14
15 from PIL import Image
ImportError: cannot import name 'int_classes' from 'torch._six' (/usr/local/lib/python3.7/dist-packages/torch/_six.py)
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
can someone help me resolve this?
In pytorch 1.9 int_classes variable in torch._six was removed. facebookresearch/TimeSformer#47
Use this code instead.
from torch._six import string_classes
int_classes = (bool, int)
See source here: https://github.com/visionml/pytracking/issues/272

AttributeError: module 'matplotlib' has no attribute 'scatter'

I'm trying to make cluster of latitude and longitude.
the code gave an error in plt.scatter(data['Lng'],data['Lat']) line
the error is:
AttributeError: module 'matplotlib' has no attribute 'scatter'
code:
import numpy as np
import pandas as pd
import matplotlib as plt
import seaborn as sns
sns.set()
from sklearn.cluster import KMeans
data = pd.read_csv("pk.csv")
data.head()
lat_long = data.drop(['country', 'iso2','admin', 'capital','population',
'population_proper'] , axis = 1)
lat_long.head()
plt.scatter(data['Lng'],data['Lat']) # error here
It should be:
import matplotlib.pyplot as plt
Or it can be:
from matplotlib import pyplot as plt
Also you can read PEP 328 for more information and clearity.

module 'numpy' has no attribute 'max'

I did the above code, I got the error message "module 'numpy' has no attribute 'max'." How should I do?
Python 3.7.2, numpy-1.17.2, macOS 10.14.5, and jupyter notebook
import numpy as np
np.array(range(10))
or
import numpy as np
np.arange(1, 51)

AttributeError: 'SerialBus' object has no attribute 'can'

I am writing a python code to receive the can data via a USB2CAN device. I receive the following error:
AttributeError: 'SerialBus' object has no attribute 'can'
from can.interfaces import serial
import random
import time
import datetime
import matplotlib.pyplot as plt
ser= can.interfaces.serial.serial_can.SerialBus('COM5',115200,timeout=None,rtscts=0)
for i in range(100) :
s= ser.can.interfaces.serial.SerialBus._recv_internal(timeout=None)
print(s)

How to scale a data using Python 3

I am trying to scale my data using Python 3
But I keep getting this error: I am out of ideas as to what could be the issue? Please can you assist me guys? I would deeply appreciate your help!
import pandas as pd
import numpy as np
from numpy.random import randn
from pandas import Series, DataFrame
from pandas.plotting import scatter_matrix
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib import rcParams
from pylab import rcParams
import seaborn as sb
import scipy
from scipy import stats
from scipy.stats import pearsonr
from scipy.stats import spearmanr
from scipy.stats import chi2_contingency
import sklearn
from sklearn import preprocessing
from sklearn.preprocessing import scale
mtcars = pd.read_csv('mtcars.csv')
mtcars.columns = ['Car
names','mpg','cyl','disp','hp','drat','wt','qsec','vs','am','gear','carb']
mpg = mtcars['mpg']
#Scale your data
mpg_matrix = mpg.reshape(-1,1)
scaled = preprocessing.MinMaxScaler()
scaled_mpg = scaled.fit_transform(mpg_matrix)
plt.plot(scaled_mpg)
plt.show()
mpg_matrix = mpg.numpy.reshape(-1,1)
tr__
File "C:\Anaconda\lib\site-packages\pandas\core\generic.py", line 5067, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'numpy'
pandas.core.series.Series doesn't have reshape.
Perhaps:
mpg_matrix = mpg.values.reshape(-1,1)
i.e. get the underlying numpy array and reshape that.

Resources