摘要:
#画线 blue = (0,0,255) cv2.line(image, (300,0), (150,150), blue, 5) show(image) #画矩形 red = (255,0,0) cv2.rectangle(image, (10,10), (60,60), red, 2) show 阅读全文
posted @ 2020-08-30 09:58
yunshangyue
阅读(177)
评论(0)
推荐(0)
摘要:
image = imread('test.jpg') show(image) image.shape # 创建遮挡 mask = np.zeros(image.shape,dtype='uint8') white = (255,255,255) cv2.rectangle(mask, (50,50) 阅读全文
posted @ 2020-08-30 09:56
yunshangyue
阅读(135)
评论(0)
推荐(0)
摘要:
""" Averaging平均 计算卷积框覆盖区域所有像素的平均值得到卷积的结果 [[1 1 1 1 1] [1 1 1 1 1] [1 1 1 1 1] [1 1 1 1 1] [1 1 1 1 1]] """ kernelsizes = [(3,3),(9,9),(15,15)] plt.fig 阅读全文
posted @ 2020-08-30 09:55
yunshangyue
阅读(297)
评论(0)
推荐(0)
摘要:
image = imread('test.jpg') image.shape #切分通道 (R, G, B) = cv2.split(image) #合并通道 merged = cv2.merge([R,G,B]) show(merged) 阅读全文
posted @ 2020-08-30 09:53
yunshangyue
阅读(140)
评论(0)
推荐(0)
摘要:
#如果果再指定complie的时候没有指定metrics这个参数,也就是网络只计算损失,不计算其他的性能指标。 #前提 # sgd:Stochastic gradient descent,随机梯度下降法 # mse:Mean Squared Error,均方误差 #model.compile(opt 阅读全文
posted @ 2020-08-30 09:50
yunshangyue
阅读(301)
评论(0)
推荐(0)
摘要:
import numpy as np import cv2 # 从文件读取视频内容 cap = cv2.VideoCapture('videos/cats.mp4') # 视频每秒传输帧数 fps = cap.get(cv2.CAP_PROP_FPS) # 视频图像的宽度 frame_width = 阅读全文
posted @ 2020-08-30 09:48
yunshangyue
阅读(288)
评论(0)
推荐(0)
摘要:
from keras.processing.image import ImageDataGenerator,array_to_img,img_to_array,load_img import numpy as np datagen =ImageDataGenerator( rotation_rang 阅读全文
posted @ 2020-08-30 09:45
yunshangyue
阅读(189)
评论(0)
推荐(0)
摘要:
# 保存模型,数据和网络全部保存 model.save('model.h5') # HDF5文件,pip install h5py #网络训练好以后就可以按照上面保存了。 # 载入模型 model = load_model('model.h5') # 评估模型,载入后可以直接用于评估 loss,ac 阅读全文
posted @ 2020-08-30 09:42
yunshangyue
阅读(516)
评论(0)
推荐(0)
摘要:
训练的数据输入可以全部载入内存,下面这两种方法 #按照批次进行训练(传入的是一个批次的样本和标签)样本少,将所有的样本作为一个批次 cost = model.train_on_batch(x_data,y_data) #划分批次进行训练(传入的是所有的数据进行分批次训练)样本数量多。 model.f 阅读全文
posted @ 2020-08-30 09:39
yunshangyue
阅读(238)
评论(0)
推荐(0)
摘要:
顺序模型用的多 # Sequential按顺序构成的模型 from keras.models import Sequential # 构建一个顺序模型 model = Sequential() #model中添加层 #方法一 # 构建一个顺序模型 model = Sequential() # 在模型 阅读全文
posted @ 2020-08-30 09:37
yunshangyue
阅读(298)
评论(0)
推荐(0)
摘要:
from keras.applications.vgg16 import VGG16 from keras.models import Sequential from keras.layers import Conv2D,MaxPool2D,Activation,Dropout,Flatten,De 阅读全文
posted @ 2020-08-30 09:33
yunshangyue
阅读(764)
评论(0)
推荐(0)
摘要:
from keras.applications.vgg16 import VGG16 from keras.models import Sequential from keras.layers import Conv2D,MaxPool2D,Activation,Dropout,Flatten,De 阅读全文
posted @ 2020-08-30 09:32
yunshangyue
阅读(689)
评论(0)
推荐(0)
摘要:
from keras.models import Sequential from keras.layers import Conv2D,MaxPool2D,Activation,Dropout,Flatten,Dense from keras.optimizers import Adam from 阅读全文
posted @ 2020-08-30 09:31
yunshangyue
阅读(536)
评论(0)
推荐(0)
摘要:
Haar特征+Adaboost级联分类器 from imutils import * image = imread('face.png') show(image) """ 1 image:输入图像 2 scaleFactor=1.1:这个是每次缩小图像的比例,默认是1.1 3 minNeighbor 阅读全文
posted @ 2020-08-30 09:28
yunshangyue
阅读(223)
评论(0)
推荐(0)
摘要:
import numpy as np import cv2 # 从文件读取视频内容 cap = cv2.VideoCapture('videos/cats.mp4') # 视频每秒传输帧数 fps = cap.get(cv2.CAP_PROP_FPS) # 视频图像的宽度 frame_width = 阅读全文
posted @ 2020-08-30 09:25
yunshangyue
阅读(141)
评论(0)
推荐(0)
摘要:
# 从摄像头获取图像数据 cap = cv2.VideoCapture(0) while(True): # ret 读取成功True或失败False # frame读取到的图像的内容 # 读取一帧数据 ret,frame = cap.read() # 变为灰度图 gray = cv2.cvtColo 阅读全文
posted @ 2020-08-30 09:23
yunshangyue
阅读(178)
评论(0)
推荐(0)
摘要:
from imutils import * image = imread('image/school.jpg') show(image) def edge_detection(image,minVal=100,maxVal=200): image = cv2.cvtColor(image, cv2. 阅读全文
posted @ 2020-08-30 09:22
yunshangyue
阅读(311)
评论(0)
推荐(0)
摘要:
from imutils import * image = imread('image/bricks.png') show(image) def gradient(image): image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) # cv2.CV_64F 阅读全文
posted @ 2020-08-30 09:21
yunshangyue
阅读(140)
评论(0)
推荐(0)
摘要:
from imutils import * #载入图片,并以灰度显示 image = imread('image/coins.jpg') show(image) gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) plt.imshow(gray,'gray' 阅读全文
posted @ 2020-08-30 09:20
yunshangyue
阅读(121)
评论(0)
推荐(0)
摘要:
image = imread('image.jpg') (R, G, B) = cv2.split(image) zeros = np.zeros(image.shape[:2],dtype='uint8') show(cv2.merge([R,zeros,zeros])) show(cv2.mer 阅读全文
posted @ 2020-08-30 09:18
yunshangyue
阅读(203)
评论(0)
推荐(0)
摘要:
#腐蚀:选取kernel区域内的最小值 # 矩形 kernel1 = cv2.getStructuringElement(cv2.MORPH_RECT, (5,5)) print(kernel1) # 椭圆 kernel2 = cv2.getStructuringElement(cv2.MORPH_ 阅读全文
posted @ 2020-08-30 09:15
yunshangyue
阅读(399)
评论(0)
推荐(0)
摘要:
image = imread('image.jpg') show(image) #5个像素的加权平均值 #像素降低 for i in range(4): image = cv2.pyrDown(image) print(image.shape) show(image) #像素提高 for i in 阅读全文
posted @ 2020-08-30 09:13
yunshangyue
阅读(169)
评论(0)
推荐(0)
摘要:
rectangle = np.zeros((300,300,3),dtype='uint8') white = (255,255,255) cv2.rectangle(rectangle, (25,25), (275,275), white, -1) show(rectangle) circle = 阅读全文
posted @ 2020-08-30 09:12
yunshangyue
阅读(159)
评论(0)
推荐(0)
摘要:
# 水平翻转 image = imread("test.jpg") image = cv2.flip(image,1) show(image) # 垂直翻转 image = imread("test.jpg") image = cv2.flip(image,0) show(image) # 水平+垂 阅读全文
posted @ 2020-08-30 09:10
yunshangyue
阅读(220)
评论(0)
推荐(0)
摘要:
image = imread('image.jpg') M = np.float32([[1,0,250],[0,1,500]]) #X轴右移250个像素,Y轴下移500个像素 #前面的0,1 是在选择坐标轴 shifted = cv2.warpAffine(image, M, (image.sha 阅读全文
posted @ 2020-08-30 09:08
yunshangyue
阅读(256)
评论(0)
推荐(0)
摘要:
import cv2 import matplotlib.pyplot as plt image = cv2.imread('image.jpg') plt.imshow(image) plt.axis('off') plt.show() #读入并显示图片 image = cv2.cvtColor( 阅读全文
posted @ 2020-08-30 09:06
yunshangyue
阅读(196)
评论(0)
推荐(0)
摘要:
import matplotlib.pyplot as plt import numpy as np import pandas as pd ''' ax[0,0].plot/bar/pie/hist/barh/ 直接来。两种方法都是 有两种方法: 方法1: fig = plt.figure(fig 阅读全文
posted @ 2020-08-30 09:04
yunshangyue
阅读(454)
评论(0)
推荐(0)
摘要:
plt.figure(facecolor = 'w') #面板分成3类 cm_light = mpl.colors.ListedColormap(['#77E0A0', '#FF8080', '#A0A0FF']) #根据y的不同,填充颜色也不同 plt.pcolormesh(x1, x2, y_h 阅读全文
posted @ 2020-08-30 09:00
yunshangyue
阅读(330)
评论(0)
推荐(0)
摘要:
def color(): most_use={'red':'r', 'green':'g', 'bule':'b', 'black':'k'} cmaps_or_colormaps ={ 'Perceptually_Uniform_Sequential' : [ 'viridis', 'plasma 阅读全文
posted @ 2020-08-30 08:53
yunshangyue
阅读(2151)
评论(0)
推荐(0)
摘要:
# -*- coding: utf-8 -*- import time import matplotlib.pyplot as plt import matplotlib import numpy as np import pandas as pd from pylab import mpl mpl 阅读全文
posted @ 2020-08-30 08:51
yunshangyue
阅读(2141)
评论(0)
推荐(0)
摘要:
阅读全文
posted @ 2020-08-30 08:49
yunshangyue
阅读(298)
评论(0)
推荐(0)
摘要:
# 分组 df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar','foo', 'bar', 'foo', 'foo'], 'B' : ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'thre 阅读全文
posted @ 2020-08-30 08:46
yunshangyue
阅读(337)
评论(0)
推荐(0)
摘要:
import matplotlib.pyplot as plt import numpy as np def graph_basic_args(): args_name = { 'linestyle' : ['-','-.','--',':'],#直线,点化线,虚线,点(包含全了) 'linewid 阅读全文
posted @ 2020-08-30 08:45
yunshangyue
阅读(316)
评论(0)
推荐(0)
摘要:
# 图表窗口1 → plt.show() plt.plot(np.random.rand(10)) plt.show() # 直接生成图表 # 图表窗口2 → 魔法函数,嵌入图表,好像是jupyter notebook才可以 % matplotlib inline x = np.random.ran 阅读全文
posted @ 2020-08-30 08:43
yunshangyue
阅读(355)
评论(0)
推荐(0)
摘要:
阅读全文
posted @ 2020-08-30 08:42
yunshangyue
阅读(103)
评论(0)
推荐(0)
摘要:
# 替换 .replace 一个替换就用逗号就行了,多个就用字典 s = pd.Series(list('ascaazsd')) print(s.replace('a', np.nan)) print(s.replace(['a','s'] ,np.nan)) print(s.replace({'a 阅读全文
posted @ 2020-08-30 08:41
yunshangyue
阅读(195)
评论(0)
推荐(0)
摘要:
# 去重 .duplicated s = pd.Series([1,1,1,1,2,2,2,3,4,5,5,5,5]) print(s.duplicated()) print(s[s.duplicated() == False]) print(' ') # 判断是否重复 # 通过布尔判断,得到不重复 阅读全文
posted @ 2020-08-30 08:40
yunshangyue
阅读(874)
评论(0)
推荐(0)
摘要:
import pandas as pd df1 = pd.DataFrame({'key': ['K0', 'K1', 'K2', 'K3'], 'A': ['A0', 'A1', 'A2', 'A3'], 'B': ['B0', 'B1', 'B2', 'B3']}) df2 = pd.DataF 阅读全文
posted @ 2020-08-30 08:39
yunshangyue
阅读(458)
评论(0)
推荐(0)
摘要:
拼接 # 连接:concat s1 = pd.Series([1,2,3]) s2 = pd.Series([2,3,4]) print(pd.concat([s1,s2])) print(' ') # 默认axis=0,行+行 s3 = pd.Series([1,2,3],index = ['a' 阅读全文
posted @ 2020-08-30 08:37
yunshangyue
阅读(306)
评论(0)
推荐(0)
摘要:
# 读取普通分隔数据:read_table # 可以读取txt,csv import os os.chdir('C:/Users/iHJX_Alienware/Desktop/') data1 = pd.read_table('data1.txt', delimiter=',',header = 0 阅读全文
posted @ 2020-08-30 08:34
yunshangyue
阅读(303)
评论(0)
推荐(0)
摘要:
s = pd.Series(['A','b','C','bbhello','123',np.nan,'hj']) df = pd.DataFrame({'key1':list('abcdef'), 'key2':['hee','fv','w','hija','123',np.nan]}) print 阅读全文
posted @ 2020-08-30 08:31
yunshangyue
阅读(682)
评论(0)
推荐(0)
摘要:
import pandas as pd import numpy as np np.random.seed(7) df1 = pd.DataFrame(np.arange(20).reshape(5, 4), columns=['A', 'B', 'C', 'D']) df2 = pd.DataFr 阅读全文
posted @ 2020-08-30 08:26
yunshangyue
阅读(109)
评论(0)
推荐(0)
摘要:
# 成员资格:.isin() s = pd.Series(np.arange(10,15)) df = pd.DataFrame({'key1':list('asdcbvasd'), 'key2':np.arange(4,13)}) print(s) print(df) print(' ') pri 阅读全文
posted @ 2020-08-30 08:23
yunshangyue
阅读(119)
评论(0)
推荐(0)
摘要:
# 唯一值:.unique() s = pd.Series(list('asdvasdcfgg')) sq = s.unique() print(s) print(sq,type(sq)) print(pd.Series(sq)) # 得到一个唯一值数组 # 通过pd.Series重新变成新的Ser 阅读全文
posted @ 2020-08-30 08:22
yunshangyue
阅读(167)
评论(0)
推荐(0)
摘要:
# 值计数:.value_counts() sc = s.value_counts(sort = False) # 也可以这样写:pd.value_counts(sc, sort = False) print(sc) # 得到一个新的Series,计算出不同值出现的频率 # sort参数:排序,默认 阅读全文
posted @ 2020-08-30 08:21
yunshangyue
阅读(108)
评论(0)
推荐(0)
摘要:
# 数据分布的图表可视化 - 直方图 r = np.random.RandomState(1) ar = r.randn(1000) * 100 # 创建一个正态分布数组 # 计算分位数 df = pd.DataFrame(ar,columns = ['value']) q25 = df['valu 阅读全文
posted @ 2020-08-30 08:20
yunshangyue
阅读(143)
评论(0)
推荐(0)
摘要:
# 排序1 - 按值排序 .sort_values # 同样适用于Series df1 = pd.DataFrame(np.random.rand(16).reshape(4,4)*100, columns = ['a','b','c','d']) print(df1) print(df1.sort 阅读全文
posted @ 2020-08-30 08:19
yunshangyue
阅读(147)
评论(0)
推荐(0)
摘要:
缺失值处理import numpy as np import pandas as pd data = np.array([1,2,5,4,np.nan]) print(data) print('numpy 有专门的nansum,nanmax等操作处理缺失值') # r = data.sum() r 阅读全文
posted @ 2020-08-30 08:18
yunshangyue
阅读(124)
评论(0)
推荐(0)
摘要:
#查看 print(df.head(2)) print(df.tail()) # .head()查看头部数据 # .tail()查看尾部数据 # 默认查看5条 print(df.T)# .T 转置 # 新增列/行并赋值 df['e'] = 10 df.loc[4] = 20 print(df) # 阅读全文
posted @ 2020-08-30 08:14
yunshangyue
阅读(102)
评论(0)
推荐(0)
摘要:
Series Series import numpy as np import pandas as pd s = pd.Series([1,2,3,4],index=list('abcd')) #获取 data = s['b']#显式索引 print(data) data = s[1]#隐式索引 p 阅读全文
posted @ 2020-08-30 08:05
yunshangyue
阅读(255)
评论(0)
推荐(0)
摘要:
import numpy as np import pandas as pd #创建方法一:多个series组成字典创建dataframe pp = {'bj':3000,'gz':2800,'sh':3200} area={'bj':290,'gz':310,'sh':150} pp_series 阅读全文
posted @ 2020-08-30 08:01
yunshangyue
阅读(323)
评论(0)
推荐(0)
摘要:
创建 import numpy as np import pandas as pd #创建方法一、一维数组或者列表创建 a = [1,2,3,4] #1.1不指定index data = pd.Series(a) print(data) #1.2指定index data = pd.Series(a, 阅读全文
posted @ 2020-08-30 07:59
yunshangyue
阅读(359)
评论(0)
推荐(0)
摘要:
np.linalg.det(d) # 计算行列式结果 np.dot(a2,b2)#点乘 np.linalg.inv()#逆矩阵 np.linalg.det(A)#伴随矩阵 np.linalg.matrix_rank(b)#矩阵的秩 #特征值和特征向量 print(np.linalg.eigvals( 阅读全文
posted @ 2020-08-30 07:56
yunshangyue
阅读(350)
评论(0)
推荐(0)
摘要:
# 直线运动问题 # 对于f(X) = x**2 def f(x): return x**2 plt.figure(figsize = (12,6)) n = np.linspace(-10,10,num = 50) plt.plot(n,f(n)) plt.xlim(-11,11) plt.yli 阅读全文
posted @ 2020-08-30 07:50
yunshangyue
阅读(2600)
评论(0)
推荐(0)
摘要:
#拼接import numpy as np a = np.arange(1,25).reshape(2,3,4) b = np.arange(101,125).reshape(2,3,4) print('axis = 0') c = np.concatenate((a,b), axis = 0) p 阅读全文
posted @ 2020-08-30 07:49
yunshangyue
阅读(1523)
评论(0)
推荐(0)
摘要:
# 随机数生成 #标准正态分布 samples = np.random.normal(size=(4,4)) print(samples) # 生成一个标准正太分布的4*4样本值 #均值分布 # numpy.random.rand(d0, d1, ..., dn):生成一个[0,1)之间的随机浮点数 阅读全文
posted @ 2020-08-30 07:44
yunshangyue
阅读(340)
评论(0)
推荐(0)

浙公网安备 33010602011771号