python相关
一位不愿暴露自己的小可爱
把时间分给睡眠
分给书籍
分给运动
分给花鸟树木和山川湖海
分给你对这个世界的热爱
当你开始做时间的主人
你会感受到平淡生活中
喷涌而出的平静的力量
要永远年轻,永远热爱
展开
-
zip和tar解压文件到指定文件夹
解压 linux原创 2023-02-25 14:18:23 · 93 阅读 · 0 评论 -
Type must be a sub-type of ndarray type
python原创 2022-10-14 09:51:59 · 2501 阅读 · 0 评论 -
tfrecord生成对应的idx
生成idx原创 2022-09-14 17:19:17 · 314 阅读 · 0 评论 -
os.path.splitext()的用法
python原创 2022-06-11 15:09:43 · 818 阅读 · 0 评论 -
vscode无法激活虚拟环境
vscode的终端无法激活虚拟环境,网上的方法 https://blog.csdn.net/m0_46093829/article/details/122939521说需要安装pscondaenvs, 不争气的电脑一直报错NFO menuinst_win32:__init__(182): Menu: name: 'Anaconda${PY_VER} ${PLATFORM}', prefix: 'D:\anaconda', env_name: 'None', mode: 'None', used_mode原创 2022-04-26 17:55:55 · 812 阅读 · 0 评论 -
cuda10.2安装torch1.9
pip --default-timeout=1000 install torch==1.9.0+cu102 torchvision==0.10.0+cu102 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html原创 2022-04-22 16:17:41 · 2009 阅读 · 0 评论 -
ImportError: cannot import name ‘get_all_providers‘ from ‘onnxruntime.capi._pybind_state‘
报错如下:Traceback (most recent call last): File "test.py", line 7, in <module> from utils.utils_inference import InterfaceOnnx, InterfaceTorch File "F:\F_code\insightface_ir_train\utils\utils_inference.py", line 8, in <module> import原创 2022-04-22 10:34:44 · 1507 阅读 · 0 评论 -
批量删除指定的文件夹
import osimport shutildef move_dir(): file_root = 'J:/data/clear' dirs = os.listdir(file_root) target_move_root = r'\ryData\WebFace4u\\faces_g_img\\' target_move_dirs = os.listdir(target_move_root) for dir in dirs: print('remo原创 2022-04-14 14:41:02 · 641 阅读 · 0 评论 -
Linux压缩打包命令——tar、zip、unzip
最常用:tar -zcvf local_cover.tar.gz ./local_cover/https://blog.csdn.net/weixin_44901564/article/details/99682926转载 2022-04-07 16:59:34 · 164 阅读 · 0 评论 -
ntpath的用法
>>> import ntpath>>> zz='G:/RGB2IR_data/val/9_ir_SNAY0S4930049_yc1801_1573693797.png'>>> ntpath.basename(zz)'9_ir_SNAY0S4930049_yc1801_1573693797.png'>>> ntpath.join('zz0/zz1','zz2')'zz0/zz1\\zz2'原创 2022-03-24 16:53:12 · 811 阅读 · 0 评论 -
bash: kill: (74001) - 不允许的操作
需要进到container中操作,执行ps -ef | grep "train.py" | grep -v grep | awk '{print "kill -9 "$2}' | sh原创 2022-01-19 16:54:17 · 5954 阅读 · 0 评论 -
grep的用法
先说说grep命令能做什么?我们可以使用grep命令在文本中查找指定的字符串,就像你在windows中打开txt文件,使用快捷键 “Ctrl+F” 在文本中查找某个字符串一样,说白了,可以把grep理解成字符查找工具。grep是Linux中最常用的”文本处理工具”之一,grep与sed、awk合称为Linux中的三剑客。grep的全称为: Global search Regular Expression and Print out the line全称中的”Global search”为全局搜索之意原创 2022-01-18 13:49:02 · 1958 阅读 · 0 评论 -
python中的uuid通用唯一标识符
背景知识:UUID: 通用唯一标识符 ( Universally Unique Identifier ), 对于所有的UUID它可以保证在空间和时间上的唯一性. 它是通过MAC地址, 时间戳, 命名空间, 随机数, 伪随机数来保证生成ID的唯一性, 有着固定的大小( 128 bit ). 它的唯一性和一致性特点使得可以无需注册过程就能够产生一个新的UUID. UUID可以被用作多种用途, 既可以用来短时间内标记一个对象, 也可以可靠的辨别网络中的持久性对象.为什么要使用UUID?很多应用场景需要.原创 2021-12-24 14:20:41 · 393 阅读 · 0 评论 -
VScode提示未找到Git.请安装Git,或在“git.path”设置中配置
传送门:https://blog.csdn.net/qiqibei666/article/details/96966543转载 2021-12-21 10:57:34 · 2055 阅读 · 0 评论 -
ERROR: No matching distribution found for torch==1.2
运行命令pip install torch==1.2.0 -f https://download.pytorch.org/whl/torch_stable.html即可。原创 2021-12-17 17:46:55 · 465 阅读 · 0 评论 -
conda创建虚拟环境报错 Package missing in current win-64 channels
C:\Users\zg>conda create -n env_python37 python=3.7Fetching package metadata ...........PackageNotFoundError: Package missing in current win-64 channels: - python 3.7*原创 2021-12-17 17:13:27 · 5788 阅读 · 0 评论 -
TypeError: expected str, bytes or os.PathLike object, not int
安装好anaconda后,pip或者conda安装各种包都报错:TypeError: expected str, bytes or os.PathLike object, not int加入环境变量,不管用,最后解决方法:curl https://bootstrap.pypa.io/get-pip.py | python -原创 2021-12-17 16:57:31 · 1045 阅读 · 0 评论 -
pytorch中的scatter_()函数
传送门:https://www.cnblogs.com/daremosiranaihana/p/12538512.html转载 2021-12-08 14:07:01 · 164 阅读 · 0 评论 -
torch.clamp_min_方法
torch.clamp_min_方法设置一个下限min,tensor中有元素小于这个值, 就把对应的值赋为min>>> zz1tensor([ 130, 144, 183, 609, 818, 832, 891, 1386, 1494, 1729, 1739, 1785, 2671, 2802, 3444, 4711, 4754, 4763, 5728, 5842])>>> zz2 = zz1.clamp_min_(1000)>&原创 2021-12-08 11:40:29 · 6894 阅读 · 0 评论 -
明明有内存报错CUDA out of memory
RuntimeError: CUDA out of memory. Tried to allocate 2.42 GiB (GPU 0; 24.00 GiB total capacity; 113.84 MiB already allocated; 21.85 GiB free; 134.00 MiB reserved in total by PyTorch)百度,有人说是运行完python, 没有释放内存,运行nvidia-smi, 查看占用GPU的进程,命令TASKKILL /PID 18620 -原创 2021-12-07 15:49:09 · 1328 阅读 · 0 评论 -
Group Convolution分组卷积,以及Depthwise Convolution和Global Depthwise Convolution
原文写的非常详细GDC操作是在我们的人脸识别代码最后用来降维的操作,卷积核大小为7*7,作为特殊的一种分组卷积,相比GAP,GDC操作在不同的空间位置是有不同的权重的,尤其对人脸这种,中心和边界是有很大区别的,而GAP只是单纯的平均,细节见如下链接传送门:https://blog.csdn.net/blogshinelee/article/details/86094419...原创 2021-11-10 10:44:23 · 224 阅读 · 0 评论 -
notepad删除包含指定内容的行
删除包含字段“test_head_shoulder”的行注意要将查找模式,普通改成正则表达式,全部替换即可。原创 2021-11-03 17:36:15 · 1573 阅读 · 0 评论 -
from collections import defaultdict 的用法
defaultdict:当我使用普通的字典时,用法一般是dict={},添加元素的只需要dict[element] =value即,调用的时候也是如此,dict[element] = xxx,但前提是element字典里,如果不在字典里就会报错,如:这时defaultdict就能排上用场了,defaultdict的作用是在于,当字典里的key不存在但被查找时,返回的不是keyError而是一个默认值,这个默认值是什么呢,下面会说如何使用defaultdictdefaultdict接受一个工厂函数作为原创 2021-10-09 11:19:24 · 521 阅读 · 0 评论 -
cv2.addWeighted 图像叠加or图像混合加权
Python-OpenCV 图像叠加or图像混合加权实现函数说明cv2.addWeighted(src1, alpha, src2, beta, gamma[, dst[, dtype]]) → dst参数说明src1 – first input array.alpha – weight of the first array elements.src2 – second input array of the same size and channel number as src1.beta原创 2021-09-14 09:57:37 · 1410 阅读 · 0 评论 -
Python中的进程process
传送门转载 2021-09-12 19:45:13 · 119 阅读 · 0 评论 -
Python之系统交互(subprocess)
subprocess.getoutput(cmd) 功能:接收字符串格式的命令,执行命令并返回执行结果,其功能类似于os.popen(cmd).read()和commands.getoutput(cmd)。具体见:传送门转载 2021-09-12 17:18:41 · 188 阅读 · 0 评论 -
grep查找的内容输出到文件
使用grep查看服务日志是必备的技能,有时候遇上比较难排查的疑难杂症,需要将日志筛选后保存到指定文件,再下载到本地进行日志分析。将grep查找的内容输出到文件的示例:在文件server.log中查找 ‘search-string’ 并输出到用户目录下的/log/test.log文件中:grep 'search-string' server.log > ~/log/test.log如果test.log已存在,输出的内容将会覆盖test.log文件原有的内容如果test.log不存在,则会创建t转载 2021-09-12 17:15:34 · 11479 阅读 · 0 评论 -
csv追加写入的时候报错Permission denied
是把对应的csv打开了,关闭之后运行就没问题,把一个csv文件打乱顺序拆分为指定百分比的训练集和测试集,实现如下:import csvimport osimport randomdef split_csv(path, total_len, per): # 如果train.csv和vali.csv存在就删除 if os.path.exists('E:/Server/U2S_fake_face_test_0909_train.csv'): os.remove('E原创 2021-09-10 09:29:00 · 1122 阅读 · 2 评论 -
cv2.imread()和cv2.cvtColor() 的使用
import matplotlib.pyplot as pltimport cv2 # cv2.imread()接口读图像,读进来直接是BGR 格式数据格式在 0~255,通道格式为(W,H,C)img_BGR = cv2.imread('D:/Desktop/lena.jpg')plt.subplot(2,2,1)plt.imshow(img_BGR)plt.axis('off')plt.title('BGR') img_RGB = cv2.cvtColor(img_BGR, c.转载 2021-09-05 17:09:11 · 361 阅读 · 2 评论 -
shutil.rmtree()使用
在python文件中,使用shutil.rmtree(/XXX/XX/c)可以递归地删除文件夹c以及里面的文件,类似于linux系统中的 rm -rf原创 2021-09-05 16:17:07 · 691 阅读 · 0 评论 -
Python中动态导入对象importlib.import_module()的使用
大佬写的非常详细了,传送门转载 2021-09-02 17:16:10 · 291 阅读 · 0 评论 -
报错 from torchvision import _C as C ImportError: DLL load failed: 找不到指定的模块
运行程序,其中的torchvision报错:from torchvision import _C as C ImportError: DLL load failed: 找不到指定的模块解决方法:先把已有的pytorch和torchvision全部卸载,然后运行如下指令重装,把torch和torchvision重装,就OK了。现在from torchvision import _C完美通过!pip install torch==1.2.0+cu92 torchvision==0.4.0+cu92 -f原创 2021-09-02 16:20:39 · 1308 阅读 · 0 评论 -
python os.path.basename()方法
返回path最后的文件名。如果path以/或\结尾,那么就会返回空值。即os.path.split(path)的第二个元素。>>> import os>>> path = '/Users/beazley/Data/data.csv'>>> # Get the last component of the path>>> os.path.basename(path)'data.csv'...原创 2021-08-31 16:40:44 · 809 阅读 · 0 评论 -
VS Code终端窗口(TERMINAL)无法输入命令问题及解决办法
解决办法:右键VS Code快捷方式,点击属性,打开“兼容性”标签,勾选"以管理员身份运行此程序",点击确定。如下:结果:我的取消兼容模式运行这个程序,勾上以管理员身份运行此程序就成功了if 修改完成之后重启VS Code,还是不可以正常在终端窗口输入命令:最后解决办法:1.win+r 打开系统命令提示符cmd;2.窗口左上角右键 -> 属性 ,勾选“使用旧版本控制台”;3.重启VS Code;...原创 2021-08-18 11:38:34 · 2995 阅读 · 0 评论 -
卷积操作如何进行反向传播
传送门:https://www.zybuluo.com/hanbingtao/note/485480转载 2021-08-14 17:08:59 · 151 阅读 · 0 评论 -
Relu操作为啥能增加非线性
relu激活函数:Relu(x) = max(0, x)relu是分段线性函数,为什么能增加网络的非线性,个人认为,因为卷积操作的值有正有负,卷积的输出是relu的定义域,保持大于零的值,负数则对应为0,这就是非线性,当卷积输出全为正的时候,才是一个完全线性的网络。...原创 2021-08-14 17:06:42 · 827 阅读 · 0 评论 -
头肩检测数据清洗小工具
import osimport numpy as npimport cv2class WiderFaceDetection(): def __init__(self, txt_path): self.imgs_path = [] self.words = [] f = open(txt_path,'r') lines = f.readlines() isFirst = True labels =原创 2021-08-13 14:15:37 · 445 阅读 · 3 评论 -
Python OpenCV cv2鼠标事件标记和类型(MouseEventFlags、MouseEventTypes)
传送门:https://blog.csdn.net/lly1122334/article/details/88975503转载 2021-08-13 13:46:23 · 448 阅读 · 0 评论 -
OpenCV-Python setMouseCallback回调函数中图像变量img的传递方法解析
传送门:https://blog.csdn.net/LaoYuanPython/article/details/108176864转载 2021-08-13 13:43:05 · 159 阅读 · 0 评论 -
Python rindex()方法
描述Python rindex() 返回子字符串 str 在字符串中最后出现的位置,如果没有匹配的字符串会报异常,你可以指定可选参数[beg:end]设置查找的区间。语法rindex()方法语法:str.rindex(str, beg=0 end=len(string))参数str – 查找的字符串beg – 开始查找的位置,默认为0end – 结束查找位置,默认为字符串的长度。返回值返回子字符串 str 在字符串中最后出现的位置,如果没有匹配的字符串会报异常。实例以下实例展示了原创 2021-08-13 10:04:25 · 445 阅读 · 0 评论