
python
zouxiaolv
踏实、稳重、前行
展开
-
PyQt5--使用Qt Designer设计用户界面
(避免覆盖,继承生成的py文件)(界面需要加入main函数)原创 2023-02-08 12:00:15 · 670 阅读 · 1 评论 -
Autodl运行自己的代码
Autodl使用教程_可基大萌萌哒的马鹿的博客-优快云博客_autodl转载 2022-11-14 10:21:18 · 3453 阅读 · 0 评论 -
AssertionError: Default process group is not initialized
在tool/train.py开头加入如下语句即可。原创 2022-11-08 08:25:25 · 1351 阅读 · 0 评论 -
多头注意力机制的计算流、代码解析
这个N*[8*C1]的输出结果,经过[8*C1]*C2的全连接,得到N*C2的输出O。比如计算8个头的Q,K,V时,每个头计算Q要用一次矩阵乘法,计算K要用一次矩阵乘法,计算V要用一次矩阵乘法。用这个相关系数矩阵 和 v 进行矩阵的乘法,得到8*N*C1 的注意力输出结果,转化为N*[8*C1]然后8个头的q,k,v 一起并行进行注意力机制的计算,得到拼接在一起的N*[8*C1]的矩阵。将8个头的Q 合并为N*[8*C1]的q。将8个头的V 合并为N*[8*C1]的v。原创 2022-11-03 09:38:13 · 1062 阅读 · 0 评论 -
swim transformer之PatchMering实现方法
PatchMering的作用:其实就是下采样的作用。这里面用到花式python切片。原创 2022-10-31 19:38:58 · 832 阅读 · 0 评论 -
python 中[0]*2与0*2,[0 for _ in range(n)]的区别说明
【代码】python 中[0]*2与0*2,[0 for _ in range(n)]的区别说明。原创 2022-10-29 21:18:03 · 472 阅读 · 0 评论 -
【无标题】嘻嘻嘻嘻嘻嘻嘻
class PRM(nn.Module): def __init__(self, output_chl_num, efficient=False): super(PRM, self).__init__() self.output_chl_num = output_chl_num self.conv_bn_relu_prm_1 = conv_bn_relu(self.output_chl_num, self.output_chl_num, kerne.原创 2022-04-28 22:31:49 · 258 阅读 · 0 评论 -
注意力图可视化代码
https://github.com/szagoruyko/attention-transfer/blob/master/visualize-attention.ipynbfrom PIL import Imageimport requestsimport numpy as npfrom io import BytesIOimport torchfrom torch import nnfrom torchvision.models import resnet34from torchvis原创 2021-12-21 12:17:40 · 2907 阅读 · 0 评论 -
python,numpy中np.random.choice()的用法详解及其参考代码
https://blog.youkuaiyun.com/ImwaterP/article/details/96282230转载 2021-08-27 21:13:14 · 210 阅读 · 0 评论 -
python之类与函数
class Animals(object): def __init__(self,name): self.name = name def eyes(self): print("") def mouths(self): print('') def legs(self): print('')class People(Animals): """如果还有除了Animals的名字属相还有其他属.原创 2021-08-10 11:29:13 · 89 阅读 · 0 评论 -
python之self用法
3、python的几种变量——按作用域分1、全局变量:在模块内、在所有函数外面、在class外面,这就是全局变量。2、局部变量:在函数内、在class的方法内(未加self修饰的) ,这就是局部变量3、静态变量(也可以说,类属性):在class内的,但不在class的方法内的,这就是静态变量4、实例变量(也可以说,实例属性):在class的方法内的,用self修饰的变量,这就是实例变量1.变量:如果没有定义方法,仅是在类内定义的代表的是局部变量,直接类.zero就可以调用class .原创 2021-03-26 17:14:47 · 531 阅读 · 0 评论 -
numpy错误汇集
1、TypeError: Cannot interpret '720' as a data type这个错误是在我定义一个numpy数组的时候出现错误的。import numpy as np a = np.ones(1,16,64,64)#错误因为这不是一个整体数组维度正确的如下:a = np.ones((1,16,64,64))...原创 2020-12-27 19:34:41 · 1404 阅读 · 1 评论 -
opencv错误汇集
1、cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-vu_aq9yd/opencv/modules/imgproc/src/resize.cpp:3572: error: (-215:Assertion failed) !dsize.empty() in function 'resize'这个是在调pytorch_pose的数据预处理遇见的问题。就是输入图像的维度正确的是(h,w,3),但是经过下面的两个函数后,输入图像的变为(w,h,3)。就不符合cv2.res原创 2020-12-27 11:28:10 · 2470 阅读 · 0 评论 -
python之可变对象与不可变对象区别
一、可变对象1、可变对象定义: 不可变对象定义: 可变对象表示可以原处修改该数据对象。...转载 2020-12-09 11:15:05 · 1035 阅读 · 0 评论 -
python中的zip()函数详解
https://blog.youkuaiyun.com/wyisfish/article/details/79242387?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-2.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-2.control转载 2020-12-08 15:00:33 · 209 阅读 · 0 评论 -
numpy 之np.not_equal
np.not_equal比较的是对应元素是否相等.相等元素为false,不相等就是true对于第一种情况,比较的对象shape与第二个比较对象shape不相等,需要将维度广播,下面就是一个例子,将arr1进行广播arr1 = np.array([[11, 12, 13],[11, 12, 13]])import numpy as nparr1 = np.array([11, 12, 13])arr2 = np.array([[11, 22, 23],[21, 22, 23]])print.原创 2020-11-25 19:30:13 · 1870 阅读 · 0 评论 -
np.dot
https://www.cnblogs.com/Shawnyi/p/10370815.html转载 2020-11-25 18:09:01 · 196 阅读 · 0 评论 -
python之x.astype
import numpy as npx = np.array([1, True, False])b = x.astype(int)print(b)[1 1 0]这个函数是在人体姿态估计中获取最大热图值使用到#######这里的目的是将1*4096的预测热图值的矩阵变成64*64热图尺寸的形式 preds[:, :, 0] = (preds[:, :, 0]) % width preds[:, :, 1] = np.floor((preds[:, :, 1]) / w.原创 2020-11-25 10:24:53 · 1299 阅读 · 0 评论 -
numpy之np.tile函数
>>> import numpy>>> numpy.tile([0,0],5)#在列方向上重复[0,0]5次,默认行1次array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])>>> numpy.tile([0,0],(1,1))#在列方向上重复[0,0]1次,行1次array([[0, 0]])>>> numpy.tile([0,0],(2,1))#在列方向上重复[0,0]1次,行2次array([[0.原创 2020-11-25 09:52:38 · 754 阅读 · 0 评论 -
numpy之numpy.amax
numpy.amax(a, axis=None, out=None, keepdims=<no value>, initial=<no value>, where=<no value>)获取数据a的坐标轴方向的最大值。举例:a = np.arange(4).reshape((2,2))print(a)array([[0, 1], [2, 3]])##########################################np.原创 2020-11-25 09:10:49 · 990 阅读 · 0 评论 -
pytorch只计算20%代码如何编写
https://github.com/hellojialee/Multi-Person-Pose-using-Body-Parts/blob/7dd783f8dca4a8292232fcc724ecbd911a69f428/training/train_common.py#L82 model_metrics = [] inhouse_metrics = [] t0 = time() for i in range(validation_steps): # 分成很多个batc.原创 2020-10-06 20:10:45 · 145 阅读 · 0 评论 -
numpy 花式索引c = a[:, i]解释
复杂的多维(2)上面示例中,都是a[i]的形式输出的,那么对于a[:, i]来说,":"代表先是从第0个维度开始获取值到最后一个。c = a[:, i]就转换成c = [a[0][i], a[1][i], a[2][i], a[3][i], a[4][i]]原创 2020-09-20 21:29:19 · 751 阅读 · 0 评论 -
python学习-isinstance()
isinstance()是一个内置的函数(BIF)。它允许某个特定标识符是否包含某个特定类型的数据如判断某个对象是不是列表、字典、整型等>>> a = [1,2,3]>>> b = 123>>> c = {1:2,2:3}>>> isinstance(a,list)True>>> isinstance(a,dict)False>>> isinstance(b,int)Tru原创 2020-09-10 20:49:50 · 980 阅读 · 2 评论 -
Given groups=1, weight of size [256,1024,1, 1], expected input[1, 256, 64, 64] to have 1024
错误:Given groups=1, weight of size [256,1024,1, 1], expected input[1, 256, 64, 64] to have 1024,但是通道数是256解决问题:将变通道代码不在for循环即可,就解决此问题了。原创 2020-09-10 07:52:24 · 4641 阅读 · 2 评论 -
TypeError: cat(): argument ‘tensors‘ (position 1) must be tuple of Tensors, not Tensor解决
原创 2020-09-09 16:28:21 · 4413 阅读 · 0 评论 -
#对列表中的元素是tensor形式,取出后在进行合并的代码块
#对列表中的元素是tensor形式,取出后在进行合并的代码块import torchimport torch.nn as nnimport numpy as np# vec = [[1,2,3],[4,5,6],[7,8,9]]v= torch.rand(1,3,5,5)a = torch.rand(1,3,5,5)g = torch.rand(1,3,5,5)print('v = ',v)print('a = ',a)print('g = ',g)cc = [v,a,g]pri.原创 2020-09-09 15:55:46 · 572 阅读 · 0 评论 -
Python中self用法详解
https://blog.youkuaiyun.com/CLHugh/article/details/75000104#commentBox转载 2020-06-18 18:42:04 · 621 阅读 · 0 评论 -
高斯核函数在图像中的应用——模糊"(blur)滤镜,让图像产生模糊效果
通常,图像处理软件会提供"模糊"(blur)滤镜,使图片产生模糊的效果(或者让图像起到平滑效果)。有很多种模糊算法,本文只介绍高斯模糊。本文介绍"高斯模糊"的算法,你会看到这是一个非常简单易懂的算法。本质上,它是一种数据平滑技术(data smoothing),适用于多个场合,图像处理恰好提供了一个直观的应用实例。一、高斯模糊的原理...原创 2020-04-27 17:06:00 · 1303 阅读 · 0 评论 -
Attention Model(mechanism) 的 套路
https://blog.youkuaiyun.com/bvl10101111/article/details/78470716https://blog.youkuaiyun.com/yideqianfenzhiyi/article/details/79422857原创 2020-04-03 21:18:08 · 252 阅读 · 0 评论 -
Python-copy()与deepcopy()区别
https://blog.youkuaiyun.com/qq_32907349/article/details/52190796?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task转载 2020-03-31 16:55:01 · 135 阅读 · 0 评论 -
【python】详解collections模块中OrderedDict的使用
很多人认为python中的字典是无序的,因为它是按照hash来存储的,但是python中有个模块collections(英文,收集、集合),里面自带了一个子类OrderedDict,实现了对字典对象中元素的排序。# -*- coding: utf-8 -*-from collections import OrderedDictitems = ( ('A', 1), ...转载 2020-03-31 10:34:39 · 1076 阅读 · 0 评论 -
Math.ceil()
1、Math.ceil()“向上取整”, 即小数部分直接舍去,并向正数部分进1,(如果是负数部分不进1) double d = 3.1415926; double d3 = -15.23; double d5 = -16.5; double d6 = 16.5; ...原创 2020-03-23 09:30:57 · 6595 阅读 · 0 评论 -
numpy.argmax()
argmax返回的是最大数的索引.argmax有一个参数axis,默认是0,表示第几维的最大值.看二维的情况.import numpy as npa = np.array([[1, 5, 5, 2], [9, 6, 2, 8], [3, 7, 9, 1]])print(np.argmax(a, axis=0))[1,2,2,1...转载 2020-03-17 09:56:26 · 252 阅读 · 0 评论 -
python中的os.path.dirname(__file__)的使用
os.path.dirname(__file__)返回脚本的路径,但是需要注意一下几点:1、必须是实际存在的.py文件,如果在命令行执行,则会引发异常NameError: name '__file__' is not defined2、在运行的时候如果输入完整的执行的路径,则返回.py文件的全路径如: python D:/test/test.py 则返回路径 D:/test ...原创 2020-03-16 09:13:13 · 415 阅读 · 0 评论 -
argparse基本用法
1、先导入了argparse这个包,然后包中的ArgumentParser类生成一个parser对象(好多博客中把这个叫做参数解析器);2、description描述这个参数解析器是干什么的,当我们在命令行显示帮助信息的时候会看到description描述的信息。3、接着我们通过对象的add_argument函数来增加参数。这里我们增加了两个参数name和year,其中'-n','--n...原创 2020-03-15 10:57:58 · 196 阅读 · 0 评论 -
Python中*args 和**kwargs的用法
https://blog.youkuaiyun.com/chenjinyu_tang/article/details/8136841?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task转载 2020-03-08 13:40:37 · 144 阅读 · 0 评论 -
python3读取文件夹下的文件,以及检查有多少图片
"""#https://blog.youkuaiyun.com/gusui7202/article/details/83239142(参考博客)qhy。"""import sysimport osi=0data_dir = "/media/z"file_list = []write_file_name = '/media/s.txt'write_file = open(write_fil...原创 2019-09-26 09:33:31 · 875 阅读 · 0 评论 -
python对txt里的文件名进行排序
b=[]count = 1all_count = 1filename = "/media/z/CC/zxl/数据集/LEEDS/selected/zong.txt"output_file='/media/z/CC/zxl/数据集/LEEDS/selected/d.txt'country_list = []with open(filename, "r") as ins: #打开文件 ...原创 2019-09-26 14:55:09 · 1868 阅读 · 0 评论 -
python实现对一个文件夹下的多个txt进行合并成一个txt,并且对合并的txt文件内容进行排序
#############################合并多个txt文件为一个txt文件import osdirPath = "/media/pc" #所有txt位于的文件夹路径files = os.listdir(dirPath)res = ""i = 0for file in files: if file.endswith(".txt"): i += ...原创 2019-09-26 15:51:57 · 991 阅读 · 0 评论 -
python查找txt文件中重复文件
d = {}for line in open('a.txt'): d[line] = d.get(line, 0) + 1 fd = open('b.txt', 'w')for k, v in d.items(): if v > 1: fd.write(k)fd.close()转载 2019-09-27 08:15:39 · 960 阅读 · 0 评论