python
highoooo
这个作者很懒,什么都没留下…
展开
-
CV2 开闭
图像开运算是图像依次经过腐蚀、膨胀处理后的过程。图像被腐蚀后,去除了噪声,但是也压缩了图像;接着对腐蚀过的图像进行膨胀处理,可以去除噪声,并保留原有图像。开运算实际是先腐蚀运算,再膨胀运算,把看上去把细微连在一起的两块目标分开了。一般来说,开运算可以使图像的轮廓变得光滑,还能使狭窄的连接断开和消除细毛刺。开运算在过滤噪声的同时并没有对物体的形状、轮廓造成明显的影响,这是一大优势。当只关心物体的位置或者个数时,物体形状的改变不会给任务带来困扰,此时用开运算处理具有处理速度上的优势。闭运算是开运算的相反操作,先原创 2022-07-08 11:10:22 · 542 阅读 · 0 评论 -
python sort
sort原创 2022-06-07 09:52:14 · 89 阅读 · 1 评论 -
bisect
https://docs.python.org/zh-cn/3.7/library/bisect.html原创 2022-02-09 09:51:40 · 398 阅读 · 0 评论 -
饱和和非饱和激活函数
https://blog.csdn.net/qq_40824311/article/details/103017760原创 2022-02-08 16:04:15 · 447 阅读 · 0 评论 -
BatchN
from torch import nnimport torchtorch.manual_seed(21)input = torch.randn(1,3,3,3).cuda()input[0][0] = 0m3 = nn.BatchNorm2d(3, eps=0, momentum=0.5, affine=True, track_running_stats=True).cuda()m3.running_mean = (torch.ones([3])*4).cuda() # 设置模型的均原创 2022-02-08 15:25:12 · 1215 阅读 · 0 评论 -
thop 计算flops和params
from torchvision.models import resnet50from thop import profileimport torchmodel = resnet50()input = torch.randn(1, 3, 224, 224)flops, params = profile(model, inputs=(input, ))print("%s ------- params: %.2fMB ------- flops: %.2fG" % (model, params /原创 2022-02-08 13:38:40 · 2491 阅读 · 0 评论 -
侵线检测 python
侵线检测class cal_tools(object): def cal_slope(self,line): coorA = (line[0][0], line[0][1]) coorB = (line[0][2], line[0][3]) m = (coorB[1] - coorA[1]) / (coorB[0] - coorA[0] + 0.0000001) return m def slope_filter(self,原创 2021-12-13 13:36:33 · 1400 阅读 · 0 评论 -
PHOT-
import cv2import osimport numpy as npimport time# calculate The Phase Only Transformdef PHOT(image): # DFT F = np.fft.fft2(image) # get magnitude M = np.abs(F) # Get phase P = F / M # Reconstruct image from phase R =原创 2021-12-08 13:51:36 · 2483 阅读 · 0 评论 -
增加椭圆噪声
import scipy.statsimport torchimport globimport cv2import randomimport numpy as npdef make_noise(image_size, diag_limit=10): a = np.pi * np.random.random() R = np.array([ [np.cos(a), np.sin(a)], [-np.sin(a), np.cos(a)],原创 2021-12-08 09:19:57 · 169 阅读 · 0 评论 -
yolov5-deepstream
一、pytorch模型转为tensorrt模型1.yololayer.h中修改class_num2.Cmakelist中修改cuda路径3.build中编译生成yolov5文件4.sudo ./yolov5 -s [.wts] [.engine] [s/m/l/x/s6/m6/l6/x6 or c/c6 gd gw] // serialize model to plan file 生成.engine文件5.sudo ./yolov5 -d yolov5.engine …/samples 确定原创 2021-11-09 17:21:38 · 3248 阅读 · 0 评论 -
不常用的python符号和函数记录
vars() : 与args和class相关 转为字典形式星号 https://blog.csdn.net/zkk9527/article/details/88675129a={'A':1,'B':2,'C':3}print(a)print(*a)-------------------{'A': 1, 'B': 2, 'C': 3}A B CPath:https://blog.csdn.net/hxj0323/article/details/113374539...原创 2021-10-20 09:02:33 · 126 阅读 · 0 评论 -
Python 轨道区域检测(基于霍夫变换)
效果演示:(顺时针方向 - Ori-image/After canny/Final area/Hough lines)Maindef getline(imgpath): save_Edges = True save_Lines = True # Default - rate = 0.25 img, general_point = img_Preprocess(imgpath) gray, edges, orgb, orgb_lines, lines =原创 2021-10-14 10:26:51 · 1976 阅读 · 21 评论 -
color_split
import cv2import numpy as npimport collections# 定义字典存放颜色分量上下限# 例如:{颜色: [min分量, max分量]}# {'red': [array([160, 43, 46]), array([179, 255, 255])]}def getColorList(): dict = collections.defaultdict(list) # 黑色 lower_black = np.array([0,原创 2021-10-13 16:51:04 · 123 阅读 · 0 评论 -
C盘释放空间
一、删除休眠文件:转到“开始”菜单,键入“cmd”,然后右键单击结果“命令提示符”,然后选择“以管理员身份运行”。然后键入“powercfg. exe -h off”,然后按Enter。之后,你应该在C盘上看到多几个GB的可用空间。二、删除临时文件:Appdata/Local/temp 里面文件删除三、删除Local不必要文件:Appdata/Local 里面不必要文件删除四、开始->系统清理C盘文件五、C盘->属性->清理系统文件....原创 2021-09-27 09:15:24 · 98 阅读 · 0 评论 -
自定义dataset dataloader
https://blog.csdn.net/guyuealian/article/details/88343924转载 2021-09-24 17:10:29 · 62 阅读 · 0 评论 -
nargs
https://www.pynote.net/archives/1621#:~:text=%E8%80%8Cadd_argument%E5%87%BD%E6%95%B0%E6%9C%89%E4%B8%80%E4%B8%AAnargs%E5%8F%82%E6%95%B0%EF%BC%8C%E9%80%9A%E8%BF%87%E6%AD%A4%E5%8F%82%E6%95%B0%EF%BC%8C%E5%8F%AF%E4%BB%A5%E5%AE%9E%E7%8E%B0%E5%91%BD%E4%BB%A4%E8%A原创 2021-09-01 11:08:58 · 224 阅读 · 0 评论 -
model_name : Epoch{i}-Total_Loss{m}-Val_Loss{n}.pth to figure
import matplotlib.pyplot as pltimport globimport osimport numpy as npimport pylab as plfile_names = os.listdir("824_4classes_200epoch_logs")train_Loss_merge = np.empty(len(file_names))val_Loss_merge = np.empty(len(file_names))Epoch_merge = np.a原创 2021-08-26 16:29:07 · 111 阅读 · 0 评论 -
read - xml
xml -> annotationclass提前设定好import xml.etree.ElementTree as ETimport randomimport globall_class = ['straw hat' , 'train' , 'person' , 'hat' , 'head' , 'cellphone' , 'cell phone']act_class = ['hat' , 'head' , 'cellphone']def Read_Write_classest.原创 2021-08-26 16:26:02 · 445 阅读 · 0 评论 -
@classmethod
class Data_test(object): day=0 month=0 year=0 def __init__(self,year=0,month=0,day=0): self.day=day self.month=month self.year=year def out_date(self): print "year :" print self.year prin原创 2021-08-16 08:56:48 · 116 阅读 · 0 评论 -
Request:my post and get
import cv2import numpy as npimport requestsimport urllib.requestimport requestsimport jsondef my_post(): data = {"imageID":(None,"1648"), "imageKeyWord":(None,"811"), "project":(None,"bolttest"), "imgFileA":("原创 2021-08-16 08:26:19 · 119 阅读 · 0 评论 -
cv2.boundingRect和cv2.fillPol 用多边形填充图形
cv2.boundingRect和cv2.fillPol 用多边形填充图形: pts:提取出来的特征点 转为np.array->astype(dtype=int)->reshape(-1,1,2) ///boundingRec返回正矩形 /// minAreaRect返回最小斜矩形 x,y,w,h:返回矩形框的x,y,w,h newImg = np.full(img.shape, 255, dtype=np.uint8) 创建一个背景图原创 2021-04-14 16:08:52 · 491 阅读 · 0 评论 -
os.listdir顺序读取/ os.path.exists()+continue
1.files = os.listdir(……)顺序读取:files = [‘img1.jpg’,‘img5.jpg’,‘img9.jpg’]for i in range(len(files)):list = [f"img{i}".jpg ]return listos.pat.exists(file)+continue若不存在文件则进入下一个循环当图片是img0.jpg ,img5.jpg可用...原创 2021-04-14 16:20:01 · 492 阅读 · 0 评论 -
train/val/annotation
import randomwith open('annotation.txt', 'r') as ff: dataList = ff.readlines() tempList = set(range(len(dataList)))valIndex = set(random.sample(tempList, 760))trainIndex = tempList - valIndexvalList = [dataList[i].strip() for i in list(valInd原创 2021-04-19 15:08:54 · 173 阅读 · 1 评论 -
custom_dataset
https://blog.csdn.net/qq_38883271/article/details/96439208lenhttps://www.zhihu.com/question/46973549/answer/767530541inithttps://blog.csdn.net/chituozha5528/article/details/78354833getitem原创 2021-04-26 12:01:28 · 367 阅读 · 0 评论 -
os.system python执行shell
https://blog.csdn.net/Haiqiang1995/article/details/89284201原创 2021-06-21 15:34:13 · 228 阅读 · 0 评论 -
Python xml.etree.ElementTree解析XML文件
https://blog.csdn.net/weixin_36279318/article/details/79176475原创 2021-08-03 10:04:04 · 127 阅读 · 0 评论