![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
MarkJhon
这个作者很懒,什么都没留下…
展开
-
GAN in action: Implement Autoencoder
使用Tensorflow和keras构建自编码器Let's get started!Define some key variables.Define sampling helper function.Define the encoder.Define the decoder.Define the Variational Autoencoder(VAE).Define the loss and run our model.Load Mnist Dataset.Generate new image .Let’原创 2020-12-09 17:01:57 · 162 阅读 · 0 评论 -
代码记录:Spatial pyramid pooling Implementation
import numpy as npimport mathimport tensorflow as tf#inupt_feature maps if of the form: N, C, H, Wdef np_spatial_pyramid_pooling(input_feature_maps, spatial_pyramid, dtype=np.float32): assert input_feature_maps.ndim == 4 assert spatial_pyrami.原创 2020-12-08 15:27:58 · 133 阅读 · 0 评论 -
集于Yolo3的目标检测模型(百度AiStudio)
简介YOLOv3 是由 Joseph Redmon 和 Ali Farhadi 提出的单阶段检测器, 该检测器与达到同样精度的传统目标检测方法相比,推断速度能达到接近两倍.模型结构YOLOv3将输入图像分成S*S个格子,每个格子预测B个bounding box,每个bounding box预测内容包括: Location(x, y, w, h)、Confidence Score和C个类别的概率,因此YOLOv3输出层的channel数为B*(5 + C)。YOLOv3的loss函数也有三部分组成翻译 2020-07-13 17:16:00 · 1581 阅读 · 1 评论 -
Tensorflow如何使用GPU训练(笔记)
Tensorflow和tf.keras 模型可以在单个GPU上透明运行,而无需更改。注意:(1)需要使用tf.config.experimental.list_physical_devices('GPU')确认使用的tensorflow可以使用GPU。(2)在一台机器上运行多个GPU,或者在多台机器上运行,最简单的方法是使用分布策略。确保你的机器已经安装TensorflowGPU版。import tensorflow as tfprint("Num GPUs Available: ",原创 2020-07-12 18:33:03 · 37749 阅读 · 3 评论 -
YoloV3使用k-means聚类产生矛框大小(以VOC数据集为例)
import matplotlib.pyplot as pltimport numpy as npimport os, cv2%matplotlib inlineLABELS = ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable','dog', 'ho.原创 2020-07-12 16:06:01 · 3103 阅读 · 3 评论 -
python环境下opencv学习(1)
检测opencv是否安装"""测试opencv是否安装"""# 导入opencvimport cv2#使用函数cv2。imread()读入图像#图像应该在工作目录中,或者提供全路径image = cv2.imread("logo.png")#使用cv2.cvtColor()转变图像格式# In this case we use cv2.cvtColor() to conve...原创 2020-05-06 09:09:46 · 237 阅读 · 0 评论 -
图片处理:对图片进行马赛克、毛玻璃、图片融合处理
#对图片指定部位进行马赛克处理import cv2import numpy as npimg = cv2.imread('image0.jpg', 1)imgInfo = img.shapeheight = imgInfo[0]width = imgInfo[1]#定义马赛克窗体范围for m in range(100, 300): for n in range(100,...原创 2019-07-25 15:57:42 · 297 阅读 · 0 评论 -
图片处理:完成图片的颜色反转
#完成图像的颜色反转#RGB 255-R = newR#灰度图的颜色反转:0-255 255-当前import cv2import numpy as npimg = cv2.imread('image0.jpg',1)imgInfo = img.shapeheight = imgInfo[0]width = imgInfo[1]#转化为灰度图片gray = cv2.cvtC...原创 2019-07-25 10:14:49 · 3513 阅读 · 0 评论 -
图片处理:完成图片的旋转
#完成图像的旋转import cv2import numpy as npimg = cv2.imread('image0.jpg', 1)imgInfo = img.shapeheight = imgInfo[0]width = imgInfo[1]#定义图像的旋转矩阵,参数1,旋转的中心点,2,旋转的角度,3,缩放的系数matRotate = cv2.getRotationM...原创 2019-07-25 09:34:25 · 392 阅读 · 0 评论 -
图像处理:完成一幅图像的灰度化处理
#完成图像灰度化的处理import cv2import numpy as np#方法1:读入参数调整去灰度图img0 = cv2.imread('image0.jpg', 0)img1 = cv2.imread('image0.jpg', 1)print(img0.shape)print(img1.shape)#图像展示cv2.imshow('src', img0)cv2.w...原创 2019-07-25 09:23:06 · 2175 阅读 · 0 评论 -
图像处理:对图片进行缩放
#实现图片缩放#定义一个2*3的矩阵,[[A1 A2 B1],[A3 A4 B2]]#[[A1 A2],[A3 A4]] [B1 B2]#newX = A1*x+A2*y+B1#newY = A3*x+A4*y+B2# x->0.5*x y->0.5*y#把A1=0.5 A2=0 B1=0 => newX= 0.5*ximport cv2import ...原创 2019-07-24 19:55:22 · 459 阅读 · 0 评论 -
图片处理:图片边缘检测(api调用和源码实现两种方法)
#对图片进行边缘检测,实质:对图片的卷积运算import cv2import numpy as npimport random#实现步骤:1、完成图片灰度处理2、进行高斯滤波,去除噪声干扰3、调用canny完成边缘检测img = cv2.imread('image0.jpg', 1)imgInfo = img.shapeheight = imgInfo[0]width = img...原创 2019-07-25 16:41:23 · 965 阅读 · 0 评论 -
图片处理:对图片进行均衡化处理
#彩色图片直方图import cv2import numpy as np#定义方法,表明直方图的统计def ImageHist(image,type): #定义一个颜色,白色 color = (255, 255, 255) #定义一个windows窗体 windowName = 'Gray' #判断类型 if type == 31: ...原创 2019-07-26 09:58:18 · 1069 阅读 · 0 评论 -
图片处理:对图片进行简单修补、对图片灰度直方图进行绘制
#图片修补import cv2import numpy as npimg = cv2.imread('image0.jpg', 1)#通过代码生成损坏的图片#画一个三像素的直线for i in range(200, 300): img[i, 200] = (255,255,255) img[i, 200+1] = (255, 255, 255) img[i, ...原创 2019-07-26 11:26:49 · 235 阅读 · 0 评论 -
图像处理:彩色直方图和灰度直方图实现源码
#彩色直方图源码实现#本质:统计每个像素灰度出现的概率X:0-255, Y:Pimport cv2import numpy as npimport matplotlib.pyplot as pltimg = cv2.imread('image0.jpg',1)imgInfo = img.shapeheight = imgInfo[0]width = imgInfo[1]cou...原创 2019-07-26 14:30:26 · 383 阅读 · 0 评论 -
图像处理:对图片进行彩色直方图均衡化、图片真亮、磨皮美白处理
#实现彩色直方图均衡化import cv2import numpy as npimport matplotlib.pyplot as pltimg = cv2.imread('image0.jpg', 1)cv2.imshow('sec',img)imgInfo = img.shapeheight = imgInfo[0]width = imgInfo[1]count_b ...原创 2019-07-26 15:13:36 · 463 阅读 · 0 评论 -
图像处理:对图片进行高斯滤波、均值滤波、中值滤波处理
#高斯均值滤波,对原图中的噪声小点进行删除,但是图片会变模糊import cv2import numpy as npimg = cv2.imread('iamge0.jpg', 1)cv2.imshow('src', img)#使用opencvAPI的形式进行调用dst = cv2.GaussianBlur(img, (5,5), 1.5)cv2.imshow('dst', dst...原创 2019-07-26 16:25:15 · 2274 阅读 · 1 评论 -
实现简单卷积神经网络实现MNIST手写数据集的识别(python+tensorflow)
#MarkJhon#2019/10/04#homework#????四层卷积神经网络,前两个卷积层由covonlution-relu-maxpool操作组成#1,加载必要的编程库,开始计算图绘画import matplotlib.pyplot as pltimport numpy as npimport tensorflow as tffrom tensorflow.contrib...原创 2019-10-08 17:32:30 · 998 阅读 · 1 评论 -
图像处理:实现图片的缩放(基于python)
#实现图片缩放#定义一个2*3的矩阵,[[A1 A2 B1],[A3 A4 B2]]#[[A1 A2],[A3 A4]] [B1 B2]#newX = A1*x+A2*y+B1#newY = A3*x+A4*y+B2# x->0.5*x y->0.5*y#把A1=0.5 A2=0 B1=0 => newX= 0.5*ximport cv2import ...原创 2019-07-24 19:35:25 · 2848 阅读 · 0 评论 -
图像处理:实现图片镜像(基于python)
#实现步骤:#1、创建一个画布#2、将一个画像从前到后,从左到右进行绘制#3、绘制中心分割线#引入所需要的包import cv2import numpy as np#img = cv2.imread('image0.jpg',1)cv2.imshow('src', img)imgInfo = img.shapeheight = imgInfo[0]width = imgI...原创 2019-07-24 19:06:21 · 3971 阅读 · 0 评论 -
创建scrapy项目
1. windows+r打开cmd命令行工具,cd Desktop进入到桌面目录2. 输入创建项目命令 scrapy startproject 项目名3. cd 到 项目目录下 cd项目名4. 执行创建爬虫的命令 scrapy genspider 爬虫名 爬虫起始网址 5. 使用pycharm打开项目,查看项目目录结构 6. 启动爬虫,找到pycharm原创 2018-01-22 15:46:18 · 346 阅读 · 0 评论 -
体重计算器函数
# 体重计算器函数def bmi(): # 实现计算器的功能代码 while True: # 声明变量 身高、体重 height = input('请输入您的身高(m):') weight = input('情输入您的体重(kg):') # 如果输入的身高或者体重有一个为0,直接结束循环原创 2018-01-23 12:12:45 · 454 阅读 · 0 评论 -
生成一个列表,存放100个随机整数,找出出现次数最多的数字(可能不止一个)
import randomfrom collections import Counterdef randomNum(): num = random.randint(0,100) return numdef findMost(): num_counters = Counter(num) top_common = num_counters.most_comm原创 2018-01-24 18:18:14 · 2786 阅读 · 0 评论 -
python中__slots__的作用
#-*- coding:utf-8 -*-class People(object): #限制只有定义的属性才能动态添加 #以元组的方式定义能给对象添加的属性,除此之外的属性都不能添加 #对动态添加属性可以做出一些限制 __slots__ = ('name', 'age', 'phone') def __init__(self,): su原创 2018-02-01 18:12:07 · 299 阅读 · 0 评论 -
pythonl类函数和静态函数
#-*- coding:utf-8 -*-#上午继承#类函数 和 静态函数class People(object): total = 0 #类变量 def __init__(self): #调用父类的初始化函数 super(People, self).__init__() #初始化当期类对象的一些属性原创 2018-02-01 19:09:15 · 294 阅读 · 0 评论 -
用python写一个文件工具类
#-*- coding:utf-8 -*-#写入数据的工具类class FileManager(object): #保存文件名称 filename = 'student.txt' #写一个写入数据的接口 @classmethod def write(cls, content, split = '\n'): ''' :par原创 2018-02-01 19:35:26 · 3635 阅读 · 0 评论 -
写一个简单的python格式化时间格式的工具类
#-*- coding:utf-8 -*-#写入格式化时间的工具类,用类执行一个函数,返回一个对象,对象有year/month/day'''2018-2-1\2018.2.1\2018 2 1'''class DateTool(object): #初始化函数 def __init__(self, year, month,day): self.year =原创 2018-02-01 19:51:14 · 517 阅读 · 0 评论 -
类的继承和静态函数、类函数分析
# -*- coding: utf-8 -*-# 类的继承''' 1.子类继承自父类,子类拥有父类的所有属性和函数 2.子类继承自父类,子类可以拥有自己独有的属性和函数,父类不可以使用子类独有的属性和函数 3.子类继承自父类,子类可以重写父类的函数 3.1 完全重写,在子类中重新定义一个和父类函数名称一样的函数,但是这个函数执行的功能和父原创 2018-02-02 12:05:07 · 310 阅读 · 0 评论 -
python中的@property装饰器详解
#-*- coding:utf-8#@property负责装饰一个对象函数,让其生成对应的setter和getter函数,调用的时候可以直接使用对象名.函数名#函数名不加括的形式,这种类似属性的调用方式来执行函数class Man(object): #@property装饰的对象函数就是一个getter函数,一般来获取某些数据,不会向函数中传递参数 对象.函数名 @prope原创 2018-02-02 12:06:34 · 538 阅读 · 0 评论 -
使用python装饰器对对象私有属性的读取和删除
#-*- coding:utf-8 -*-class Women(object): def __init__(self, age): #执行age函数,给_age属性赋值 self.age = age def set_age(self, value): if not isinstance(value, int):原创 2018-02-02 12:09:04 · 404 阅读 · 0 评论 -
python中的内存管理
# -*- coding: utf-8 -*-# python中自动管理内存的# 自动管理内存编程语言 例如:object-c python# 手动管理内存编程语言 例如:c# python中的内存管理采用的'引用计数'的方式, 如果一个对象的引用计数为0,该对象占用的内存会被python解释器清空,对象也会消失,如果一个对象的引用计数超过0,这个对象会一直存放在内存中# Pyt原创 2018-02-02 18:48:45 · 199 阅读 · 0 评论 -
代码练习:图片缩放 (基于python)
#引入opencvimport cv2import tensorflow#参数1代表读入彩色图片img = cv2.imread('img0.jpg', 1)imgInfo = img.shapeprint(imgInfo)#获取图片的长宽高参数height = imgInfo[0]width = imgInfo[1]#这个参数描述颜色组成方式,通道数mode = imgI...原创 2019-07-24 10:58:15 · 620 阅读 · 0 评论 -
图像处理:对图片进行缩放(基于python)
import tensorflow as tfimport numpy as npimport cv2#获取图像的基本img = cv2.imread('image0.jpg', 1)imgInfo = img.shapeheight = imgInfo[0]width =imgInfo[1]dstHeight = int(height/2)dstWidth = int(wid...原创 2019-07-24 11:28:29 · 8584 阅读 · 1 评论 -
代码练习:图片移位
#图片移位import cv2import numpy as npimg = cv2.imread('image0.jpg', 1)cv2.imshow('src', img)#图片信息获取imgInfo = img.shapeheight = imgInfo[0]width = imgInfo[1]#设置平移矩阵mathShift = np.float([1, 0, 10...原创 2019-07-24 13:11:44 · 231 阅读 · 0 评论 -
图像处理:人脸识别预处理
#opencv对图像进行预处理import cv2import numpy as np#xml文件的加载face_xml = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')eye_xml = cv2.CascadeClassifier('haarcascade_exye,xml')img = cv2.imre...原创 2019-07-24 15:07:33 · 3871 阅读 · 0 评论 -
图像处理:基于耶鲁大学Yale_64x64.mat的数据集进行人脸识别
#数据准备import cv2#准备由训练训练数据集和测试数据集#实现cnn数据图标检测#使用检测数据进行检测#模块引入,其中scipy.io是为了引入同文件夹下的数据集import tensorflow as tfimport numpy as np#注意加载此包import scipy.io as sio#打开文件数据,第一个参数传递是文件名称,f是文件句柄f =op...原创 2019-07-24 18:16:09 · 5488 阅读 · 7 评论 -
淘宝商品数据爬取
# coding: utf-8from selenium import webdriverimport time# 1.创建浏览器对象driver = webdriver.Firefox()# 2.打开淘宝首页driver.get('http://www.taobao.com')# 3.找到搜索输入框search_ele = driver.find_element_原创 2018-01-13 09:12:16 · 1117 阅读 · 0 评论