import matplotlib.pyplot as plt
import cv2
from scipy.misc import toimage
im = toimage(skeleton)
cv2.imwrite('./zee/img'+(str(count)+".png"),im)
but we get
ImportError: cannot import name 'toimage'
Related
Imports & Settings
%matplotlib inline
from pathlib import Path
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
import seaborn as sns
import tensorflow as tf
from tensorflow.keras.applications.densenet import DenseNet201
from tensorflow.keras.layers import Dense, BatchNormalization
from tensorflow.keras.models import Sequential
from tensorflow.keras.callbacks import ModelCheckpoint, EarlyStopping
from tensorflow.keras.regularizers import l1_l2
from tensorflow.keras.optimizers import Adam
import tensorflow_datasets as tfds
Load EuroSat Dataset
(raw_train, raw_validation), metadata = tfds.load('eurosat',
split=['train[:90%]','train[90%:]'],
with_info=True,
shuffle_files=False,
as_supervised=True,
data_dir='../data/tensorflow')
i got error message
how can i fix it?
i use tensorflow2
I guess there's a problem with the codec.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import check_util.checker as checker
from IPython.display import clear_output
from PIL import Image
import os
import time
import re
from glob import glob
import shutil
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from tensorflow import keras
print('tensorflow version: {}'.format(tf.__version__))
print('GPU available: {}'.format(tf.test.is_gpu_available()))
When I run this, there is no error. But it shows as indefinitely in progress.
(Current 630..631..632...sec)
The code below sends an error "RuntimeError: NetCDF: HDF error". If I remove the import h5py, I get no error. Are there any suggestions on why this might be happening and how I can fix it? My ultimate aim is to load a hdf5 and write out to netCDF.
import numpy as np
import pandas as pd
import h5py
import xarray as xr
ds = xr.Dataset(
{"foo": (("x", "y"), np.random.rand(4, 5))},
coords={
"x": [10, 20, 30, 40],
"y": pd.date_range("2000-01-01", periods=5),
"z": ("x", list("abcd")),
},
)
ds.to_netcdf("saved_on_disk.nc")
import numpy as np
import pandas as pd
import xarray as xr
Works.
import numpy as np
import pandas as pd
import h5py
import xarray as xr
Doesn't Work
import numpy as np
import pandas as pd
import xarray as xr
import h5py
Doesn't Work
import numpy as np
import pandas as pd
from netCDF4 import Dataset
import xarray as xr
import h5py
Works!
The key was also loading the netCDF4 package.
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.
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.