
python
文章平均质量分 78
wuguangbin1230
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Visual Studio Code——python程序软件配置
1. 选择虚拟环境ctrl+shift+p-----> >Python: Select Interpreter2. 设置Configuration在Run--->Add Configuration 添加configuration,内容为:{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attribute转载 2022-02-07 10:09:05 · 1847 阅读 · 0 评论 -
cv2.findContours()轮廓检测
轮廓检测函数cv2.findContours()cv2.findContours(image, mode, method[, contours[, hierarchy[, offset ]]]) 函数参数: image:参数是寻找轮廓的图像; mode:参数表示轮廓的检索模式,有四种(本文介绍的都是新的cv2接口): cv2.RETR_EXTERNAL:表示只检测外轮廓 cv2.RETR_LIST:检测的轮廓不建立等级关系 cv2...转载 2022-01-21 13:45:52 · 16093 阅读 · 0 评论 -
Pycharm快捷键
1、编辑(Editing)Ctrl + Space 基本的代码完成(类、方法、属性)Ctrl + Alt + Space 快速导入任意类Ctrl + Shift + Enter 语句完成Ctrl + P 参数信息(在方法中调用参数)Ctrl + Q 快速查看文档F1 Web帮助文档主页Shift + F1 选中对象的Web帮助文档Ctrl + 悬浮/单击鼠标左键 简介/进入代码定义Ctrl + Z 撤销上次操作Ctrl + Shift + Z 重做,恢复上次的撤销Ctrl + F1 显转载 2021-08-09 11:25:18 · 288 阅读 · 0 评论 -
python matplotlib绘图技巧(1)-plt.legend()
import tensorflow as tffrom matplotlib import pyplot as pltimport numpy as np train_x = np.linspace(-1, 1, 100)train_y_1 = 2*train_x + np.random.rand(*train_x.shape)*0.3train_y_2 = train_x**2+np.random.randn(*train_x.shape)*0.3 plt.scatter(train..转载 2020-09-08 11:00:54 · 1659 阅读 · 0 评论 -
pycharm代码自动补全功能
pycharm具有代码自动补全的功能。无意中将其功能关闭,百度了好久才解决掉,所以把这次失误记录下来。那么我们怎么打开呢?在软件的左上角找到File-》Power Save Mode,将对勾去掉就可以了。...转载 2020-03-13 09:08:55 · 2498 阅读 · 0 评论 -
使用__future__
Python的每个新版本都会增加一些新的功能,或者对原来的功能作一些改动。有些改动是不兼容旧版本的,也就是在当前版本运行正常的代码,到下一个版本运行就可能不正常了。从Python 2.7到Python 3.x就有不兼容的一些改动,比如2.x里的字符串用'xxx'表示str,Unicode字符串用u'xxx'表示unicode,而在3.x中,所有字符串都被视为unicode,因此,写u'xxx'和'...转载 2018-04-04 09:44:35 · 158 阅读 · 0 评论 -
python class property (类,属性) 示例
出自:/tensorflow_object_detection_api/models_installed/research/slim/deployment/model_deploy.pyclass DeploymentConfig(object): """Configuration for deploying a model with `deploy()`. You can pass a...原创 2018-04-05 12:58:03 · 1514 阅读 · 0 评论 -
Python中的try...except...finally
try, except, finally是Python中的异常捕捉机制,通常的用法就是try..except...结合起来用,程序捕捉try语句块中的异常,如果发现异常就把异常交给except中的语句块进行处理,也就是执行except中的语句,这里except也可以结合if...else一起使用。当然,try...except也可以结合finally使用。则将finally放在最后,finally...转载 2018-04-19 09:47:51 · 1669 阅读 · 0 评论 -
python collections
1.collections中namedtuple()的理解Python中存储系列数据,比较常见的数据类型有list,除此之外,还有tuple数据类型。相比与list,tuple中的元素不可修改,在映射中可以当键使用。tuple元组的item只能通过index访问,collections模块的namedtuple子类不仅可以使用item的index访问item,还可以通过item的name进行访问。...转载 2018-04-19 10:55:50 · 428 阅读 · 0 评论 -
高级形态学处理
形态学处理,除了最基本的膨胀、腐蚀、开/闭运算、黑/白帽处理外,还有一些更高级的运用,如凸包,连通区域标记,删除小块区域等。1、凸包凸包是指一个凸多边形,这个凸多边形将图片中所有的白色像素点都包含在内。函数为:skimage.morphology.convex_hull_image(image)输入为二值图像,输出一个逻辑二值图像。在凸包内的点为True, 否则为False例:import mat...转载 2018-04-25 18:16:40 · 1184 阅读 · 0 评论 -
Python filter() 函数
Python 内置函数描述filter() 函数用于过滤序列,过滤掉不符合条件的元素,返回由符合条件元素组成的新列表。该接收两个参数,第一个为函数,第二个为序列,序列的每个元素作为参数传递给函数进行判,然后返回 True 或 False,最后将返回 True 的元素放到新列表中。语法以下是 filter() 方法的语法:filter(function, iterable)参数function -...转载 2018-04-11 13:20:12 · 182 阅读 · 0 评论 -
Python enumerate() 函数
描述enumerate() 函数用于将一个可遍历的数据对象(如列表、元组或字符串)组合为一个索引序列,同时列出数据和数据下标,一般用在 for 循环当中。Python 2.3. 以上版本可用,2.6 添加 start 参数。语法以下是 enumerate() 方法的语法:enumerate(sequence, [start=0])参数sequence -- 一个序列、迭代器或其他支持迭代对象。st...转载 2018-04-01 23:04:31 · 221 阅读 · 0 评论 -
python zip函数
zip函数接受任意多个(包括0个和1个)序列作为参数,返回一个tuple列表。(在海豚实习时自己写了一个要用到zip的函数,那个例子非常代表性)示例1for i,j in zip(range(3),range(5)): print(zip(range(3),range(5))) print(i) print(j)xbwang@xbwang-desktop:~/Desk...转载 2018-04-01 22:50:22 · 668 阅读 · 0 评论 -
python collections中namedtuple()
python模块collections中namedtuple()的理解 原创 2016年09月28日 17:32:30 标签:collections /namedtuple ...转载 2018-04-01 22:36:45 · 269 阅读 · 0 评论 -
Python set (2)
python的set和其他语言类似, 是一个无序不重复元素集, 基本功能包括关系测试和消除重复元素. 集合对象还支持union(联合), intersection(交), difference(差)和sysmmetric difference(对称差集)等数学运算.s={1,2,"a"} type(s)setx=set("python")x{'h', 'n', 'o', 'p', '...转载 2018-04-01 11:28:41 · 324 阅读 · 0 评论 -
generate_grid_anchor for ssd
画图像的anchor框,设定图像的大小(size)为1*1, 在分割19*19个框.然后在求出每个边框的最大和最小角点(corner_point)坐标.程序为: from object_detection.utils import opsimport tensorflow as tfaspect_ratios = (1,2,0.5)scales = (0.1, 0.20000000298...原创 2018-04-08 18:47:33 · 534 阅读 · 0 评论 -
python 环境变量设置PYTHONPATH
PYTHONPATH是Python搜索路径,默认我们import的模块都会从PYTHONPATH里面寻找。打印PYTHONPATH:import osprint sys.path>['', '/usr/local/lib/python2.7/dist-packages/dlib-19.4.0-py2.7-linux-x86_64.egg', '/home/ershisui',...]注意:s...转载 2018-03-19 20:38:47 · 63414 阅读 · 2 评论 -
Python图像处理库PIL的ImageDraw模块介绍
ImageDraw模块提供了图像对象的简单2D绘制。用户可以使用这个模块创建新的图像,注释或润饰已存在图像,为web应用实时产生各种图形。PIL中一个更高级绘图库见The aggdraw Module。一、ImageDraw模块的概念1、 Coordinates绘图接口使用和PIL一样的坐标系统,即(0,0)为左上角。2、 Colours为了指定颜色,用户可以使用数字或者元组,对应用户使用函数...转载 2018-05-17 11:33:18 · 42149 阅读 · 1 评论 -
draw_bounding_box
import collectionsimport functools# Set headless-friendly backend.import matplotlib; matplotlib.use('Agg') # pylint: disable=multiple-statementsimport matplotlib.pyplot as plt # pylint: disable=...转载 2018-05-15 11:56:03 · 1069 阅读 · 0 评论 -
原 linux下使用python脚本查看CUDA和CUDNN版本
先说说用shell命令查看CUDA和CUDNN版本的方法:查看CUDA版本的命令如下:cat /usr/local/cuda/version.txt查看CUDNN版本:cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2其实CUDA和CUDNN的版本信息写在对应的文件里,如果用上述命令找不到版本信息,那么就用...转载 2019-09-21 21:51:24 · 1355 阅读 · 0 评论 -
cos_window(python)
1.crop_sz=107cos_window = torch.Tensor(np.outer(np.hanning(crop_sz), np.hanning(crop_sz))).cuda()import matplotlib.pyplot as pltfrom matplotlib import cmfrom mpl_toolkits.mplot3d import Axes3D...原创 2019-04-13 10:24:24 · 613 阅读 · 0 评论 -
python 圆形分布
import matha = [月中角度]b = [每月例数]n =总例数i=0fsin_all = 0fcos_all = 0for aa,bb in zip(a,b): bb = bb i+=1 value = math.sin(aa/180.0*math.pi)*bb fcos = math.cos(aa/180.0*math.pi)*bb...原创 2019-02-10 22:19:36 · 1207 阅读 · 0 评论 -
python 张量运算(1)-----拼接、叠加(stack,vstack,hstack,dstack,concatenate)
np.stack首先stack函数用于堆叠数组,其调用方式如下所示:np.stack(arrays,axis=0)其中arrays即需要进行堆叠的数组,axis是堆叠时使用的轴,比如:arrays = [[1,2,3,4], [5,6,7,8]]这是一个二维数组,axis=0表示的是第一维,也即是arrays[0] = [1,2,3,4]或者arrays[1] = [5,6,7,...转载 2019-01-21 07:38:19 · 7945 阅读 · 0 评论 -
matplotlib命令与格式:标题(title),标注(annotate),文字说明(text)
1.title设置图像标题(1)title常用参数fontsize设置字体大小,默认12,可选参数 ['xx-small', 'x-small', 'small', 'medium', 'large','x-large', 'xx-large']fontweight设置字体粗细,可选参数 ['light', 'normal', 'medium', 'semibold', 'bold', '...转载 2018-10-19 09:38:19 · 6456 阅读 · 0 评论 -
python3与Python2.7 转换中问题(1)
1. 字符串与字符之间的转换(2.7---->3.6)#!/usr/bin/env python2.7# -*- coding: utf-8 -*-import numpy as npimport osa =b'IMG_20180724_210759.jpg'c=np.str(b'IMG_20180724_210759.jpg')g =str(a,encoding='...原创 2018-10-16 07:42:50 · 1269 阅读 · 0 评论 -
python list元素的unique方法
1.例子如下import numpy as npwg = []a = [1]b= [2]c = [2,4,5]d = [3,2,5,6]e = [1,4,7,9,4]f = [1]wg.append(a)wg.append(b)wg.append(c)wg.append(d)wg.append(e)wg.append(f)wgb = [list(set(i)...原创 2018-10-18 14:48:47 · 20935 阅读 · 1 评论 -
windows 下安装anaconda,并配opencv环境
1. 下载anaconda,(pythonban'版本为3.6.5),并安装。注:安装时选择all usrs(base) C:\Users\Administrator>pythonPython 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32T...原创 2018-09-03 12:01:23 · 2213 阅读 · 0 评论 -
计算Python Numpy向量之间的欧氏距离
计算Python Numpy向量之间的欧氏距离,已知vec1和vec2是两个Numpy向量,欧氏距离计算如下: import numpy dist = numpy.sqrt(numpy.sum(numpy.square(vec1 - vec2))) 或者直接:dist = numpy.linalg.norm(vec1 - vec2) ...转载 2018-08-15 10:02:58 · 5291 阅读 · 0 评论 -
python 从外部引入变量并运行该程序
1. python程序部分import argparseFLAGS = tf.app.flags.FLAGSoffice31_flags.train()parser = argparse.ArgumentParser()parser.add_argument('--unlabeled_data_path', type=str, default=None)parser.add_argum...原创 2018-06-30 19:07:47 · 3096 阅读 · 0 评论 -
draw rectangle with CV2
import osimport cv2import numpy as npimport globimport randomimage_path = '/wgb_tensorflow/tfapi_vrep_detection531/11/1515530110_ang-55.png'neg_path = '/wgb_tensorflow/tfapi_vrep_detection531/1...原创 2018-05-31 17:23:43 · 603 阅读 · 0 评论 -
python(cv2) 求倾斜矩形(多边形)交集的面积(比)Jaccard
1.import cv2import numpy as npimage = cv2.imread('。。/Downloads/timg.jpeg')original_grasp_bboxes = np.array([[[361, 260.582 ], [301 ,315], [320 ,336],[380, 281.582]]], dtype = np.int32)predictio...原创 2018-06-07 15:06:27 · 6016 阅读 · 0 评论 -
python opencv多边形掩膜(Mask)
# coding=utf-8import numpy as npimport cv2image = cv2.imread("d:/bgs.jpg")b = np.array([[[100,100], [250,100], [300,220],[100,230]]], dtype = np.int32)im = np.zeros(image.shape[:2], dtype ...转载 2018-06-07 11:01:19 · 13309 阅读 · 6 评论 -
python os 文件文件夹操作
python 移动文件或文件夹操作。python中对文件、文件夹操作时经常用到的os模块和shutil模块常用方法。1.得到当前工作目录,即当前Python脚本工作的目录路径: os.getcwd()2.返回指定目录下的所有文件和目录名:os.listdir()3.函数用来删除一个文件:os.remove()4.删除多个目录:os.removedirs(r“c:\py...转载 2018-06-13 10:57:02 · 4823 阅读 · 0 评论 -
Python 集合set()添加删除、交集、并集、集合操作详解
在Python set是基本数据类型的一种集合类型,它有可变集合(set())和不可变集合(frozenset)两种。创建集合set、集合set添加、集合删除、交集、并集、差集的操作都是非常实用的方法。创建集合setpython set类是在python的sets模块中,大家现在使用的python2.7.x中,不需要导入sets模块可以直接创建集合。>>>set('boy')se...转载 2018-03-12 14:39:08 · 2991 阅读 · 1 评论 -
np.tile 和np.newaxis
outputarray([[ 0.24747071, -0.43886742], [-0.03916734, -0.70580089], [ 0.00462337, -0.51431584], ..., [ 0.15071507, -0.57029653], [ 0.06246116, -0.33766761],原创 2017-08-29 15:37:36 · 1395 阅读 · 0 评论 -
[scope.strip() for scope in flags.split(',')]
1. flags = 'ssd_300_vgg/conv6,ssd_300_vgg/conv7,ssd_300_vgg/block8,ssd_300_vgg/block9,ssd_300_vgg/block10,ssd_300_vgg/block11,ssd_300_vgg/block4_box,ssd_300_vgg/block7_box,ssd_300_vgg/block8_b原创 2017-06-07 16:58:04 · 1126 阅读 · 0 评论 -
python numpy使用
python numpy使用1.建立矩阵a1=np.array([1,2,3],dtype=int) #建立一个一维数组,数据类型是int。也可以不指定数据类型,使用默认。几乎所有的数组建立函数都可以指定数据类型,即dtype的取值。a2=np.array([[1,2,3],[2,3,4]]) #建立一个二维数组。此处和MATLAB的二维数组(矩阵)的建立有很大转载 2017-06-03 09:39:26 · 503 阅读 · 0 评论 -
Python算术运算符
本章节主要说明Python的运算符。举个简单的例子 4 +5 = 9 。例子中,4 和 5 被称为操作数,"+" 称为运算符。Python语言支持以下类型的运算符:算术运算符比较(关系)运算符赋值运算符逻辑运算符位运算符成员运算符身份运算符运算符优先级接下来让我们一个个来学习Python的运算符。Python算术运算符以下假设变量: a=10,b=20:转载 2017-06-01 16:34:42 · 513 阅读 · 0 评论 -
Python的条件语句与运算符优先级详解(2)
Python 条件语句Python条件语句是通过一条或多条语句的执行结果(True或者False)来决定执行的代码块。可以通过下图来简单了解条件语句的执行过程:Python程序语言指定任何非0和非空(null)值为true,0 或者 null为false。Python 编程中 if 语句用于控制程序的执行,基本形式为:?123转载 2017-05-31 15:22:13 · 1571 阅读 · 0 评论 -
python 运算符优先级(1)
如果你有一个如2 + 3 * 4那样的表达式,是先做加法呢,还是先做乘法?我们的中学数学告诉我们应当先做乘法——这意味着乘法运算符的优先级高于加法运算符。下面这个表给出Python的运算符优先级,从最低的优先级(最松散地结合)到最高的优先级(最紧密地结合)。这意味着在一个表达式中,Python会首先计算表中较下面的运算符,然后在计算列在表上部的运算符。下面这张表(与Python参考手册中的转载 2017-05-31 15:21:02 · 872 阅读 · 0 评论